using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using System.Data;
|
|
namespace DAL
|
{
|
public class ClsCrm_CustomerAppealBill : DBUtility.ClsXt_BaseBill
|
{
|
public Model.ClsCrm_CustomerAppealBillMain omodel = new Model.ClsCrm_CustomerAppealBillMain();
|
public List<Model.ClsCrm_CustomerAppealBillSub> DetailColl = new List<Model.ClsCrm_CustomerAppealBillSub>();
|
|
public ClsCrm_CustomerAppealBill()
|
{
|
base.MvarItemKeyForWeb = "";
|
base.MvarItemKeySubForWeb = "";
|
base.MvarItemKeySub = "Crm_CustomerAppealBillSub";
|
base.MvarItemKeySub2 = "";
|
base.MvarItemKeySub3 = "";
|
base.MvarItemKeySub4 = "";
|
base.MvarItemKey= "Crm_CustomerAppealBillMain";
|
base.MvarReportTitle="客诉处理单";
|
base.BillType="7511";
|
base.HBillSubType = "7511";
|
|
}
|
|
#region 固定代码
|
|
~ClsCrm_CustomerAppealBill()
|
{
|
DetailColl = null;
|
}
|
|
#endregion 自定义方法
|
//修改单据
|
public override bool ModifyBill(Int64 lngBillKey, ref string sReturn)
|
{
|
try
|
{
|
//
|
oCn.BeginTran();
|
//更新主表
|
string sql = "update Crm_CustomerAppealBillMain set " +
|
"HYear = " + int.Parse(omodel.HDate.ToString("yyyy-MM-dd").Split('-')[0]) +
|
", HPeriod = " + int.Parse(omodel.HDate.ToString("yyyy-MM-dd").Split('-')[1]) +
|
", HBillType = '" + this.BillType +
|
"', HBillSubType = '" + this.HBillSubType +
|
"', HInterID = " + omodel.HInterID +
|
", HDate = '" + omodel.HDate.ToString("yyyy-MM-dd") +
|
"', HBillNo = '" + omodel.HBillNo +
|
"', HBillStatus = " + omodel.HBillStatus +
|
", HRemark = '" + omodel.HRemark +
|
"', HUpDater = getdate()" +
|
", HUpDateDate = '" + omodel.HUpDateDate +
|
"', HContext = '" + omodel.HContext +
|
"', HOrderBillNo = '" + omodel.HOrderBillNo +
|
"', HManager = " + omodel.HManager +
|
", HServiceMan = " + omodel.HServiceMan +
|
", HCusID = " + omodel.HCusID +
|
", HLinkMan = '" + omodel.HLinkMan +
|
"', HAppealType = '" + omodel.HAppealType +
|
"', HAppealTime = '" + omodel.HAppealTime.ToString("yyyy-MM-dd hh:mm:ss") +
|
"', HHappenTime = '" + omodel.HHappenTime.ToString("yyyy-MM-dd hh:mm:ss") +
|
"', HLevel = '" + omodel.HLevel +
|
"', HWorkShopID = " + omodel.HWorkShopID +
|
", HMaterID = " + omodel.HMaterID +
|
", HUnitID = " + omodel.HUnitID +
|
", HMaterType = '" + omodel.HMaterType +
|
"', HQty = " + omodel.HQty +
|
", HBadQty = " + omodel.HBadQty +
|
", HBadSource = '" + omodel.HBadSource +
|
"', HBadReasonID = " + omodel.HBadReasonID +
|
", HProcID = " + omodel.HProcID +
|
", HWorkedResult = '" + omodel.HWorkedResult +
|
"', HIsStopLine = '" + omodel.HIsStopLine +
|
"', HIsRepeat = '" + omodel.HIsRepeat +
|
"', HIsMater = '" + omodel.HIsMater +
|
"', HMaterNumber = '" + omodel.HMaterNumber +
|
"', HBarCode = '" + omodel.HBarCode +
|
"', HBadNote = '" + omodel.HBadNote +
|
"', HBadRemark = '" + omodel.HBadRemark +
|
"' where HInterID = " + lngBillKey.ToString();
|
|
oCn.RunProc(sql);
|
|
|
//删除关联
|
DeleteRelation(ref sReturn, lngBillKey);
|
|
|
//删除子表
|
DeleteBillSub(lngBillKey);
|
//插入子表
|
omodel.HInterID = lngBillKey;
|
int HEntryID = 0; //标记子表的子内码
|
foreach (Model.ClsCrm_CustomerAppealBillSub oSub in DetailColl)
|
{
|
HEntryID++;
|
sql = "insert into Crm_CustomerAppealBillSub" +
|
"(HInterID,HEntryID,HRemark) " +
|
"values(" +
|
"" + omodel.HInterID +
|
"," + HEntryID +
|
")";
|
|
|
oCn.RunProc(sql);
|
}
|
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();
|
string sql = "insert into Crm_CustomerAppealBillMain" +
|
"(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate,HBillNo,HBillStatus,HRemark,HMaker,HMakeDate,HContext,HOrderBillNo,HManager,HServiceMan,HCusID,HLinkMan" +
|
",HAppealType,HAppealTime,HHappenTime,HLevel,HWorkShopID,HMaterID,HUnitID,HMaterType,HQty,HBadQty,HBadSource,HBadReasonID,HProcID,HWorkedResult,HIsStopLine,HIsRepeat" +
|
",HIsMater,HMaterNumber,HBarCode,HBadNote,HBadRemark) " +
|
"values(" +
|
"" + int.Parse(omodel.HDate.ToString("yyyy-MM-dd").Split('-')[0]) +
|
"," + int.Parse(omodel.HDate.ToString("yyyy-MM-dd").Split('-')[1]) +
|
",'" + this.BillType +
|
"','" + this.HBillSubType +
|
"'," + omodel.HInterID +
|
",'" + omodel.HDate.ToString("yyyy-MM-dd") +
|
"','" + omodel.HBillNo +
|
"'," + 1 +
|
",'" + omodel.HRemark +
|
"','" + DBUtility.ClsPub.CurUserName +
|
"',getdate()" +
|
",'" + omodel.HContext +
|
"','" + omodel.HOrderBillNo +
|
"'," + omodel.HManager +
|
"," + omodel.HServiceMan +
|
"," + omodel.HCusID +
|
",'" + omodel.HLinkMan +
|
"','" + omodel.HAppealType +
|
"','" + omodel.HAppealTime.ToString("yyyy-MM-dd hh:mm:ss") +
|
"','" + omodel.HHappenTime.ToString("yyyy-MM-dd hh:mm:ss") +
|
"','" + omodel.HLevel +
|
"'," + omodel.HWorkShopID +
|
"," + omodel.HMaterID +
|
"," + omodel.HUnitID +
|
",'" + omodel.HMaterType +
|
"'," + omodel.HQty +
|
"," + omodel.HBadQty +
|
",'" + omodel.HBadSource +
|
"'," + omodel.HBadReasonID +
|
"," + omodel.HProcID +
|
",'" + omodel.HWorkedResult +
|
"','" + omodel.HIsStopLine +
|
"','" + omodel.HIsRepeat +
|
"','" + omodel.HIsMater +
|
"','" + omodel.HMaterNumber +
|
"','" + omodel.HBarCode +
|
"','" + omodel.HBadNote +
|
"','" + omodel.HBadRemark +
|
"')";
|
|
|
|
|
//主表
|
oCn.RunProc(sql);
|
//插入子表
|
int HEntryID = 0; //标记子表的子内码
|
foreach (Model.ClsCrm_CustomerAppealBillSub oSub in DetailColl)
|
{
|
HEntryID++;
|
sql = "insert into Crm_CustomerAppealBillSub" +
|
"(HInterID,HEntryID,HRemark) " +
|
"values(" +
|
"" + omodel.HInterID +
|
"," + HEntryID +
|
")";
|
|
|
oCn.RunProc(sql);
|
}
|
|
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 Crm_CustomerAppealBillMain Where HInterID=" + lngBillKey.ToString(), "Crm_CustomerAppealBillMain");
|
if(Ds.Tables[0].Rows.Count==0)
|
{
|
sReturn = "单据未找到!";
|
return false;
|
}
|
//固定赋值===========================================
|
omodel.HYear = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HYear"]);
|
omodel.HPeriod = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HPeriod"]);
|
omodel.HBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBillType"]);
|
omodel.HBillSubType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBillSubType"]);
|
omodel.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"]);
|
omodel.HDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HDate"]);
|
omodel.HBillNo = Ds.Tables[0].Rows[0]["HBillNo"].ToString().Trim();
|
omodel.HBillStatus = DBUtility.ClsPub.isInt(Ds.Tables[0].Rows[0]["HBillStatus"]);
|
omodel.HCheckItemNowID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCheckItemNowID"]);
|
omodel.HCheckItemNextID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCheckItemNextID"]);
|
omodel.HCheckFlowID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCheckFlowID"]);
|
omodel.HRemark = Ds.Tables[0].Rows[0]["HRemark"].ToString().Trim();
|
omodel.HBackDate = Ds.Tables[0].Rows[0]["HBackDate"].ToString().Trim();
|
omodel.HBacker = Ds.Tables[0].Rows[0]["HBacker"].ToString().Trim();
|
omodel.HCheckDate = Ds.Tables[0].Rows[0]["HCheckDate"].ToString().Trim();
|
omodel.HChecker = Ds.Tables[0].Rows[0]["HChecker"].ToString().Trim();
|
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.HCloseDate = Ds.Tables[0].Rows[0]["HCloseDate"].ToString().Trim();
|
omodel.HCloseMan = Ds.Tables[0].Rows[0]["HCloseMan"].ToString().Trim();
|
omodel.HCloseType = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[0]["HCloseType"]);
|
omodel.HDeleteDate = Ds.Tables[0].Rows[0]["HDeleteDate"].ToString().Trim();
|
omodel.HDeleteMan = Ds.Tables[0].Rows[0]["HDeleteMan"].ToString().Trim();
|
//========================================================
|
omodel.HContext = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HContext"]);
|
omodel.HOrderBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HOrderBillNo"]);
|
omodel.HManager = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HManager"]);
|
omodel.HServiceMan = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HServiceMan"]);
|
omodel.HCusID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCusID"]);
|
omodel.HLinkMan = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HLinkMan"]);
|
omodel.HAppealType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HAppealType"]);
|
omodel.HAppealTime = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HAppealTime"]);
|
omodel.HHappenTime = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HHappenTime"]);
|
omodel.HLevel = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HLevel"]);
|
omodel.HWorkShopID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HWorkShopID"]);
|
omodel.HMaterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMaterID"]);
|
omodel.HUnitID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HUnitID"]);
|
omodel.HMaterType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HMaterType"]);
|
omodel.HQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HQty"]);
|
omodel.HBadQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HBadQty"]);
|
omodel.HBadSource = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBadSource"]);
|
omodel.HBadReasonID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HBadReasonID"]);
|
omodel.HProcID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HProcID"]);
|
omodel.HWorkedResult = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HWorkedResult"]);
|
omodel.HIsStopLine = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HIsStopLine"]);
|
omodel.HIsRepeat = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HIsRepeat"]);
|
omodel.HIsMater = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HIsMater"]);
|
omodel.HMaterNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HMaterNumber"]);
|
omodel.HBarCode = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBarCode"]);
|
omodel.HBadNote = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBadNote"]);
|
omodel.HBadRemark = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBadRemark"]);
|
|
//
|
|
//循环
|
DataSet DsSub ;
|
DsSub = oCn.RunProcReturn("Select * from Crm_CustomerAppealBillSub Where HInterID=" + lngBillKey.ToString() + " order by HEntryID ", "Crm_CustomerAppealBillSub");
|
DetailColl.Clear();//清空
|
for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
|
{
|
Model.ClsCrm_CustomerAppealBillSub oSub = new Model.ClsCrm_CustomerAppealBillSub();
|
// 固定赋值===============================================
|
oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HInterID"]);
|
oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HEntryID"]);
|
oSub.HSourceInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceInterID"]);
|
oSub.HSourceEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceEntryID"]);
|
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"]);
|
oSub.HRelationMoney = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationMoney"]);
|
oSub.HCloseMan = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HCloseMan"]);
|
oSub.HCloseType = DBUtility.ClsPub.isBool(DsSub.Tables[0].Rows[i]["HCloseType"]);
|
oSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[i]["HEntryCloseDate"]);
|
oSub.HRemark = DsSub.Tables[0].Rows[i]["HRemark"].ToString().Trim();
|
DetailColl.Add(oSub);
|
}
|
sReturn = "显示单据成功!";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
|
|
}
|
|
}
|