/// <summary> /// 保存按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { string strRowID = hfFormID.Text; Model.Base_AccidentType accidentType = new Model.Base_AccidentType { AccidentTypeCode = this.txtAccidentTypeCode.Text.Trim(), AccidentTypeName = this.txtAccidentTypeName.Text.Trim(), Remark = txtRemark.Text.Trim() }; if (string.IsNullOrEmpty(strRowID)) { accidentType.AccidentTypeId = SQLHelper.GetNewID(typeof(Model.Base_AccidentType)); BLL.AccidentTypeService.AddAccidentType(accidentType); BLL.LogService.AddSys_Log(this.CurrUser, accidentType.AccidentTypeCode, accidentType.AccidentTypeId, BLL.Const.AccidentTypeMenuId, BLL.Const.BtnAdd); } else { accidentType.AccidentTypeId = strRowID; BLL.AccidentTypeService.UpdateAccidentType(accidentType); BLL.LogService.AddSys_Log(this.CurrUser, accidentType.AccidentTypeCode, accidentType.AccidentTypeId, BLL.Const.AccidentTypeMenuId, BLL.Const.BtnModify); } this.SimpleForm1.Reset(); // 重新绑定表格,并点击当前编辑或者新增的行 BindGrid(); PageContext.RegisterStartupScript(String.Format("F('{0}').selectRow('{1}');", Grid1.ClientID, accidentType.AccidentTypeId)); }
/// <summary> /// 根据主键删除事故类型 /// </summary> /// <param name="accidentTypeId"></param> public static void DeleteAccidentTypeById(string accidentTypeId) { Model.SUBHSSEDB db = Funs.DB; Model.Base_AccidentType accidentType = db.Base_AccidentType.FirstOrDefault(e => e.AccidentTypeId == accidentTypeId); if (accidentType != null) { db.Base_AccidentType.DeleteOnSubmit(accidentType); db.SubmitChanges(); } }
/// <summary> /// 修改事故类型 /// </summary> /// <param name="accidentType"></param> public static void UpdateAccidentType(Model.Base_AccidentType accidentType) { Model.SUBHSSEDB db = Funs.DB; Model.Base_AccidentType newAccidentType = db.Base_AccidentType.FirstOrDefault(e => e.AccidentTypeId == accidentType.AccidentTypeId); if (newAccidentType != null) { newAccidentType.AccidentTypeCode = accidentType.AccidentTypeCode; newAccidentType.AccidentTypeName = accidentType.AccidentTypeName; newAccidentType.Remark = accidentType.Remark; db.SubmitChanges(); } }
/// <summary> /// 添加事故类型 /// </summary> /// <param name="accidentType"></param> public static void AddAccidentType(Model.Base_AccidentType accidentType) { Model.SUBHSSEDB db = Funs.DB; Model.Base_AccidentType newAccidentType = new Model.Base_AccidentType { AccidentTypeId = accidentType.AccidentTypeId, AccidentTypeCode = accidentType.AccidentTypeCode, AccidentTypeName = accidentType.AccidentTypeName, Remark = accidentType.Remark }; db.Base_AccidentType.InsertOnSubmit(newAccidentType); db.SubmitChanges(); }