using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using System.Data;
|
|
namespace DAL
|
{
|
public class ClsXt_UserRelationSupplier_Ctl : DBUtility.ClsGy_Base_Ctl
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
//原代码 用于 替换子项目
|
public string HOldNumber;
|
public List<Model.ClsXt_UserRelationSupplier_Model> DetailColl = new List<Model.ClsXt_UserRelationSupplier_Model>();
|
|
|
|
//反审核
|
public bool AbandonCheck(Int64 lngBillKey, ref string sReturn)
|
{
|
try
|
{
|
oCn.RunProc(" Update Xt_UserRelationSupplier 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 Xt_UserRelationSupplier set HStopflag=0,HChecker='" + DBUtility.ClsPub.CurUserName + "',HCheckDate='" + DBUtility.ClsPub.GetServerDate(-1) + "' Where HItemID=" + lngBillKey.ToString());
|
//将其他 工价设置为 停用
|
oCn.RunProc(" exec h_p_Xt_UserRelationSupplierStopflag " + lngBillKey.ToString());
|
//
|
sReturn = "";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
return false;
|
}
|
}
|
|
|
//新增
|
public override bool AddNew()
|
{
|
|
try
|
{
|
oCn.BeginTran();
|
//插入子表
|
foreach (Model.ClsXt_UserRelationSupplier_Model oSub in DetailColl)
|
{
|
oCn.RunProc("Insert into Xt_UserRelationSupplier " +
|
" (HMaterID,HProcID" +
|
",HBeginDate,HEndDate,HCostFlag,HDeptID" +
|
",HPrice,HStopflag,HRemark,HMaker,HMakeDate,HUserID,HSupID)" +
|
" values(" + oSub.HMaterID.ToString() + "," + oSub.HProcID.ToString() +
|
",'" + oSub.HBeginDate.ToShortDateString() + "','" + oSub.HEndDate.ToShortDateString() + "'," +Convert.ToString(oSub.HCostFlag ? 1 : 0)+ "," + oSub.HDeptID.ToString() +
|
"," + oSub.HPrice.ToString() + "," + Convert.ToString(oSub.HStopflag ? 1 : 0) + ",'" + oSub.HRemark + "','" + oSub.HMaker + "','" + oSub.HMakeDate + "'," + oSub.HUserID.ToString() + "," + oSub.HSupID.ToString() + ") ");
|
}
|
oCn.Commit();
|
return true;
|
}
|
catch (Exception e)
|
{
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//修改
|
public override bool ModifyByID(Int64 sItemID)
|
{
|
try
|
{
|
if (DetailColl.Count == 0) return false;
|
oCn.BeginTran();
|
DeleteByID(sItemID); //删除记录
|
//插入表
|
foreach (Model.ClsXt_UserRelationSupplier_Model oSub in DetailColl)
|
{
|
oCn.RunProc("Insert into Xt_UserRelationSupplier " +
|
" (HMaterID,HProcID" +
|
",HBeginDate,HEndDate,HCostFlag,HDeptID" +
|
",HPrice,HStopflag,HRemark,HMaker,HMakeDate,HUserID,HSupID)" +
|
" values(" + oSub.HMaterID.ToString() + "," + oSub.HProcID.ToString() +
|
",'" + oSub.HBeginDate.ToShortDateString() + "','" + oSub.HEndDate.ToShortDateString() + "'," + Convert.ToString(oSub.HCostFlag ? 1 : 0) + "," + oSub.HDeptID.ToString() +
|
"," + oSub.HPrice.ToString() + "," + Convert.ToString(oSub.HStopflag ? 1 : 0) + ",'" + oSub.HRemark + "','" + oSub.HMaker + "','" + oSub.HMakeDate + "'," + oSub.HUserID.ToString() + "," + oSub.HSupID.ToString() + ") ");
|
}
|
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 Xt_UserRelationSupplier Where HitemID=" + lngBillKey.ToString(), "Xt_UserRelationSupplier");
|
DetailColl.Clear();//清空
|
for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
|
{
|
Model.ClsXt_UserRelationSupplier_Model oSub = new Model.ClsXt_UserRelationSupplier_Model();
|
oSub.HMaterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HMaterID"]);
|
oSub.HProcID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HProcID"]);
|
oSub.HDeptID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HDeptID"]);
|
oSub.HCostFlag = (bool)DsSub.Tables[0].Rows[i]["HCostFlag"];
|
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.HPrice = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HPrice"]);
|
oSub.HMaker = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HMaker"]);
|
oSub.HMakeDate = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HMakeDate"]);
|
oSub.HChecker = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HChecker"]);
|
oSub.HCheckDate = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HCheckDate"]);
|
oSub.HUserID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HUserID"]);
|
oSub.HSupID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSupID"]);
|
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 Xt_UserRelationSupplier 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 LoadProcPrice(Int64 sMaterID, Int64 sProcID)
|
{
|
double sPrice = 0;
|
try
|
{
|
//查询主表
|
DataSet DsSub = new DataSet();
|
DsSub = oCn.RunProcReturn("Select * from Xt_UserRelationSupplier Where HStopflag=0 and HEndDate>=convert(varchar(10),Getdate(),120) and HChecker<>'' and HMaterID=" + sMaterID.ToString() + " and HProcID=" + sProcID.ToString(), "Xt_UserRelationSupplier");
|
if (DsSub == null)
|
{
|
return 0;
|
}
|
for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
|
{
|
sPrice = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HPrice"]);
|
}
|
return sPrice;
|
}
|
catch (Exception e)
|
{
|
return 0;
|
}
|
}
|
|
//构造函数
|
public ClsXt_UserRelationSupplier_Ctl()
|
{
|
MvarItemKey = "Xt_UserRelationSupplier";
|
MvarReportTitle = "金蝶用户供应商";
|
}
|
}
|
}
|