private void InitData() { txtC_Code.Text = bll.GetMaxCode(); if (Id > 0) { //edit model = bll.GetModel(Id); if (model != null) { txtC_Name.Text = model.C_Name; txtC_Code.Text = model.C_Code; if (model.C_Code != "") { txtC_Code.Enabled = false; } txtC_Course.Text = model.C_Course; hideC_Course.Value = model.C_Courseid; txtC_Teacher.Text = model.C_Teacher; hideC_Teacher.Value = model.C_Teacherid; txtStudents.Text = new MW.BLL.B_ecan_user().GetUserNameAoe(model.Students.Trim(',')); hideStudents.Value = model.Students; txtChexi.Text = new MW.BLL.B_ecan_domainvalue().GetString(model.Chexi.Trim(',')); hideChexi.Value = model.Chexi; string[] arr = Utils.SplitString(model.Changdi, ",", 3); chkgl.Checked = arr[0] == "0"; chkyd.Checked = arr[1] == "1"; chkyy.Checked = arr[2] == "2"; //JBind.SetSelectedList(txtChangdi, model.Changdi.Split(',')); } } }
protected void btnSave_Click(object sender, EventArgs p1) { if (Id > 0) { #region __________Edit__________ model = bll.GetModel(Id); model.C_Name = txtC_Name.Text; model.C_Code = txtC_Code.Text; model.C_Course = txtC_Course.Text; model.C_Courseid = hideC_Course.Value; model.C_Teacher = txtC_Teacher.Text; model.C_Teacherid = hideC_Teacher.Value; model.Students = hideStudents.Value; model.Chexi = hideChexi.Value; model.Changdi = getcd(); if (bll.Update(model)) { bll.ClearCache("_info"); MessageBox.JSLoad(this, "alert('保存成功!');window.location.href='testdriverlist.aspx'"); } #endregion } else { #region __________Add__________ model.C_Name = txtC_Name.Text; model.C_Code = txtC_Code.Text; model.C_Course = txtC_Course.Text; model.C_Courseid = hideC_Course.Value; model.C_Teacher = txtC_Teacher.Text; model.C_Teacherid = hideC_Teacher.Value; model.Students = hideStudents.Value; model.Chexi = hideChexi.Value; model.Changdi = getcd(); if (bll.Add(model)) { MessageBox.JSLoad(this, "alert('新增成功!');window.location.href='testdriverlist.aspx'"); } #endregion } }