当前位置: 首页>>代码示例>>C#>>正文


C# DataSet1.NewRow方法代码示例

本文整理汇总了C#中DataSet1.NewRow方法的典型用法代码示例。如果您正苦于以下问题:C# DataSet1.NewRow方法的具体用法?C# DataSet1.NewRow怎么用?C# DataSet1.NewRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataSet1的用法示例。


在下文中一共展示了DataSet1.NewRow方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExportPDF

        public FileContentResult ExportPDF()
        {
            var tn_ExamUser = (TN_ExamUser)Session[SessionKey.ExamUserObject];
            if (tn_ExamUser == null) return null;

            var tnExamUser = db.TN_ExamUser.FirstOrDefault(m => m.ID == tn_ExamUser.ID);
            if (tnExamUser != null)
            {
                var user = tnExamUser.TN_User;
                string fileType = "pdf";
                string fileExtendsion = "pdf";

                var listTN_ExamUserAnswer = tnExamUser != null ? tnExamUser.TN_ExamUserAnswer : null;
                int count = 0;
                string[] getAnswer = { "A", "B", "C", "D", "E", "F", "G", "H" };
                if (listTN_ExamUserAnswer != null && listTN_ExamUserAnswer.Count > 0)
                {
                    DataTable dt = new DataSet1().KetQua;
                    for (int i = 0; i < listTN_ExamUserAnswer.Count; i++)
                    {
                        var quest = listTN_ExamUserAnswer.ElementAt(i).TN_Question;
                        var answerTrue = quest != null && quest.TN_Answer != null && quest.TN_Answer.Count > 0 ? quest.TN_Answer : null;
                        if (answerTrue != null && answerTrue.Count > 0)
                        {
                            string traloi = "", dapan = "";
                            for (int j = 0; j < answerTrue.Count; j++)
                            {
                                if (answerTrue.ElementAt(j).ID == listTN_ExamUserAnswer.ElementAt(i).AnswerID)
                                {
                                    traloi = getAnswer[j];
                                }
                                if (answerTrue.ElementAt(j).IsCorrect)
                                {
                                    dapan = getAnswer[j];
                                    if (answerTrue.ElementAt(j).ID == listTN_ExamUserAnswer.ElementAt(i).AnswerID)
                                    {
                                        count++;
                                    }
                                }
                            }
                            DataRow dr = dt.NewRow();
                            dr["CauHoi"] = "Câu " + (i + 1);
                            dr["TraLoi"] = traloi;
                            dr["DapAn"] = dapan;
                            dt.Rows.Add(dr);
                        }

                    }
                    LocalReport localReport = new LocalReport();
                    localReport.ReportPath = Server.MapPath("~/Views/Home/KetQua.rdlc");
                    string title = tnExamUser.TN_Exam != null ? tnExamUser.TN_Exam.Content : "";
                    ReportParameter param0 = new ReportParameter("Title", title);
                    ReportParameter param1 = new ReportParameter("Name", user.FullName);
                    ReportParameter param2 = new ReportParameter("SBD", user.SBD);
                    ReportParameter param3 = new ReportParameter("Mark", count + " / " + listTN_ExamUserAnswer.Count);

                    ReportDataSource reportDataSource = new ReportDataSource();
                    localReport.SetParameters(new ReportParameter[] { param0, param1, param2, param3 });
                    reportDataSource.Name = "DataSet1";
                    reportDataSource.Value = dt;
                    localReport.DataSources.Add(reportDataSource);
                    Byte[] mybytes = localReport.Render(fileType);

                    Response.AppendHeader("Content-Disposition", "inline; Ket-qua_" + user.SBD + "." + fileExtendsion);
                    return File(mybytes, "application/pdf");
                }
            }
            return null;
        }
开发者ID:huyenvv,项目名称:bv74tw-tracnghiem,代码行数:69,代码来源:HomeController.cs


注:本文中的DataSet1.NewRow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。