using System; using System.Collections.Generic; using System.Text; using System.Data; namespace WebAPI.DLL { public class ClsGy_InspectInstruMent_Ctl : DBUtility.ClsGy_Base_Ctl { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); //原代码 用于 替换子项目 public string HOldNumber; public Model.ClsGy_InspectInstruMent_Model oModel = new Model.ClsGy_InspectInstruMent_Model(); //新增 public bool AddNew(ref string sExeReturnInfo) { // try { oCn.BeginTran(); //保存前控制========================================= DataSet ds = oCn.RunProcReturn("Exec h_p_Gy_InspectInstruMent_BeforeSaveCtrl " + oModel.HMakeEmp + ",'1'", "h_p_Gy_InspectInstruMent_BeforeSaveCtrl"); if (ds == null) { oCn.RollBack(); sExeReturnInfo = "保存前判断失败!"; return false; } if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0") { oCn.RollBack(); sExeReturnInfo = "保存失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); return false; } //========================================================= oCn.RunProc("Insert into " + MvarItemKey + " " + " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HCREATEORGID,HERPItemID" + ",HCalibrationStatus,HCalibrationDate,HValidDate,HExpiryDay) " + " Values('" + oModel.HNumber + "','" + oModel.HName + "','" + oModel.HHelpCode + "','" + oModel.HShortNumber + "'," + oModel.HParentID.ToString() + "," + oModel.HLevel.ToString() + "," + Convert.ToString(oModel.HEndFlag ? 1 : 0) + "," + Convert.ToString(oModel.HStopflag ? 1 : 0) + ",'" + oModel.HRemark + "','" +DateTime.Now+ "','" + oModel.HUSEORGID + "','" + oModel.HUseFlag + "','" + oModel.HMakeEmp+ "','" + oModel.HUSEORGID + "','" + 0 + "'" + ",'" + oModel.HCalibrationStatus.ToString() + "','" + oModel.HCalibrationDate.ToString() + "','" + oModel.HValidDate.ToString() + "','" + oModel.HExpiryDay.ToString() + "')", ref DBUtility.ClsPub.sExeReturnInfo); //修改上级为非末级代码 oCn.RunProc("Update " + MvarItemKey + " set HEndflag=0 where HItemID=" + oModel.HParentID, ref DBUtility.ClsPub.sExeReturnInfo); //保存后控制========================================= DataSet ds2 = oCn.RunProcReturn("Exec h_p_Gy_InspectInstruMent_AfterSaveCtrl " + oModel.HMakeEmp + ",'1'", "h_p_Gy_InspectInstruMent_AfterSaveCtrl"); if (ds2 == null) { oCn.RollBack(); sExeReturnInfo = "保存后判断失败!"; return false; } if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0") { oCn.RollBack(); sExeReturnInfo = "" + DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBackRemark"]); return false; } //========================================================= oCn.Commit(); return true; } catch (Exception e) { oCn.RollBack(); throw (e); } } //修改 public bool ModifyByID(Int64 sItemID, ref string sExeReturnInfo) { try { oCn.BeginTran(); //保存前控制========================================= DataSet ds = oCn.RunProcReturn("Exec h_p_Gy_InspectInstruMent_BeforeSaveCtrl " + oModel.HMakeEmp + ",'1'", "h_p_Gy_InspectInstruMent_BeforeSaveCtrl"); if (ds == null) { oCn.RollBack(); sExeReturnInfo = "保存前判断失败!"; return false; } if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0") { oCn.RollBack(); sExeReturnInfo = "保存失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); return false; } //========================================================= oCn.RunProc("Update " + MvarItemKey + " set " + " HNumber='" + oModel.HNumber + "'" + ",HName='" + oModel.HName + "'" + ",HShortNumber='" + oModel.HShortNumber + "'" + ",HHelpCode='" + oModel.HHelpCode + "'" + ",HModifyTime='" + DateTime.Now + "'" + ",HUSEORGID='" + oModel.HUSEORGID + "'" + ",HModifyEmp ='" + oModel.HMakeEmp + "'" + ",HUseFlag='" + oModel.HUseFlag + "'" + ",HCalibrationStatus='" + oModel.HCalibrationStatus + "'" + ",HCalibrationDate='" + oModel.HCalibrationDate + "'" + ",HValidDate='" + oModel.HValidDate + "'" + ",HExpiryDay='" + oModel.HExpiryDay + "'" + ",HStopflag=" + Convert.ToString(oModel.HStopflag ? 1 : 0) + ",HRemark= '" + oModel.HRemark + "' Where HItemID=" + sItemID, ref DBUtility.ClsPub.sExeReturnInfo); //修改子项目代码 oCn.RunProc("exec h_p_Gy_UpdateNumber '" + MvarItemKey + "','" + oModel.HNumber + ".','" + this.HOldNumber + ".'", ref DBUtility.ClsPub.sExeReturnInfo); //将上级 为非末级 oCn.RunProc("Update " + MvarItemKey + " set HEndflag=0 where HItemID=" + oModel.HParentID, ref DBUtility.ClsPub.sExeReturnInfo); // //保存后控制========================================= DataSet ds2 = oCn.RunProcReturn("Exec h_p_Gy_InspectInstruMent_AfterSaveCtrl " + oModel.HMakeEmp + ",'1'", "h_p_Gy_InspectInstruMent_AfterSaveCtrl"); if (ds2 == null) { oCn.RollBack(); sExeReturnInfo = "保存后判断失败!"; return false; } if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0") { oCn.RollBack(); sExeReturnInfo = "" + DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBackRemark"]); return false; } //========================================================= oCn.Commit(); return true; } catch (Exception e) { oCn.RollBack(); throw (e); } } //根据代码判断信息 public override bool HavParentCode(string sCode, Int64 sItemID) { DataSet DS; try { DS = oCn.RunProcReturn("Select * from " + MvarItemKey + " Where HStopflag=0 and HNumber='" + sCode + "' and HItemID<>" + sItemID, MvarItemKey, ref Pub_Class.ClsPub.sExeReturnInfo); if (DS.Tables[0].Rows.Count == 0) return false; else { oModel.HItemID = Convert.ToInt64(DS.Tables[0].Rows[0]["HItemID"]); return true; } } catch (Exception e) { throw (e); } } //构造函数 public ClsGy_InspectInstruMent_Ctl() { MvarItemKey = "Gy_InspectInstruMent"; MvarReportTitle = "检验仪器设置"; oModel = new Model.ClsGy_InspectInstruMent_Model(); } } }