using System; using System.Collections.Generic; using System.Text; using System.Data; namespace DAL { public class ClsGy_MatePrice_Ctl : DBUtility.ClsGy_Base_Ctl { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); //原代码 用于 替换子项目 public string HOldNumber; public List DetailColl = new List(); public Model.ClsGy_MatePrice_Model oModel = new Model.ClsGy_MatePrice_Model(); //反审核 public bool AbandonCheck(Int64 lngBillKey, ref string sReturn) { try { oCn.RunProc(" Update Gy_MatePrice set HCheckEmp='',HCheckTime=null Where HItemID=" + 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_MaterPrice set HUsed=0,HChecker='" + DBUtility.ClsPub.CurUserName + "',HCheckDate='" + DBUtility.ClsPub.GetServerDate(-1) + "' Where HItemID=" + lngBillKey.ToString()); //将其他 工价设置为 停用 //oCn.RunProc(" exec h_p_Gy_MatePriceSupStopflag " + lngBillKey.ToString()); // sReturn = ""; return true; } catch (Exception e) { sReturn = e.Message; return false; } } //新增 public override bool AddNew() { try { oCn.BeginTran(); oCn.RunProc("Insert into " + MvarItemKey + " (HSupID,HCusID,HMaterID,HWHID,HPrice" + ",HStopflag,HRemark,HUseFlag,HMakeEmp,HMakeTime" + ",HUSEORGID,HCREATEORGID) " + " values('" + oModel.HSupID + "', '" + oModel.HCusID + "', " + oModel.HMaterID.ToString() + ", " + oModel.HWHID.ToString() + ", " + oModel.HPrice.ToString() + ", " + Convert.ToString(oModel.HStopflag ? 1 : 0) + ", '" + oModel.HRemark + "', " + oModel.HUseFlag.ToString() + ", '" + oModel.HMakeEmp.ToString() + "', getdate()" + ", '" + oModel.HUSEORGID + "', '" + oModel.HCREATEORGID + "')"); // 修改结束 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 " + "HSupID=" + oModel.HSupID.ToString() + ",HCusID=" + oModel.HCusID.ToString() + ",HMaterID=" + oModel.HMaterID.ToString() + ",HWHID=" + oModel.HWHID.ToString() + ",HPrice=" + oModel.HPrice.ToString() + ",HStopflag=" + Convert.ToString(oModel.HStopflag ? 1 : 0) + ",HRemark='" + oModel.HRemark + "'" + ",HUseFlag='" + oModel.HUseFlag.ToString() + "'" + ",HCheckEmp='" + oModel.HCheckEmp.ToString() + "'" + ",HCheckTime='" + oModel.HCheckTime + "'" + ",HModifyEmp='" + oModel.HModifyEmp + "'" + ",HModifyTime=GETDATE()" + ",HStopEmp='" + oModel.HStopEmp + "'" + ",HStopTime='" + oModel.HStopTime + "'" + ",HUSEORGID=" + oModel.HUSEORGID.ToString() + ",HCREATEORGID=" + oModel.HCREATEORGID.ToString() + " Where HItemID=" + sItemID, ref DBUtility.ClsPub.sExeReturnInfo); 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_MaterPrice Where HitemID=" + lngBillKey.ToString(), "Gy_MaterPrice"); DetailColl.Clear();//清空 for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++) { Model.ClsGy_MatePrice_Model oSub = new Model.ClsGy_MatePrice_Model(); oSub.HMaterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HMaterID"].ToString()); oSub.HRemark = DsSub.Tables[0].Rows[i]["HRemark"].ToString().Trim(); oSub.HWHID = DBUtility.ClsPub.isInt(DsSub.Tables[0].Rows[i]["HWHID"].ToString()); oSub.HSupID = DBUtility.ClsPub.isInt(DsSub.Tables[0].Rows[i]["HSupID"].ToString()); oSub.HPrice = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HPrice"].ToString()); oSub.HCusID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HCusID"].ToString()); oSub.HStopflag = DBUtility.ClsPub.isBool(DsSub.Tables[0].Rows[i]["HStopflag"].ToString()); oSub.HUseFlag = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HUseFlag"].ToString()); oSub.HMakeEmp = DsSub.Tables[0].Rows[i]["HMakeEmp"].ToString(); oSub.HCheckEmp = DsSub.Tables[0].Rows[i]["HCheckEmp"].ToString(); oSub.HStopEmp = DsSub.Tables[0].Rows[i]["HStopEmp"].ToString(); oSub.HModifyEmp = DsSub.Tables[0].Rows[i]["HModifyEmp"].ToString(); oSub.HMakeTime = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HMakeTime"].ToString()); oSub.HCheckTime = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HCheckTime"].ToString()); oSub.HModifyTime = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HModifyTime"].ToString()); oSub.HStopTime = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HStopTime"].ToString()); 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_MatePriceSup set HPrice=" + sPrice.ToString() + " Where HItemID=" + lngBillKey.ToString()); sReturn = "修改单据成功!"; oCn.Commit(); return true; } catch (Exception e) { sReturn = e.Message; oCn.RollBack(); return false; } } //得到采购价格资料 public double GetMatePriceBySup(long HMaterID, long HSupID) { try { DataSet oDs = new DataSet(); // oDs = oCn.RunProcReturn("exec h_p_Gy_GetMatePrice_Sup " + HMaterID.ToString() + "," + HSupID.ToString(), "gy_czygl"); double HPrice = DBUtility.ClsPub.isDoule(oDs.Tables[0].Rows[0]["单价"]); // return HPrice; } catch (Exception e) { return 0; } } //构造函数 public ClsGy_MatePrice_Ctl() { MvarItemKey = "dbo.Gy_MaterPrice"; MvarReportTitle = "样品资料设置"; oModel = new Model.ClsGy_MatePrice_Model(); } } }