/// <summary> /// 保存按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { string strRowID = hfFormID.Text; Model.Base_Depart depart = new Model.Base_Depart { DepartCode = this.txtDepartCode.Text.Trim(), DepartName = this.txtDepartName.Text.Trim(), Remark = txtRemark.Text.Trim() }; if (string.IsNullOrEmpty(strRowID)) { depart.DepartId = SQLHelper.GetNewID(typeof(Model.Base_Depart)); BLL.DepartService.AddDepart(depart); BLL.LogService.AddSys_Log(this.CurrUser, depart.DepartCode, depart.DepartId, BLL.Const.DepartTypeMenuId, BLL.Const.BtnAdd); } else { depart.DepartId = strRowID; BLL.DepartService.UpdateDepart(depart); BLL.LogService.AddSys_Log(this.CurrUser, depart.DepartCode, depart.DepartId, BLL.Const.DepartTypeMenuId, BLL.Const.BtnModify); } this.SimpleForm1.Reset(); // 重新绑定表格,并点击当前编辑或者新增的行 BindGrid(); PageContext.RegisterStartupScript(String.Format("F('{0}').selectRow('{1}');", Grid1.ClientID, depart.DepartId)); }
/// <summary> /// 根据主键删除信息 /// </summary> /// <param name="departId"></param> public static void DeleteDepartById(string departId) { Model.SUBHSSEDB db = Funs.DB; Model.Base_Depart depart = db.Base_Depart.FirstOrDefault(e => e.DepartId == departId); { db.Base_Depart.DeleteOnSubmit(depart); db.SubmitChanges(); } }
/// <summary> /// 修改 /// </summary> /// <param name="teamGroup"></param> public static void UpdateDepart(Model.Base_Depart depart) { Model.SUBHSSEDB db = Funs.DB; Model.Base_Depart newDepart = db.Base_Depart.FirstOrDefault(e => e.DepartId == depart.DepartId); if (newDepart != null) { newDepart.DepartCode = depart.DepartCode; newDepart.DepartName = depart.DepartName; newDepart.Remark = depart.Remark; db.SubmitChanges(); } }
/// <summary> /// 添加 /// </summary> /// <param name="?"></param> public static void AddDepart(Model.Base_Depart depart) { Model.SUBHSSEDB db = Funs.DB; Model.Base_Depart newDepart = new Model.Base_Depart { DepartId = depart.DepartId, DepartCode = depart.DepartCode, DepartName = depart.DepartName, Remark = depart.Remark }; db.Base_Depart.InsertOnSubmit(newDepart); db.SubmitChanges(); }