using System; 
 | 
using System.Collections.Generic; 
 | 
using System.Text; 
 | 
using System.Data; 
 | 
  
 | 
namespace WebAPI.DLL 
 | 
{ 
 | 
    public class ClsGy_InspectValue_Ctl : DBUtility.ClsGy_Base_Ctl    
 | 
    { 
 | 
        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); 
 | 
        //原代码 用于 替换子项目 
 | 
        public string HOldNumber; 
 | 
        public Model.ClsGy_InspectValue_Model oModel = new Model.ClsGy_InspectValue_Model(); 
 | 
        //新增 
 | 
        public  bool AddNew(ref string sExeReturnInfo) 
 | 
        { 
 | 
            // 
 | 
            try 
 | 
            { 
 | 
                oCn.BeginTran(); 
 | 
  
 | 
                //保存前控制========================================= 
 | 
                DataSet ds = oCn.RunProcReturn("Exec h_p_Gy_InspectValue_BeforeSaveCtrl " + oModel.HMakeEmp + ",'1'", "h_p_Gy_InspectValue_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) " + 
 | 
                    " 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 + "')", 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_InspectValue_AfterSaveCtrl " + oModel.HMakeEmp + ",'1'", "h_p_Gy_InspectValue_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_InspectValue_BeforeSaveCtrl " + oModel.HMakeEmp + ",'1'", "h_p_Gy_InspectValue_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 + "'" + 
 | 
                    ",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_InspectValue_AfterSaveCtrl " + oModel.HMakeEmp + ",'1'", "h_p_Gy_InspectValue_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_InspectValue_Ctl() 
 | 
        { 
 | 
            MvarItemKey = "Gy_InspectValue"; 
 | 
            MvarReportTitle = "检测值设置"; 
 | 
            oModel = new Model.ClsGy_InspectValue_Model(); 
 | 
        } 
 | 
  
 | 
     
 | 
  
 | 
    } 
 | 
} 
 |