/// <summary> /// 保存按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { string strRowID = hfFormID.Text; Model.Base_GasCylinder gasCylinder = new Model.Base_GasCylinder { GasCylinderCode = this.txtGasCylinderCode.Text.Trim(), GasCylinderName = this.txtGasCylinderName.Text.Trim(), Remark = txtRemark.Text.Trim() }; if (string.IsNullOrEmpty(strRowID)) { gasCylinder.GasCylinderId = SQLHelper.GetNewID(typeof(Model.Base_GasCylinder)); BLL.GasCylinderService.AddGasCylinder(gasCylinder); BLL.LogService.AddSys_Log(this.CurrUser, gasCylinder.GasCylinderCode, gasCylinder.GasCylinderId, BLL.Const.GasCylinderMenuId, BLL.Const.BtnAdd); } else { gasCylinder.GasCylinderId = strRowID; BLL.GasCylinderService.UpdateGasCylinder(gasCylinder); BLL.LogService.AddSys_Log(this.CurrUser, gasCylinder.GasCylinderCode, gasCylinder.GasCylinderId, BLL.Const.GasCylinderMenuId, BLL.Const.BtnModify); } this.SimpleForm1.Reset(); // 重新绑定表格,并点击当前编辑或者新增的行 BindGrid(); PageContext.RegisterStartupScript(String.Format("F('{0}').selectRow('{1}');", Grid1.ClientID, gasCylinder.GasCylinderId)); }
/// <summary> /// 根据主键删除气瓶类型 /// </summary> /// <param name="gasCylinderId"></param> public static void DeleteGasCylinderById(string gasCylinderId) { Model.SUBHSSEDB db = Funs.DB; Model.Base_GasCylinder gasCylinder = db.Base_GasCylinder.FirstOrDefault(e => e.GasCylinderId == gasCylinderId); if (gasCylinder != null) { db.Base_GasCylinder.DeleteOnSubmit(gasCylinder); db.SubmitChanges(); } }
/// <summary> /// 修改气瓶类型 /// </summary> /// <param name="gasCylinder"></param> public static void UpdateGasCylinder(Model.Base_GasCylinder gasCylinder) { Model.SUBHSSEDB db = Funs.DB; Model.Base_GasCylinder newGasCylinder = db.Base_GasCylinder.FirstOrDefault(e => e.GasCylinderId == gasCylinder.GasCylinderId); if (newGasCylinder != null) { newGasCylinder.GasCylinderCode = gasCylinder.GasCylinderCode; newGasCylinder.GasCylinderName = gasCylinder.GasCylinderName; newGasCylinder.Remark = gasCylinder.Remark; db.SubmitChanges(); } }
/// <summary> /// 添加气瓶类型 /// </summary> /// <param name="gasCylinder"></param> public static void AddGasCylinder(Model.Base_GasCylinder gasCylinder) { Model.SUBHSSEDB db = Funs.DB; Model.Base_GasCylinder newGasCylinder = new Model.Base_GasCylinder { GasCylinderId = gasCylinder.GasCylinderId, GasCylinderCode = gasCylinder.GasCylinderCode, GasCylinderName = gasCylinder.GasCylinderName, Remark = gasCylinder.Remark }; db.Base_GasCylinder.InsertOnSubmit(newGasCylinder); db.SubmitChanges(); }