using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using System.Data;
|
|
namespace DAL
|
{
|
public class ClsCB_UnQualiFiedCheckBill : DBUtility.ClsXt_BaseBill
|
{
|
public Model.ClsCB_UnQualiFiedCheckBillMain omodel = new Model.ClsCB_UnQualiFiedCheckBillMain();
|
public List<Model.ClsCB_UnQualiFiedCheckBillSub> DetailColl = new List<Model.ClsCB_UnQualiFiedCheckBillSub>();
|
|
public ClsCB_UnQualiFiedCheckBill()
|
{
|
base.MvarItemKeySub = "CB_UnQualiFiedCheckBillSub";
|
base.MvarItemKeySub2 = "";
|
base.MvarItemKeySub3 = "";
|
base.MvarItemKeySub4 = "";
|
base.MvarItemKey = "CB_UnQualiFiedCheckBillMain";
|
base.MvarReportTitle = "不合格审理单";
|
base.BillType = "1823";
|
base.HBillSubType = "1823";
|
|
}
|
|
#region 固定代码
|
|
~ClsCB_UnQualiFiedCheckBill()
|
{
|
DetailColl = null;
|
}
|
|
#endregion 自定义方法
|
//修改单据
|
public override bool ModifyBill(Int64 lngBillKey, ref string sReturn)
|
{
|
try
|
{
|
oCn.BeginTran();
|
//更新主表
|
oCn.RunProc("UpDate CB_UnQualiFiedCheckBillMain set " +
|
" HBillNo='" + omodel.HBillNo + "'" +
|
",HMaterID=" + omodel.HMaterID.ToString() +
|
",HGroupID=" + omodel.HGroupID.ToString() +
|
",HEmpID=" + omodel.HEmpID.ToString() +
|
",HQty=" + omodel.HQty.ToString() +
|
",HUnQty=" + omodel.HUnQty.ToString() +
|
",HProcNo='" + omodel.HProcNo + "'" +
|
",HBatchNo='" + omodel.HBatchNo + "'" +
|
",HType='" + omodel.HType + "'" +
|
",HReason='" + omodel.HReason + "'" +
|
",HReason1='" + omodel.HReason1 + "'" +
|
",HDate='" + omodel.HDate + "'" +
|
",HYear='" + omodel.HYear.ToString() + "'" +
|
",HPeriod='" + omodel.HPeriod.ToString() + "'" +
|
",HRemark='" + omodel.HRemark + "'" +
|
",HUpdater='" + DBUtility.ClsPub.CurUserName + "'" +
|
",HUpdateDate='" + DBUtility.ClsPub.GetServerDate(-1) + "'" +
|
" where HInterID=" + lngBillKey.ToString());
|
//删除关联
|
DeleteRelation(ref sReturn, lngBillKey);
|
//删除子表
|
DeleteBillSub(lngBillKey);
|
//插入子表
|
foreach (Model.ClsCB_UnQualiFiedCheckBillSub oSub in DetailColl)
|
{
|
oCn.RunProc("Insert into CB_UnQualiFiedCheckBillSub " +
|
" (HInterID,HEntryID,HMaterID,HProcMoney" +
|
",HQty,HUnQty,HHSMoney,HCJMoney,HSunHao,HUnRate" +
|
",HCheckItemRemark,HUnQualiFied,HHSType" +
|
",HCloseMan,HCloseType,HRemark" +
|
",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType" +
|
",HRelationQty,HRelationMoney" +
|
") values("
|
+ lngBillKey.ToString() + "," + oSub.HEntryID.ToString() + "," + oSub.HMaterID.ToString() + "," + oSub.HProcMoney.ToString() +
|
"," + oSub.HQty.ToString() + "," + oSub.HUnQty.ToString() + "," + oSub.HHSMoney.ToString() + "," + oSub.HCJMoney.ToString() + "," + oSub.HSunHao.ToString() + "," + oSub.HUnRate.ToString() +
|
",'" + oSub.HCheckItemRemark + "','" + oSub.HUnQualiFied + "'," + Convert.ToString(oSub.HHSType ? 1 : 0) +
|
",'" + oSub.HCloseMan + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "'" +
|
"," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'" +
|
"," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() +
|
") ");
|
}
|
sReturn = "修改单据成功!";
|
oCn.Commit();
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
//新增单据
|
public override bool AddBill(ref string sReturn)
|
{
|
try
|
{
|
//得到mainid
|
omodel.HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
|
//若MAINDI重复则重新获取
|
oCn.BeginTran();
|
//主表
|
oCn.RunProc("Insert Into CB_UnQualiFiedCheckBillMain " +
|
"(HBillType,HInterID,HBillNo,HDate" +
|
",HYear,HPeriod,HRemark,HMaker" +
|
",HMakeDate,HMaterID,HGroupID,HEmpID" +
|
",HProcNo,HQty,HUnQty,HBatchNo" +
|
",HType,HReason,HReason1" +
|
") " +
|
" values('" + this.MvarItemKey + "'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','" + omodel.HDate + "'" +
|
"," + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "','" + DBUtility.ClsPub.CurUserName +
|
"','" + DBUtility.ClsPub.GetServerDate(-1) + "'," + omodel.HMaterID.ToString() + "," + omodel.HGroupID.ToString() + "," + omodel.HEmpID.ToString() +
|
",'" + omodel.HProcNo + "'," + omodel.HQty.ToString() + "," + omodel.HUnQty.ToString() + ",'" + omodel.HBatchNo +"'"+
|
",'" + omodel.HType + "','" + omodel.HReason + "','" + omodel.HReason1 + "'" +
|
") ");
|
//插入子表
|
foreach (Model.ClsCB_UnQualiFiedCheckBillSub oSub in DetailColl)
|
{
|
oCn.RunProc("Insert into CB_UnQualiFiedCheckBillSub " +
|
" (HInterID,HEntryID,HMaterID,HProcMoney" +
|
",HQty,HUnQty,HHSMoney,HCJMoney,HSunHao,HUnRate" +
|
",HCheckItemRemark,HUnQualiFied,HHSType" +
|
",HCloseMan,HCloseType,HRemark" +
|
",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType" +
|
",HRelationQty,HRelationMoney" +
|
") values("
|
+ omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + "," + oSub.HMaterID.ToString() + "," + oSub.HProcMoney.ToString() +
|
"," + oSub.HQty.ToString() + "," + oSub.HUnQty.ToString() + "," + oSub.HHSMoney.ToString() + "," + oSub.HCJMoney.ToString() + "," + oSub.HSunHao.ToString() + "," + oSub.HUnRate.ToString() +
|
",'" + oSub.HCheckItemRemark + "','" + oSub.HUnQualiFied + "'," + Convert.ToString(oSub.HHSType ? 1 : 0) +
|
",'" + oSub.HCloseMan + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "'" +
|
"," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'" +
|
"," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() +
|
") ");
|
}
|
sReturn = "新增单据成功!";
|
oCn.Commit();
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
//显示单据
|
public override bool ShowBill(Int64 lngBillKey, ref string sReturn)
|
{
|
try
|
{
|
//查询主表
|
DataSet Ds;
|
Ds = oCn.RunProcReturn("Select * from CB_UnQualiFiedCheckBillMain Where HInterID=" + lngBillKey.ToString(), "CB_UnQualiFiedCheckBillMain");
|
if (Ds.Tables[0].Rows.Count == 0)
|
{
|
sReturn = "单据未找到!";
|
return false;
|
}
|
omodel.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString());
|
omodel.HBillNo = Ds.Tables[0].Rows[0]["HBillNo"].ToString().Trim();
|
omodel.HDate = Convert.ToDateTime(Ds.Tables[0].Rows[0]["HDate"].ToString().Trim());
|
omodel.HYear = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HYear"].ToString());
|
omodel.HPeriod = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HPeriod"].ToString());
|
omodel.HRemark = Ds.Tables[0].Rows[0]["HRemark"].ToString().Trim();
|
omodel.HMaterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMaterID"].ToString());
|
omodel.HGroupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HGroupID"].ToString());
|
omodel.HEmpID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HEmpID"].ToString());
|
omodel.HProcNo = Ds.Tables[0].Rows[0]["HProcNo"].ToString().Trim();
|
omodel.HQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HQty"].ToString());
|
omodel.HUnQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HUnQty"].ToString());
|
omodel.HBatchNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBatchNo"].ToString());
|
omodel.HType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HType"].ToString());
|
omodel.HReason = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HReason"].ToString());
|
omodel.HReason1 = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HReason1"].ToString());
|
//
|
omodel.HMaker = Ds.Tables[0].Rows[0]["HMaker"].ToString().Trim();
|
omodel.HMakeDate = Ds.Tables[0].Rows[0]["HMakeDate"].ToString().Trim();
|
omodel.HUpDateDate = Ds.Tables[0].Rows[0]["HUpDateDate"].ToString().Trim();
|
omodel.HUpDater = Ds.Tables[0].Rows[0]["HUpDater"].ToString().Trim();
|
omodel.HCheckDate = Ds.Tables[0].Rows[0]["HCheckDate"].ToString().Trim();
|
omodel.HChecker = Ds.Tables[0].Rows[0]["HChecker"].ToString().Trim();
|
omodel.HCloseDate = Ds.Tables[0].Rows[0]["HCloseDate"].ToString().Trim();
|
omodel.HCloseMan = Ds.Tables[0].Rows[0]["HCloseMan"].ToString().Trim();
|
omodel.HDeleteDate = Ds.Tables[0].Rows[0]["HDeleteDate"].ToString().Trim();
|
omodel.HDeleteMan = Ds.Tables[0].Rows[0]["HDeleteMan"].ToString().Trim();
|
//循环
|
DataSet DsSub = new DataSet();
|
DsSub = oCn.RunProcReturn("Select * from CB_UnQualiFiedCheckBillSub Where HInterID=" + lngBillKey.ToString() + " order by HEntryID ", "CB_UnQualiFiedCheckBillSub");
|
DetailColl.Clear();//清空
|
for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
|
{
|
Model.ClsCB_UnQualiFiedCheckBillSub oSub = new Model.ClsCB_UnQualiFiedCheckBillSub();
|
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.HProcMoney = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HProcMoney"].ToString());
|
|
oSub.HCheckItemRemark = DsSub.Tables[0].Rows[i]["HCheckItemRemark"].ToString().Trim();
|
oSub.HUnQualiFied = DsSub.Tables[0].Rows[i]["HUnQualiFied"].ToString().Trim();
|
oSub.HHSType = (bool)DsSub.Tables[0].Rows[i]["HHSType"];
|
oSub.HRemark = DsSub.Tables[0].Rows[i]["HRemark"].ToString().Trim();
|
oSub.HQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HQty"].ToString());
|
oSub.HUnQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HUnQty"].ToString());
|
oSub.HHSMoney = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HHSMoney"].ToString());
|
oSub.HCJMoney = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HCJMoney"].ToString());
|
oSub.HSunHao = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HSunHao"].ToString());
|
oSub.HUnRate = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HUnRate"].ToString());
|
oSub.HCloseMan = DsSub.Tables[0].Rows[i]["HCloseMan"].ToString().Trim();
|
oSub.HCloseType = (bool)DsSub.Tables[0].Rows[i]["HCloseType"];
|
//
|
oSub.HSourceInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceInterID"].ToString());
|
oSub.HSourceEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceEntryID"].ToString());
|
oSub.HSourceBillType = DsSub.Tables[0].Rows[i]["HSourceBillType"].ToString().Trim();
|
oSub.HSourceBillNo = DsSub.Tables[0].Rows[i]["HSourceBillNo"].ToString().Trim();
|
oSub.HRelationQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationQty"].ToString());
|
oSub.HRelationMoney = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationMoney"].ToString());
|
DetailColl.Add(oSub);
|
}
|
sReturn = "显示单据成功!";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
|
/// <summary>
|
/// 得到回收金额 料工费
|
/// </summary>
|
/// <param name="HICMOID"></param>
|
/// <param name="sReturn"></param>
|
/// <returns></returns>
|
public bool GetPriceCostByHMaterID(long HMaterID, ref double CLMoney, ref double SumMoney)
|
{
|
DataSet Ds;
|
//
|
//增加主表
|
Ds = oCn.RunProcReturn("exec h_p_CB_GetMaterPriceCost " + HMaterID.ToString(), "h_p_CB_GetMaterPriceCost");
|
if (Ds == null || Ds.Tables[0].Rows.Count == 0)
|
{
|
CLMoney = 0;
|
SumMoney = 0;
|
return false;
|
}
|
else
|
{
|
CLMoney = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["材料成本"]);
|
SumMoney = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["料工费"]);
|
return true;
|
}
|
}
|
|
|
|
|
|
|
}
|
}
|