protected void Page_Load(object sender, EventArgs e) { if (!this.Page.IsPostBack) { int queryString = RequestHelper.GetQueryString <int>("ID"); CourseCateInfo CourseCateModel = new CourseCateInfo(); CourseCateModel.Condition = systemCompanyId.ToString(); this.CateId.DataSource = CourseCateBLL.ReadCourseCateNamedList(CourseCateModel); this.CateId.DataTextField = "CateName"; this.CateId.DataValueField = "CateId"; this.CateId.DataBind(); this.CateId.Items.Insert(0, new ListItem("请选择类别", "-1")); if (queryString != int.MinValue) { base.CheckAdminPower("UpdateCourse", PowerCheckType.Single); CourseInfo CourseModel = CourseBLL.ReadCourse(queryString); //if (CompanyId.Items.Contains(CompanyId.Items.FindByValue(CourseModel.CompanyId.ToString()))) CompanyId.Items.FindByValue(CourseModel.CompanyId.ToString()).Selected = true; if (this.CateId.Items.Contains(this.CateId.Items.FindByValue(CourseModel.CateId.ToString()))) { this.CateId.Items.FindByValue(CourseModel.CateId.ToString()).Selected = true; } this.CourseName.Text = CourseModel.CourseName; //this.CourseCode.Text = CourseModel.CourseCode; this.OrderIndex.Text = CourseModel.OrderIndex.ToString(); } else { base.CheckAdminPower("AddCourse", PowerCheckType.Single); } } //Control control = FindControlById(this, "CompanyId1"); //if (control != null) ScriptHelper.Alert("找到了"); }
protected void FileOutButton_Click(object sender, EventArgs e) { int QuestionOutNum = 0; if (!string.IsNullOrEmpty(QuestionNum.Text)) { QuestionOutNum = int.Parse(QuestionNum.Text); } if (Action == "TestCateFileOut") { ProductInfo product = ProductBLL.ReadProduct(CateId); AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("TestCateFileOut"), product.Name); if (!string.IsNullOrEmpty(product.Accessory)) { ExcelOut(product.Accessory, product.Name, QuestionOutNum, 1); } } else if (Action == "BatchFileOut") { string FilePath = "~/xml/Demo.xls"; XlsDocument xls = new XlsDocument(); //创建空xls文档 xls.FileName = Server.MapPath(FilePath); //保存路径,如果直接发送到客户端的话只需要名称 生成名称 foreach (string courseID in courseIDStr.Split(',')) { string courseName = CourseBLL.ReadCourse(int.Parse(courseID)).CourseName; AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("TestCateFileOut"), courseName); ExcelOut(xls, courseID, courseName, QuestionOutNum, 1); } //生成保存到服务器如果存在不会覆盖并且报异常所以先删除在保存新的 if (File.Exists(Server.MapPath(FilePath))) { File.Delete(Server.MapPath(FilePath));//删除 } //保存文档 xls.Save(Server.MapPath(FilePath)); //保存到服务器 xls.Send(); //发送到客户端 } else { AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("TestCateFileOut"), CourseName.Text); ExcelOut(CateId.ToString(), CourseName.Text, QuestionOutNum, 1); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Action == "CourseFileOut") { filein.Style["display"] = "none"; ListShow.Style["display"] = "none"; FileInButton.Visible = false; CourseName.Text = CourseBLL.ReadCourse(CateId).CourseName; } else if (Action == "CourseFileIn") { filein.Style["display"] = ""; fileout.Style["display"] = "none"; ListShow.Style["display"] = ""; FileOutButton.Visible = false; QuestionOutButton.Visible = false; CourseName.Text = CourseBLL.ReadCourse(CateId).CourseName + "【现有题目数量:" + QuestionBLL.ReadList(CateId).Count.ToString() + "】"; } else if (Action == "TestCateFileOut") { filein.Style["display"] = "none"; ListShow.Style["display"] = "none"; FileInButton.Visible = false; CourseName.Text = ProductBLL.ReadProduct(CateId).Name; } else if (Action == "BatchFileOut") { filein.Style["display"] = "none"; ListShow.Style["display"] = "none"; FileInButton.Visible = false; QuestionOutButton.Visible = false; CourseName.Text = "批量导出"; } } }
protected void Page_Load(object sender, EventArgs e) { Control singleTest = FindControlById(this, "singleTest"); Control MultiTest = FindControlById(this, "MultiTest"); Control PanDuanTest = FindControlById(this, "PanDuanTest"); if (!IsPostBack) { int queryString = RequestHelper.GetQueryString <int>("ID"); int CourseId = RequestHelper.GetQueryString <int>("CourseId"); int cateid = RequestHelper.GetQueryString <int>("CateId"); CourseCateInfo CourseCateModel = new CourseCateInfo(); CourseCateModel.Condition = systemCompanyId.ToString(); this._CateId.DataSource = CourseCateBLL.ReadCourseCateNamedList(CourseCateModel); this._CateId.DataTextField = "CateName"; this._CateId.DataValueField = "CateId"; this._CateId.DataBind(); this._CateId.Items.Insert(0, new ListItem("请选择类别", "-1")); _CateId.SelectedValue = cateid.ToString(); if (CourseId != int.MinValue) { CourseInfo CourseModel = new CourseInfo(); CourseModel.CateId = cateid; this._CourseId.DataSource = CourseBLL.ReadList(CourseModel); this._CourseId.DataTextField = "CourseName"; this._CourseId.DataValueField = "CourseId"; this._CourseId.DataBind(); _CourseId.SelectedValue = CourseId.ToString(); } if (queryString != int.MinValue) { base.CheckAdminPower("ReadQuestion", PowerCheckType.Single); QuestionInfo QuestionModel = QuestionBLL.ReadQuestion(queryString); int CateId = CourseBLL.ReadCourse(QuestionModel.CateId).CateId; _CateId.SelectedValue = CateId.ToString(); CourseInfo CourseModel = new CourseInfo(); CourseModel.CateId = CateId; this._CourseId.DataSource = CourseBLL.ReadList(CourseModel); this._CourseId.DataTextField = "CourseName"; this._CourseId.DataValueField = "CourseId"; this._CourseId.DataBind(); _CourseId.SelectedValue = QuestionModel.CateId.ToString(); this.Quetion.Text = QuestionModel.Question; this.TestType.Text = QuestionModel.Style; if (QuestionModel.Style == "1") { this.SingleA.Text = QuestionModel.A; this.SingleB.Text = QuestionModel.B; this.SingleC.Text = QuestionModel.C; this.SingleD.Text = QuestionModel.D; switch (QuestionModel.Answer.ToUpper()) { case "A": this.SingleAnswerA.Checked = true; break; case "B": this.SingleAnswerB.Checked = true; break; case "C": this.SingleAnswerC.Checked = true; break; case "D": this.SingleAnswerD.Checked = true; break; } this.singleTest.Style.Add("display", ""); this.MultiTest.Style.Add("display", "none"); this.PanDuanTest.Style.Add("display", "none"); } else if (QuestionModel.Style == "2") { this.MultiA.Text = QuestionModel.A; this.MultiB.Text = QuestionModel.B; this.MultiC.Text = QuestionModel.C; this.MultiD.Text = QuestionModel.D; for (int i = 0; i < QuestionModel.Answer.Length; i++) { switch (QuestionModel.Answer.ToUpper().Substring(i, 1)) { case "A": this.MultiAnswerA.Checked = true; break; case "B": this.MultiAnswerB.Checked = true; break; case "C": this.MultiAnswerC.Checked = true; break; case "D": this.MultiAnswerD.Checked = true; break; } } this.singleTest.Style.Add("display", "none"); this.MultiTest.Style.Add("display", ""); this.PanDuanTest.Style.Add("display", "none"); } else if (QuestionModel.Style == "3") { this.JudgeAnswer.Text = QuestionModel.Answer; if (QuestionModel.Answer == "0") { JudgeRightAnswer.Text = QuestionModel.A; RightAnswer.Style["display"] = ""; } this.singleTest.Style.Add("display", "none"); this.MultiTest.Style.Add("display", "none"); this.PanDuanTest.Style.Add("display", ""); } } } }