using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using System.Data;
|
using Model;
|
|
namespace DAL
|
{
|
public class ClsOA_WorkLinkBill:DBUtility.ClsXt_BaseBill
|
{
|
public Model.ClsOA_WorkLinkBillMain omodel = new Model.ClsOA_WorkLinkBillMain();
|
public List<Model.ClsOA_WorkLinkBillSub> DetailColl = new List<Model.ClsOA_WorkLinkBillSub>();
|
public List<Model.ClsOA_WorkLinkBillSub2> DetailColl2 = new List<Model.ClsOA_WorkLinkBillSub2>();
|
|
public ClsOA_WorkLinkBill()
|
{
|
base.MvarItemKeySub = "OA_WorkLinkBillSub";
|
base.MvarItemKeySub2 = "OA_WorkLinkBillSub2";
|
base.MvarItemKeySub3 = "";
|
base.MvarItemKeySub4 = "";
|
base.MvarItemKey="OA_WorkLinkBillMain";
|
base.MvarReportTitle="工作联系单";
|
base.BillType = "4501";
|
base.HBillSubType = "4501";
|
|
}
|
|
#region 固定代码
|
|
~ClsOA_WorkLinkBill()
|
{
|
DetailColl = null;
|
}
|
|
#endregion 自定义方法
|
//修改单据
|
public override bool ModifyBill(Int64 lngBillKey, ref string sReturn)
|
{
|
try
|
{
|
//
|
oCn.BeginTran();
|
//更新主表
|
oCn.RunProc("UpDate OA_WorkLinkBillMain set " +
|
" HBillNo='" + omodel.HBillNo + "'" +
|
",HDeptID=" + omodel.HDeptID.ToString() +
|
",HDate='" + omodel.HDate.ToShortDateString() + "'" +
|
",HCommDate='" + omodel.HCommDate.ToShortDateString() + "'" +
|
",HSendMan='" + omodel.HSendMan + "'" +
|
",HReceiveMan='" + omodel.HReceiveMan + "'" +
|
",HCopyMan='" + omodel.HCopyMan + "'" +
|
",HLevel='" + omodel.HLevel + "'" +
|
",HReTransmitMan='" + omodel.HReTransmitMan + "'" +
|
",HContext='" + omodel.HContext + "'" +
|
",HSendType='" + omodel.HSendType + "'" +
|
",HDescription='" + omodel.HDescription + "'" +
|
",HRemark='" + omodel.HRemark + "'" +
|
",HUpdater='" + DBUtility.ClsPub.CurUserName + "'" +
|
",HUpdateDate='" + DBUtility.ClsPub.GetServerDate(-1) + "'" +
|
" where HInterID=" + lngBillKey.ToString());
|
//删除关联
|
//DeleteRelation(ref sReturn, lngBillKey);
|
//删除子表
|
DeleteBillSub(lngBillKey);
|
DeleteBillSub2(lngBillKey);
|
//插入子表
|
omodel.HInterID = lngBillKey;
|
//插入子表
|
foreach (ClsOA_WorkLinkBillSub oSub in DetailColl)
|
{
|
oCn.RunProc("Insert into OA_WorkLinkBillSub " +
|
" (HInterID,HEntryID,HSendStatus,HSendMan" +
|
",HDescription,HDate)" +
|
" values("
|
+ omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + "," + oSub.HSendStatus.ToString() + ",'" + oSub.HSendMan + "'" +
|
",'" + oSub.HDescription + "','" + omodel.HDate.ToShortDateString() + "'" +
|
") ");
|
}
|
//插入子表
|
foreach (ClsOA_WorkLinkBillSub2 oSub in DetailColl2)
|
{
|
oCn.RunProc("Insert into OA_WorkLinkBillSub2 " +
|
" (HInterID,HEntryID,HReceiveMan,HReadFlag)" +
|
" values("
|
+ omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + oSub.HReceiveMan + "'," + DBUtility.ClsPub.BoolToString(oSub.HReadFlag) + "" +
|
") ");
|
}
|
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 OA_WorkLinkBillMain " +
|
"(HBillType,HInterID,HBillNo,HDate" +
|
",HDeptID,HDescription" +
|
",HMaker,HMakeDate,HBillStatus" +
|
",HYear,HPeriod,HRemark,HContext" +
|
",HSendMan,HReceiveMan,HCopyMan,HHasten" +
|
",HLevel,HReTransmitMan,HSendType,HEvaluateStatusID" +
|
",HCommDate" +
|
") " +
|
" values('" + BillType + "'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','" + omodel.HDate + "'" +
|
"," + omodel.HDeptID.ToString() + ",'" + omodel.HDescription + "'" +
|
",'" + DBUtility.ClsPub.CurUserName + "','" + DBUtility.ClsPub.GetServerDate(-1) + "'," + omodel.HBillStatus +
|
"," + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "','" + omodel.HContext + "'" +
|
",'" + omodel.HSendMan + "','" + omodel.HReceiveMan + "','" + omodel.HCopyMan + "'," + omodel.HHasten.ToString() + "" +
|
",'" + omodel.HLevel + "','" + omodel.HReTransmitMan + "','" + omodel.HSendType + "'," + omodel.HEvaluateStatusID.ToString() + "" +
|
",'" + omodel.HCommDate.ToShortDateString() + "'" +
|
") ");
|
//插入子表
|
foreach (ClsOA_WorkLinkBillSub oSub in DetailColl)
|
{
|
oCn.RunProc("Insert into OA_WorkLinkBillSub " +
|
" (HInterID,HEntryID,HSendStatus,HSendMan" +
|
",HDescription,HDate)" +
|
" values("
|
+ omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + "," + oSub.HSendStatus.ToString() + ",'" + oSub.HSendMan + "'" +
|
",'" + oSub.HDescription + "','" + omodel.HDate.ToShortDateString() + "'" +
|
") ");
|
}
|
//插入子表
|
foreach (ClsOA_WorkLinkBillSub2 oSub in DetailColl2)
|
{
|
oCn.RunProc("Insert into OA_WorkLinkBillSub2 " +
|
" (HInterID,HEntryID,HReceiveMan,HReadFlag)" +
|
" values("
|
+ omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + oSub.HReceiveMan + "'," + DBUtility.ClsPub.BoolToString(oSub.HReadFlag) + "" +
|
") ");
|
}
|
//
|
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 OA_WorkLinkBillMain Where HInterID=" + lngBillKey.ToString(), "OA_WorkLinkBillMain");
|
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.HDescription = Ds.Tables[0].Rows[0]["HDescription"].ToString().Trim();
|
omodel.HContext = Ds.Tables[0].Rows[0]["HContext"].ToString().Trim();
|
omodel.HDeptID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HDeptID"].ToString());
|
omodel.HSendMan = Ds.Tables[0].Rows[0]["HSendMan"].ToString().Trim();
|
omodel.HReceiveMan = Ds.Tables[0].Rows[0]["HReceiveMan"].ToString().Trim();
|
omodel.HCopyMan = Ds.Tables[0].Rows[0]["HCopyMan"].ToString().Trim();
|
omodel.HHasten = DBUtility.ClsPub.isInt(Ds.Tables[0].Rows[0]["HHasten"]);
|
omodel.HLevel = Ds.Tables[0].Rows[0]["HLevel"].ToString().Trim();
|
omodel.HReTransmitMan = Ds.Tables[0].Rows[0]["HReTransmitMan"].ToString().Trim();
|
omodel.HSendType = Ds.Tables[0].Rows[0]["HSendType"].ToString().Trim();
|
omodel.HEvaluateStatusID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HEvaluateStatusID"]);
|
omodel.HCommDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HCommDate"]);
|
//
|
|
//循环
|
DataSet DsSub ;
|
DsSub = oCn.RunProcReturn("Select * from OA_WorkLinkBillSub Where HInterID=" + lngBillKey.ToString() + " order by HEntryID ", "OA_WorkLinkBillSub");
|
DetailColl.Clear();//清空
|
for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
|
{
|
Model.ClsOA_WorkLinkBillSub oSub = new Model.ClsOA_WorkLinkBillSub();
|
// 固定赋值===============================================
|
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();
|
//===================================================
|
oSub.HSendStatus = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSendStatus"]);
|
oSub.HSendMan = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HSendMan"]);
|
oSub.HDescription = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HDescription"]);
|
oSub.HDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[i]["HDate"]);
|
DetailColl.Add(oSub);
|
}
|
//修改状态为已读
|
isRead(lngBillKey);
|
sReturn = "显示单据成功!";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
|
/// <summary>
|
/// 根据ID,修改状态为已读
|
/// </summary>
|
/// <param name="lngBillKey"></param>
|
/// <param name="sReturn"></param>
|
/// <returns></returns>
|
public void isRead(Int64 lngBillKey)
|
{
|
try
|
{
|
//查询主表
|
oCn.RunProcReturn("exec h_p_OA_WorkLinkBill_Read " + lngBillKey.ToString() + ",'" + DBUtility.ClsPub.CurUserName + "'", "gy_czygl");
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
|
//新增只添加主表和用户列表
|
public bool AddBillNew(ref string sReturn)
|
{
|
try
|
{
|
//得到mainid
|
omodel.HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
|
//若MAINDI重复则重新获取
|
oCn.BeginTran();
|
//主表
|
oCn.RunProc("Insert Into OA_WorkLinkBillMain " +
|
"(HBillType,HInterID,HBillNo,HDate" +
|
",HDeptID,HDescription" +
|
",HMaker,HMakeDate,HBillStatus" +
|
",HYear,HPeriod,HRemark,HContext" +
|
",HSendMan,HReceiveMan,HCopyMan,HHasten" +
|
",HLevel,HReTransmitMan,HSendType,HEvaluateStatusID" +
|
",HCommDate,HRelationInterID,HRelationEntryID,HRelationBillNo,HRelationBillType" +
|
") " +
|
" values('" + BillType + "'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','" + omodel.HDate + "'" +
|
"," + omodel.HDeptID.ToString() + ",'" + omodel.HDescription + "'" +
|
",'" + DBUtility.ClsPub.CurUserName + "','" + DBUtility.ClsPub.GetServerDate(-1) + "'," + omodel.HBillStatus +
|
"," + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "','" + omodel.HContext + "'" +
|
",'" + omodel.HSendMan + "','" + omodel.HReceiveMan + "','" + omodel.HCopyMan + "'," + omodel.HHasten.ToString() + "" +
|
",'" + omodel.HLevel + "','" + omodel.HReTransmitMan + "','" + omodel.HSendType + "'," + omodel.HEvaluateStatusID.ToString() + "" +
|
",'" + omodel.HCommDate.ToShortDateString() + "','" + omodel.HRelationInterID + "','" + omodel.HRelationEntryID + "','" + omodel.HRelationBillNo + "','" + omodel.HRelationBillType + "'" +
|
") ");
|
//插入子表
|
//foreach (ClsOA_WorkLinkBillSub oSub in DetailColl)
|
//{
|
// oCn.RunProc("Insert into OA_WorkLinkBillSub " +
|
// " (HInterID,HEntryID,HSendStatus,HSendMan" +
|
// ",HDescription,HDate)" +
|
// " values("
|
// + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + "," + oSub.HSendStatus.ToString() + ",'" + oSub.HSendMan + "'" +
|
// ",'" + oSub.HDescription + "','" + omodel.HDate.ToShortDateString() + "'" +
|
// ") ");
|
//}
|
//插入子表
|
foreach (ClsOA_WorkLinkBillSub2 oSub in DetailColl2)
|
{
|
oCn.RunProc("Insert into OA_WorkLinkBillSub2 " +
|
" (HInterID,HEntryID,HReceiveMan,HReadFlag)" +
|
" values("
|
+ omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + oSub.HReceiveMan + "'," + DBUtility.ClsPub.BoolToString(oSub.HReadFlag) + "" +
|
") ");
|
}
|
//
|
sReturn = "新增单据成功!";
|
oCn.Commit();
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
//修改只主表和用户列表
|
public bool ModifyBillNew(Int64 lngBillKey, ref string sReturn)
|
{
|
try
|
{
|
//
|
oCn.BeginTran();
|
//更新主表
|
oCn.RunProc("UpDate OA_WorkLinkBillMain set " +
|
" HBillNo='" + omodel.HBillNo + "'" +
|
",HDeptID=" + omodel.HDeptID.ToString() +
|
",HDate='" + omodel.HDate.ToShortDateString() + "'" +
|
",HCommDate='" + omodel.HCommDate.ToShortDateString() + "'" +
|
",HSendMan='" + omodel.HSendMan + "'" +
|
",HReceiveMan='" + omodel.HReceiveMan + "'" +
|
",HCopyMan='" + omodel.HCopyMan + "'" +
|
",HLevel='" + omodel.HLevel + "'" +
|
",HReTransmitMan='" + omodel.HReTransmitMan + "'" +
|
",HContext='" + omodel.HContext + "'" +
|
",HSendType='" + omodel.HSendType + "'" +
|
",HDescription='" + omodel.HDescription + "'" +
|
",HRemark='" + omodel.HRemark + "'" +
|
",HUpdater='" + DBUtility.ClsPub.CurUserName + "'" +
|
",HUpdateDate='" + DBUtility.ClsPub.GetServerDate(-1) + "'" +
|
" where HInterID=" + lngBillKey.ToString());
|
//删除关联
|
//DeleteRelation(ref sReturn, lngBillKey);
|
//删除子表
|
DeleteBillSub2(lngBillKey);
|
//插入子表
|
omodel.HInterID = lngBillKey;
|
//插入子表
|
//foreach (ClsOA_WorkLinkBillSub oSub in DetailColl)
|
//{
|
// oCn.RunProc("Insert into OA_WorkLinkBillSub " +
|
// " (HInterID,HEntryID,HSendStatus,HSendMan" +
|
// ",HDescription,HDate)" +
|
// " values("
|
// + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + "," + oSub.HSendStatus.ToString() + ",'" + oSub.HSendMan + "'" +
|
// ",'" + oSub.HDescription + "','" + omodel.HDate.ToShortDateString() + "'" +
|
// ") ");
|
//}
|
//插入子表
|
foreach (ClsOA_WorkLinkBillSub2 oSub in DetailColl2)
|
{
|
oCn.RunProc("Insert into OA_WorkLinkBillSub2 " +
|
" (HInterID,HEntryID,HReceiveMan,HReadFlag)" +
|
" values("
|
+ omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + oSub.HReceiveMan + "'," + DBUtility.ClsPub.BoolToString(oSub.HReadFlag) + "" +
|
") ");
|
}
|
sReturn = "修改单据成功!";
|
oCn.Commit();
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
|
}
|
}
|