using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using System.Data;
|
|
namespace DAL
|
{
|
public class ClsGy_MatePriceSup_Ctl : DBUtility.ClsGy_Base_Ctl
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
//原代码 用于 替换子项目
|
public string HOldNumber;
|
public List<Model.ClsGy_MatePriceSup_Model> DetailColl = new List<Model.ClsGy_MatePriceSup_Model>();
|
|
|
|
//反审核
|
public bool AbandonCheck(Int64 lngBillKey, ref string sReturn)
|
{
|
try
|
{
|
oCn.RunProc(" Update Gy_MatePriceSup set HChecker='',HCheckDate=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_MatePriceSup 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();
|
//插入子表
|
foreach (Model.ClsGy_MatePriceSup_Model oSub in DetailColl)
|
{
|
oCn.RunProc("Insert into Gy_MatePriceSup " +
|
" (HInterID,HEntryID,HMaterID,HRelationID" +
|
",HUnitID,HBeginQty,HEndQty,HCurID,HType" +
|
",HPrice,HBeginDate,HEndDate,HUsed,HRemark,HMaker,HMakeDate)" +
|
" values(" + oSub.HInterID.ToString() + "," + oSub.HEntryID.ToString() + "," + oSub.HMaterID.ToString() + "," + oSub.HRelationID.ToString() +
|
"," + oSub.HUnitID.ToString() + "," + oSub.HBeginQty.ToString() + "," + oSub.HEndQty.ToString() + "," + oSub.HCurID.ToString() + ",'" + oSub.HType + "'" +
|
"," + oSub.HPrice.ToString() + ",'" + oSub.HBeginDate + "','" + oSub.HEndDate + "'," + Convert.ToString(oSub.HUsed ? 1 : 0) + ",'" + oSub.HRemark + "','" + oSub.HMaker + "','" + oSub.HMakeDate + "') ");
|
}
|
oCn.Commit();
|
return true;
|
}
|
catch (Exception e)
|
{
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//修改
|
public override bool ModifyByID(Int64 sItemID)
|
{
|
try
|
{
|
oCn.BeginTran();
|
DeleteByID(sItemID); //删除记录
|
//插入表
|
foreach (Model.ClsGy_MatePriceSup_Model oSub in DetailColl)
|
{
|
oCn.RunProc("Insert into Gy_MatePriceSup " +
|
" (HInterID,HEntryID,HMaterID,HRelationID" +
|
",HUnitID,HBeginQty,HEndQty,HCurID,HType" +
|
",HPrice,HBeginDate,HEndDate,HUsed,HRemark,HMaker,HMakeDate)" +
|
" values(" + oSub.HInterID.ToString() + "," + oSub.HEntryID.ToString() + "," + oSub.HMaterID.ToString() + "," + oSub.HRelationID.ToString() +
|
"," + oSub.HUnitID.ToString() + "," + oSub.HBeginQty.ToString() + "," + oSub.HEndQty.ToString() + "," + oSub.HCurID.ToString() + ",'" + oSub.HType + "'" +
|
"," + oSub.HPrice.ToString() + ",'" + oSub.HBeginDate + "','" + oSub.HEndDate + "'," + Convert.ToString(oSub.HUsed ? 1 : 0) + ",'" + oSub.HRemark + "','" + oSub.HMaker + "','" + oSub.HMakeDate + "') ");
|
}
|
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_MatePriceSup Where HitemID=" + lngBillKey.ToString(), "Gy_MatePriceSup");
|
DetailColl.Clear();//清空
|
for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
|
{
|
Model.ClsGy_MatePriceSup_Model oSub = new Model.ClsGy_MatePriceSup_Model();
|
oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HInterID"].ToString());
|
oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HEntryID"].ToString());
|
oSub.HMaterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HMaterID"].ToString());
|
oSub.HRelationID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HRelationID"].ToString());
|
oSub.HRemark = DsSub.Tables[0].Rows[i]["HRemark"].ToString().Trim();
|
oSub.HBeginQty = DBUtility.ClsPub.isSingle(DsSub.Tables[0].Rows[i]["HBeginQty"].ToString());
|
oSub.HEndQty = DBUtility.ClsPub.isSingle(DsSub.Tables[0].Rows[i]["HEndQty"].ToString());
|
oSub.HUnitID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HUnitID"].ToString());
|
oSub.HPrice = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HPrice"].ToString());
|
oSub.HCurID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HCurID"].ToString());
|
oSub.HType = DsSub.Tables[0].Rows[i]["HType"].ToString();
|
oSub.HMaker = DsSub.Tables[0].Rows[i]["HMaker"].ToString();
|
oSub.HMakeDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[i]["HMakeDate"]);
|
oSub.HBeginDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[i]["HBeginDate"]);
|
oSub.HEndDate =DBUtility.ClsPub.isDate( DsSub.Tables[0].Rows[i]["HEndDate"]);
|
oSub.HChecker = DsSub.Tables[0].Rows[i]["HChecker"].ToString().Trim();
|
oSub.HCheckDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[i]["HCheckDate"]);
|
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_MatePriceSup_Ctl()
|
{
|
MvarItemKey = "Gy_MatePriceSup";
|
MvarReportTitle = "采购价格资料设置";
|
}
|
}
|
}
|