| using System; | 
| using System.Collections.Generic; | 
| using System.Text; | 
| using System.Data; | 
|   | 
| namespace WebAPI.DLL | 
| { | 
|     public class ClsGy_Material_Ctl : DBUtility.ClsGy_Base_Ctl | 
|     { | 
|         SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); | 
|         //原代码 用于 替换子项目 | 
|         public string HOldNumber; | 
|         public Models.ClsGy_Material_Model oModel = new Models.ClsGy_Material_Model(); | 
|         //新增 | 
|         public override bool AddNew() | 
|         { | 
|             try | 
|             { | 
|                 oCn.BeginTran(); | 
|                 oCn.RunProc("Insert into Gy_Material (" + | 
|                     "HNumber,HName,HHelpCode,HShortNumber,HParentID" + | 
|                     ",HLevel,HEndFlag,HStopflag,HRemark" + | 
|                     ",HModel,HUnitID,HMaterClsID,HMaterTypeID,HUnitGroupID" + | 
|                     ",HWhID,HRoutingID,HBomID,HSecUnitID,HSecUnitRate" + | 
|                     ",HHighStock,HLowStock,HSafeStock,HOrderPrice,HSalePrice" + | 
|                     ",HKeepDays,HPlanPrice,HstdPrice,HQtyMin,HQtyMax" + | 
|                     ",HSubjoin,HSubjoin2,HColor,HVersion,HEngName,HEngModel,HPropertyTypeID,HSPGroupID,HSPID,HMinPickQty) " + | 
|                     " 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 + "'" + | 
|                     ",'" + oModel.HModel + "'," + oModel.HUnitID.ToString() + "," + oModel.HMaterClsID.ToString() + "," + oModel.HMaterTypeID.ToString() + "," + oModel.HUnitGroupID.ToString() + | 
|                     ", " + oModel.HWhID.ToString() + "," + oModel.HRoutingID.ToString() + "," + oModel.HBomID.ToString() + "," + oModel.HSecUnitID.ToString() + "," + oModel.HSecUnitRate.ToString() + | 
|                     ", " + oModel.HHighStock.ToString() + "," + oModel.HLowStock.ToString() + "," + oModel.HSafeStock.ToString() + "," + oModel.HOrderPrice.ToString() + ",'" + oModel.HSalePrice + "'" + | 
|                     ", " + oModel.HKeepDays.ToString() + "," + oModel.HPlanPrice.ToString() + "," + oModel.HstdPrice.ToString() + "," + oModel.HQtyMin.ToString() + "," + oModel.HQtyMax.ToString() + | 
|                     ",'" + oModel.HSubjoin + "','" + oModel.HSubjoin2 + "','" + oModel.HColor + "','" + oModel.HVersion + "','" + oModel.HEngName + "','" + oModel.HEngModel + "'," + oModel.HPropertyTypeID.ToString() + "," + oModel.HSPGroupID.ToString() + "," + oModel.HSPID.ToString() + "," + oModel.HMinPickQty.ToString() + ")", ref DBUtility.ClsPub.sExeReturnInfo); | 
|                 //修改上级为非末级代码 | 
|                 oCn.RunProc("Update " + MvarItemKey + " set HEndflag=0 where HItemID=" + oModel.HParentID, ref DBUtility.ClsPub.sExeReturnInfo); | 
|                 oCn.Commit(); | 
|                 return true; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 oCn.RollBack(); | 
|                 throw (e); | 
|             } | 
|         } | 
|   | 
|         //修改 | 
|         public override bool ModifyByID(Int64 sItemID) | 
|         { | 
|             try | 
|             { | 
|                 oCn.BeginTran(); | 
|                 oCn.RunProc("Update " + MvarItemKey + " set " + | 
|                     " HNumber='" + oModel.HNumber + "'" + | 
|                     ",HName='" + oModel.HName + "'" + | 
|                     ",HShortNumber='" + oModel.HShortNumber + "'" + | 
|                     ",HParentID=" + oModel.HParentID.ToString() + | 
|                     ",HLevel=" + oModel.HLevel.ToString() + | 
|                     ",HEndflag=" + Convert.ToString(oModel.HEndFlag ? 1 : 0) + | 
|                     ",HStopflag=" + Convert.ToString(oModel.HStopflag ? 1 : 0) + | 
|                     ",HRemark= '" + oModel.HRemark + "'" + | 
|                     ",HHelpCode='" + oModel.HHelpCode + "'" + | 
|                     ",HModel='" + oModel.HModel + "'" + | 
|                     ",HUnitID=" + oModel.HUnitID.ToString() + | 
|                     ",HMaterClsID=" + oModel.HMaterClsID.ToString() + | 
|                     ",HMaterTypeID=" + oModel.HMaterTypeID.ToString() + | 
|                     ",HUnitGroupID=" + oModel.HUnitGroupID.ToString() + | 
|                     ",HWhID=" + oModel.HWhID.ToString() + | 
|                     ",HRoutingID=" + oModel.HRoutingID.ToString() + | 
|                     ",HBomID=" + oModel.HBomID.ToString() + | 
|                     ",HSecUnitID=" + oModel.HSecUnitID.ToString() + | 
|                     ",HSecUnitRate=" + oModel.HSecUnitRate.ToString() + | 
|                     ",HHighStock=" + oModel.HHighStock.ToString() + | 
|                     ",HLowStock=" + oModel.HLowStock.ToString() + | 
|                     ",HSafeStock=" + oModel.HSafeStock.ToString() + | 
|                     ",HOrderPrice=" + oModel.HOrderPrice.ToString() + | 
|                     ",HSalePrice=" + oModel.HSalePrice.ToString() + | 
|                     ",HKeepDays=" + oModel.HKeepDays.ToString() + | 
|                     ",HPlanPrice=" + oModel.HPlanPrice.ToString() + | 
|                     ",HstdPrice=" + oModel.HstdPrice.ToString() + | 
|                     ",HQtyMin=" + oModel.HQtyMin.ToString() + | 
|                     ",HQtyMax=" + oModel.HQtyMax.ToString() + | 
|                     ",HVersion='" + oModel.HVersion + "'" + | 
|                     ",HEngName='" + oModel.HEngName + "'" + | 
|                     ",HEngModel='" + oModel.HEngModel + "'" + | 
|                     ",HSubjoin='" + oModel.HSubjoin + "'" + | 
|                     ",HSubjoin2='" + oModel.HSubjoin2 + "'" + | 
|                     ",HColor='" + oModel.HColor + "'" + | 
|                     ",HSPGroupID=" + oModel.HSPGroupID.ToString() + | 
|                     ",HSPID=" + oModel.HSPID.ToString() + | 
|                     ",HMinPickQty=" + oModel.HMinPickQty.ToString() + | 
|                     ",HPropertyTypeID=" + oModel.HPropertyTypeID.ToString() + "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); | 
|                 // | 
|                 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_Material_Ctl() | 
|         { | 
|             MvarItemKey = "Gy_Material"; | 
|             MvarReportTitle = "物料设置"; | 
|             oModel = new Models.ClsGy_Material_Model(); | 
|         } | 
|     } | 
| } |