| using System; | 
| using System.Collections.Generic; | 
| using System.Text; | 
| using System.Data; | 
|   | 
| namespace WebAPI.DLL | 
| { | 
|     public class ClsGy_PostSkill_Ctl : DBUtility.ClsGy_Base_Ctl    | 
|     { | 
|         SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); | 
|         //原代码 用于 替换子项目 | 
|         public string HOldNumber; | 
|         public Model.ClsGy_PostSkill_Model oModel = new Model.ClsGy_PostSkill_Model(); | 
|         //新增 | 
|         public bool AddNew(ref string sReturn) | 
|         { | 
|             // | 
|             try | 
|             { | 
|                 oCn.BeginTran(); | 
|   | 
|                 //保存前控制===================================================================== | 
|                 DataSet ds = oCn.RunProcReturn("Exec h_p_Gy_PostSkill_BeforeSaveCtrl " + oModel.HMakeEmp + ",1 ", "h_p_Gy_PostSkill_BeforeSaveCtrl"); | 
|                 if (ds == null) | 
|                 { | 
|                     sReturn = "保存前判断失败!"; | 
|                     return false; | 
|                 } | 
|                 if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0") | 
|                 { | 
|                     sReturn = "保存失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]); | 
|                     return false; | 
|                 } | 
|                 //===================================================================================== | 
|   | 
|   | 
|                 oCn.RunProc("Insert into " + MvarItemKey + " " + | 
|                      " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + | 
|                      ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HCREATEORGID,HPostID,HProcID) " + | 
|                      " 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 + "',getdate(),'" + oModel.HUSEORGID + "','" + oModel.HUseFlag + "','" + oModel.HMakeEmp + "','" + oModel.HCREATEORGID + "','" + oModel.HPostID + "','" + oModel.HProcID + "')", 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_PostSkill_AfterSaveCtrl " + oModel.HMakeEmp + ",1", "h_p_Gy_PostSkill_AfterSaveCtrl"); | 
|                 if (ds2 == null) | 
|                 { | 
|                     sReturn = "保存后控制判断失败!"; | 
|                     oCn.RollBack(); | 
|                     return false; | 
|                 } | 
|                 if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0") | 
|                 { | 
|                     sReturn = "保存失败2!" + DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HRemark"]); | 
|                     oCn.RollBack(); | 
|                     return false; | 
|                 } | 
|                 //==================================================================================== | 
|                | 
|                 oCn.Commit(); | 
|                 return true; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 oCn.RollBack(); | 
|                 throw (e); | 
|             } | 
|         } | 
|   | 
|         //修改 | 
|         public  bool ModifyByID(Int64 sItemID, ref string sReturn) | 
|         { | 
|             try | 
|             { | 
|                  | 
|                 oCn.BeginTran(); | 
|   | 
|                 //保存前控制===================================================================== | 
|                 DataSet ds = oCn.RunProcReturn("Exec h_p_Gy_PostSkill_BeforeSaveCtrl " + oModel.HMakeEmp + ",2 ", "h_p_Gy_PostSkill_BeforeSaveCtrl"); | 
|                 if (ds == null) | 
|                 { | 
|                     sReturn = "保存前判断失败!"; | 
|                     return false; | 
|                 } | 
|                 if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0") | 
|                 { | 
|                     sReturn = "保存失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]); | 
|                     return false; | 
|                 } | 
|                 //===================================================================================== | 
|   | 
|                 oCn.RunProc("Update " + MvarItemKey + " set " + | 
|                        " HNumber='" + oModel.HNumber + "'" + | 
|                        ",HName='" + oModel.HName + "'" + | 
|                        ",HShortNumber='" + oModel.HShortNumber + "'" + | 
|                        ",HHelpCode='" + oModel.HHelpCode + "'" + | 
|                        ",HModifyTime=getdate()" + | 
|                        ",HUSEORGID='" + oModel.HUSEORGID + "'" + | 
|                        ",HCREATEORGID='" + oModel.HCREATEORGID + "'" + | 
|                        ",HModifyEmp ='" + oModel.HMakeEmp + "'" + | 
|                        ",HPostID ='" + oModel.HPostID + "'" + | 
|                        ",HProcID ='" + oModel.HProcID + "'" + | 
|                        ",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_PostSkill_AfterSaveCtrl " + oModel.HMakeEmp + ",2", "h_p_Gy_PostSkill_AfterSaveCtrl"); | 
|                 if (ds2 == null) | 
|                 { | 
|                     sReturn = "保存后控制判断失败!"; | 
|                     oCn.RollBack(); | 
|                     return false; | 
|                 } | 
|                 if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0") | 
|                 { | 
|                     sReturn = "保存失败2!" + DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HRemark"]); | 
|                     oCn.RollBack(); | 
|                     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_PostSkill_Ctl() | 
|         { | 
|             MvarItemKey = "Gy_PostSkill"; | 
|             MvarReportTitle = "岗位技能设置"; | 
|             oModel = new Model.ClsGy_PostSkill_Model(); | 
|         } | 
|   | 
|      | 
|   | 
|     } | 
| } |