using System; using System.Collections.Generic; using System.Text; using System.Data; namespace DAL { public class ClsGy_TechParamByProc_Ctl : DBUtility.ClsGy_Base_Ctl { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); //原代码 用于 替换子项目 public string HOldNumber; public List DetailColl = new List(); public Model.ClsGy_TechParamByProc_Model omodel = new Model.ClsGy_TechParamByProc_Model(); public bool DeleteByID1(Int64 sItemID) { try { oCn.BeginTran(); //删除表 foreach (Model.ClsGy_TechParamByProc_Model oSub in DetailColl) { oCn.RunProc("delete from Gy_TechParamByProc where HEntryID=" + sItemID.ToString()); } oCn.Commit(); return true; } catch (Exception e) { oCn.RollBack(); throw (e); } } //反审核 public bool AbandonCheck(Int64 lngBillKey, ref string sReturn) { try { oCn.RunProc(" Update Gy_TechParamByProc set HChecker='',HCheckDate=null Where HEntryID=" + lngBillKey.ToString()); sReturn = ""; return true; } catch (Exception e) { sReturn = e.Message; return false; } } //审核 public bool CheckBill(Int64 lngBillKey, ref string sReturn) { try { oCn.RunProc(" Update Gy_TechParamByProc set HStopflag=0,HChecker='" + DBUtility.ClsPub.CurUserName + "',HCheckDate='" + DBUtility.ClsPub.GetServerDate(-1) + "' Where HEntryID=" + lngBillKey.ToString()); //将其他 工价设置为 停用 //oCn.RunProc(" exec h_p_Gy_TechParamByProcStopflag " + lngBillKey.ToString()); // sReturn = ""; return true; } catch (Exception e) { sReturn = e.Message; return false; } } //新增 public override bool AddNew() { try { oCn.BeginTran(); //插入子表 foreach (Model.ClsGy_TechParamByProc_Model oSub in DetailColl) { oCn.RunProc("Insert into Gy_TechParamByProc " + " (HTechParamID,HProcID,HTechParamUnitID" + ",HBeginDate,HEndDate,HDeptID" + ",HStd,HStopflag,HRemark,HMaker,HMakeDate)" + " values(" + oSub.HTechParamID.ToString() + "," + oSub.HProcID.ToString() + "," + oSub.HTechParamUnitID.ToString() + ",'" + oSub.HBeginDate + "','" + oSub.HEndDate + "'," + oSub.HDeptID.ToString() + "," + oSub.HStd.ToString() + "," + Convert.ToString(oSub.HStopflag ? 1 : 0) + ",'" + oSub.HRemark + "','" + oSub.HMaker + "',getdate()) "); } oCn.Commit(); return true; } catch (Exception e) { oCn.RollBack(); throw (e); } } //修改 public override bool ModifyByID(Int64 sItemID) { try { oCn.BeginTran(); foreach (Model.ClsGy_TechParamByProc_Model oSub in DetailColl) { oCn.RunProc("delete from Gy_TechParamByProc where HEntryID=" + sItemID.ToString()); } //删除记录 //插入表 foreach (Model.ClsGy_TechParamByProc_Model oSub in DetailColl) { oCn.RunProc("Insert into Gy_TechParamByProc " + " (HTechParamID,HProcID,HTechParamUnitID" + ",HBeginDate,HEndDate,HDeptID" + ",HStd,HStopflag,HRemark,HMaker,HMakeDate)" + " values(" + oSub.HTechParamID.ToString() + "," + oSub.HProcID.ToString() + "," + oSub.HTechParamUnitID.ToString() + ",'" + oSub.HBeginDate + "','" + oSub.HEndDate + "'," + oSub.HDeptID.ToString() + "," + oSub.HStd.ToString() + "," + Convert.ToString(oSub.HStopflag ? 1 : 0) + ",'" + oSub.HRemark + "','" + oSub.HMaker + "',getdate()) "); } oCn.Commit(); return true; } catch (Exception e) { oCn.RollBack(); throw (e); } } //显示单据 public bool ShowBill(Int64 lngBillKey, ref string sReturn) { try { //查询主表 DataSet DsSub = new DataSet(); DsSub = oCn.RunProcReturn("Select * from Gy_TechParamByProc Where HEntryID=" + lngBillKey.ToString(), "Gy_TechParamByProc"); DetailColl.Clear();//清空 for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++) { Model.ClsGy_TechParamByProc_Model oSub = new Model.ClsGy_TechParamByProc_Model(); oSub.HTechParamID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HTechParamID"]); oSub.HProcID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HProcID"]); oSub.HTechParamUnitID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HTechParamUnitID"]); oSub.HDeptID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HDeptID"]); oSub.HBeginDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[i]["HBeginDate"]); oSub.HEndDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[i]["HEndDate"]); oSub.HRemark = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HRemark"]); oSub.HStd = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HStd"]); oSub.HMaker = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HMaker"]); oSub.HMakeDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[i]["HMakeDate"]); oSub.HChecker = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HChecker"]); oSub.HCheckDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[i]["HCheckDate"]); oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HEntryID"]); oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HInterID"]); DetailColl.Add(oSub); } sReturn = "显示单据成功!"; return true; } catch (Exception e) { sReturn = e.Message; return false; } } //批改单据 //public bool BatchModifyBill(Int64 lngBillKey, double sPrice, ref string sReturn) //{ // try // { // oCn.BeginTran(); // oCn.RunProc(" Update Gy_TechParamByProc set HPrice=" + sPrice.ToString() + " Where HItemID=" + lngBillKey.ToString()); // sReturn = "修改单据成功!"; // oCn.Commit(); // return true; // } // catch (Exception e) // { // sReturn = e.Message; // oCn.RollBack(); // return false; // } //} //根据物料和工序返回工价 //b 单价为ture,定额为false //public double LoadProcPrice(Int64 sMaterID, Int64 sProcID, Int64 sSourceID, bool b) //{ // double sPrice = 0; // try // { // //查询主表 // DataSet DsSub = new DataSet(); // DsSub = oCn.RunProcReturn("Select top 1 * from Gy_TechParamByProc Where HStopflag=0 and HEndDate>=convert(varchar(10),Getdate(),120) and HChecker<>'' and HMaterID=" + sMaterID.ToString() + " and HProcID=" + sProcID.ToString() + " and HSourceID=" + sSourceID.ToString(), "Gy_TechParamByProc"); // if (DsSub == null) // { // return 0; // } // if (b) // { // sPrice = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[0]["HPrice"]); // } // else // { // sPrice = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[0]["HFixPrice"]); // } // return sPrice; // } // catch (Exception e) // { // return 0; // } //} //构造函数 public ClsGy_TechParamByProc_Ctl() { MvarItemKey = "Gy_TechParamByProc"; MvarReportTitle = "工艺参数对应表资料"; } } }