using DBUtility;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Linq;
|
using System.Text;
|
|
namespace DAL
|
{
|
public class ClsGy_MateMould_Ctl : DBUtility.ClsGy_Base_Ctl
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
//原代码 用于 替换子项目
|
public string HOldNumber;
|
public List<Model.ClsGy_MateMould_Model> DetailColl = new List<Model.ClsGy_MateMould_Model>();
|
|
//反审核
|
public bool AbandonCheck(Int64 lngBillKey, ref string sReturn)
|
{
|
try
|
{
|
oCn.RunProc(" Update Gy_MateMouldInfo 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_MateMouldInfo set HUsed=0,HChecker='" + DBUtility.ClsPub.CurUserName + "',HCheckDate='" + DBUtility.ClsPub.GetServerDate(-1) + "' Where HItemID=" + lngBillKey.ToString());
|
//将其他 工价设置为 停用
|
oCn.RunProc(" exec h_p_Gy_MateMouldStopflag " + lngBillKey.ToString());
|
//
|
sReturn = "";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
return false;
|
}
|
}
|
|
|
//新增
|
public override bool AddNew()
|
{
|
|
try
|
{
|
oCn.BeginTran();
|
|
|
//插入表
|
foreach (Model.ClsGy_MateMould_Model oSub in DetailColl)
|
{
|
DataSet Ds;
|
Int64 HInterID = 1;
|
Ds = oCn.RunProcReturn("select MAX(HInterID) HInterID from Gy_MateMouldInfo", "Gy_MateMouldInfo");
|
if (Ds.Tables[0].Rows.Count != 0 && ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString()) != 0)
|
{
|
HInterID = ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString());
|
HInterID += 1;
|
}
|
|
DataSet Cs;
|
Int64 HEntryID = 1;
|
Cs = oCn.RunProcReturn("select MAX(HEntryID) HEntryID from Gy_MateMouldInfo", "Gy_MateMouldInfo");
|
if (Cs.Tables[0].Rows.Count != 0 && ClsPub.isLong(Cs.Tables[0].Rows[0]["HEntryID"].ToString()) != 0)
|
{
|
HEntryID = ClsPub.isLong(Cs.Tables[0].Rows[0]["HEntryID"].ToString());
|
HEntryID += 1;
|
}
|
|
oCn.RunProc("Insert into Gy_MateMouldInfo " +
|
" (HInterID,HEntryID,HMaterID,HRelationID,HUnitID" +
|
",HBeginDate,HEndDate" +
|
",HUsed,HRemark,HMaker,HMakeDate,HType,HMouldQty,HProcID)" +
|
" values(" + HInterID + "," + HEntryID + "," + oSub.HMaterID.ToString() + "," + oSub.HRelationID.ToString() + "," + oSub.HUnitID.ToString() +
|
",'" + oSub.HBeginDate.ToShortDateString() + "','" + oSub.HEndDate.ToShortDateString() + "'," + Convert.ToString(oSub.HUsed ? 1 : 0) + ",'" + oSub.HRemark + "','" + oSub.HMaker + "','" + oSub.HMakeDate + "','" + 1 + "','" + 1 + "','" + 1 + "') ");
|
}
|
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_MateMould_Model oSub in DetailColl)
|
{
|
// oCn.RunProc("Insert into Gy_MateMouldInfo " +
|
// " (HMaterID,HRelationID,HUnitID" +
|
// ",HBeginDate,HEndDate" +
|
// ",HUsed,HRemark,HMaker,HMakeDate)" +
|
// " values(" + oSub.HMaterID.ToString() + "," + oSub.HRelationID.ToString() + "," + oSub.HUnitID.ToString() +
|
// ",'" + oSub.HBeginDate.ToShortDateString() + "','" + oSub.HEndDate.ToShortDateString() + "'," + Convert.ToString(oSub.HUsed ? 1 : 0) + ",'" + oSub.HRemark + "','" + oSub.HMaker + "','" + oSub.HMakeDate + "') ");
|
oCn.RunProc("Update Gy_MateMouldInfo set " +
|
"HRemark='" + oSub.HRemark + "'" +
|
",HMaterID='" + oSub.HMaterID + "'" +
|
",HRelationID='" + oSub.HRelationID + "'" +
|
",HUnitID='" + oSub.HUnitID + "'" +
|
//",HStopflag=" + Convert.ToString(HStopflag ? 1 : 0) +
|
//",HUseFlag=" + Convert.ToString(HUseFlag ? 1 : 0) +
|
//",HMakeTime= getdate()" +
|
//",HMakeEmp='" + HMakeEmp + "'" +
|
/*",HRemark='" + HRemark + */"Where HItemID ='" + sItemID + "'", ref DBUtility.ClsPub.sExeReturnInfo);
|
}
|
//oCn.RunProc("Update Gy_MateMouldInfo set " +
|
// " HMaterID='" + oSub.HMaterID.ToString() + "'" +
|
// ",HRelationID='" + oSub.HRelationID.ToString() + "'" +
|
// ",HUnitID='" + oSub.HUnitID.ToString() + "'" +
|
// ",HTechParamID='" + HTechParamID + "'" +
|
// ",HTechParamUnitID='" + HTechParamUnitID + "'" +
|
// ",HDeptID='" + HDeptID + "'" +
|
// ",HRemark='" + oSub.HRemark + "'" +
|
// //",HStopflag=" + Convert.ToString(HStopflag ? 1 : 0) +
|
// //",HUseFlag=" + Convert.ToString(HUseFlag ? 1 : 0) +
|
// //",HMakeTime= getdate()" +
|
// //",HMakeEmp='" + HMakeEmp + "'" +
|
// /*",HRemark='" + HRemark + */"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_MateMouldInfo Where HitemID=" + lngBillKey.ToString(), "Gy_MateMouldInfo");
|
DetailColl.Clear();//清空
|
for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
|
{
|
Model.ClsGy_MateMould_Model oSub = new Model.ClsGy_MateMould_Model();
|
oSub.HMaterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HMaterID"]);
|
oSub.HRelationID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HRelationID"]);
|
oSub.HUnitID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HUnitID"]);
|
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.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"]);
|
|
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_MateMouldInfo 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_ProcPrice 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_ProcPrice");
|
// 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_MateMould_Ctl()
|
{
|
MvarItemKey = "Gy_MateMouldInfo";
|
MvarReportTitle = "模具对应产品资料";
|
}
|
}
|
}
|