|  |  | 
 |  |  |         public Models.ClsOA_ErrMsgBackBillMain omodel = new Models.ClsOA_ErrMsgBackBillMain(); | 
 |  |  |         public List<Models.ClsOA_ErrMsgBackBillSub> DetailColl = new List<Models.ClsOA_ErrMsgBackBillSub>(); | 
 |  |  |         public List<Models.ClsOA_ErrMsgBackBillSub2> DetailColl2 = new List<Models.ClsOA_ErrMsgBackBillSub2>(); | 
 |  |  |         public Models.ClsOA_ErrMsgBackBillSub DetailReply = new Models.ClsOA_ErrMsgBackBillSub(); | 
 |  |  |  | 
 |  |  |         public ClsOA_ErrMsgBackBill() | 
 |  |  |         { | 
 |  |  |             base.MvarItemKeySub = "OA_ErrMsgBackBillSub"; | 
 |  |  |             base.MvarItemKeySub2 = ""; | 
 |  |  |             base.MvarItemKeySub2 = "OA_ErrMsgBackBillSub2"; | 
 |  |  |             base.MvarItemKeySub3 = ""; | 
 |  |  |             base.MvarItemKeySub4 = ""; | 
 |  |  |             base.MvarItemKey="OA_ErrMsgBackBillMain"; | 
 |  |  | 
 |  |  |                 ",HDescription='" + omodel.HDescription + "'" + | 
 |  |  |                 ",HHasten=" + omodel.HHasten.ToString() + | 
 |  |  |                 ",HQty=" + omodel.HQty.ToString() + | 
 |  |  |                  | 
 |  |  |                 ",HRecDeptID=" + omodel.HRecDeptID.ToString() + | 
 |  |  |                 ",HMaterNumber='" + omodel.HMaterNumber + "'" + | 
 |  |  |  | 
 |  |  |                 " where HInterID=" + lngBillKey.ToString()); | 
 |  |  |                 //删除关联 | 
 |  |  |                 DeleteRelation(ref sReturn, lngBillKey); | 
 |  |  |                 //删除子表 | 
 |  |  |                 DeleteBillSub(lngBillKey); | 
 |  |  |                 DeleteBillSub2(lngBillKey); | 
 |  |  |                 //插入子表 | 
 |  |  |                 omodel.HInterID = lngBillKey; | 
 |  |  |                 foreach (Models.ClsOA_ErrMsgBackBillSub oSub in DetailColl) | 
 |  |  | 
 |  |  |                 foreach (Models.ClsOA_ErrMsgBackBillSub2 oSubSec in DetailColl2) | 
 |  |  |                 { | 
 |  |  |                     oCn.RunProc("Insert into OA_ErrMsgBackBillSub2 " + | 
 |  |  |                       " (HInterID,HEntryID" +                       | 
 |  |  |                       ",HReceiveMan,HReadFlag" + | 
 |  |  |                       " (HInterID,HEntryID,HReceiveMan,HReadFlag" + | 
 |  |  |                       ")" + | 
 |  |  |                       " values(" | 
 |  |  |                       + omodel.HInterID.ToString() + "," + oSubSec.HEntryID.ToString() + ",'" + oSubSec.HRemark + "'" + | 
 |  |  |                       ",'" + oSubSec.HReceiveMan + "'," + Convert.ToString(oSubSec.HReadFlag ? 1 : 0) + | 
 |  |  |                       + omodel.HInterID.ToString() + "," + oSubSec.HEntryID.ToString() + ",'" + oSubSec.HReceiveMan + "'," + Convert.ToString(oSubSec.HReadFlag ? 1 : 0) + | 
 |  |  |                       ") "); | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  | 
 |  |  |                 ",HContext,HDeptID,HDescription,HSendMan,HReceiveMan" + | 
 |  |  |                 ",HCopyMan,HHasten,HLevel,HReTransmitMan,HBillTypeName"+ | 
 |  |  |                 ",HPlanBillNo,HMaterName,HMaterModel,HQty,HSendType"+ | 
 |  |  |                 ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType" + | 
 |  |  |                 ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRecDeptID,HMaterNumber" + | 
 |  |  |                 ") " + | 
 |  |  |                 " values('" + this.BillType + "','"  + this.HBillSubType + "'," +omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','" + omodel.HDate + "'" + | 
 |  |  |                 "," + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "','" + DBUtility.ClsPub.CurUserName + "',getdate()" + | 
 |  |  | 
 |  |  |                 ",'" + omodel.HCopyMan + "'," + omodel.HHasten.ToString() + ",'" + omodel.HLevel + "','" + omodel.HReTransmitMan + "','" + omodel.HBillTypeName + "'" + | 
 |  |  |                 ",'" + omodel.HPlanBillNo + "','" + omodel.HMaterName + "','" + omodel.HMaterModel + "'," + omodel.HQty.ToString() + ",'" + omodel.HSendType + "'" + | 
 |  |  |                 ",'" + omodel.HMainSourceInterID + "','" + omodel.HMainSourceEntryID + "','" + omodel.HMainSourceBillNo + "','" + omodel.HMainSourceBillType + "'" + | 
 |  |  |                 "," + omodel.HRecDeptID + ",'" + omodel.HMaterNumber + "'" + | 
 |  |  |                 ") "); | 
 |  |  |                 //插入子表 | 
 |  |  |                 //foreach (Models.ClsOA_ErrMsgBackBillSub oSub in DetailColl) | 
 |  |  | 
 |  |  |                 throw (e); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         public bool ReplyBill(ref string sReturn) | 
 |  |  |         { | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  |                 | 
 |  |  |                 //若MAINDI重复则重新获取 | 
 |  |  |                 oCn.BeginTran(); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |                 DataSet Ds = oCn.RunProcReturn("select count(HInterID) as num from OA_ErrMsgBackBillSub where HInterID = " + DetailReply.HInterID + " group by HInterID ", "OA_ErrMsgBackBillSub"); | 
 |  |  |  | 
 |  |  |                 Int64 num = 0; | 
 |  |  |  | 
 |  |  |                 if (Ds.Tables[0].Rows.Count == 0) | 
 |  |  |                 { | 
 |  |  |                     num = 1; | 
 |  |  |                 } | 
 |  |  |                 else | 
 |  |  |                 { | 
 |  |  |                     num = Convert.ToInt64(Ds.Tables[0].Rows[0]["num"]) + 1; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 //主表 | 
 |  |  |                 oCn.RunProc("Insert Into OA_ErrMsgBackBillSub   " + | 
 |  |  |                 "(HInterID,HEntryID,HRemark,HSendStatus,HSendMan" + | 
 |  |  |                 ",HDescriptionSub,HDate" + | 
 |  |  |                 ",HCloseMan,HEntryCloseDate,HCloseType,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" + | 
 |  |  |                 ") " + | 
 |  |  |                 " values(" + DetailReply.HInterID + "," + num + ",'" + DetailReply.HRemark + "'," + 1 + ",'" + DetailReply.HSendMan + "'" + | 
 |  |  |                 ",'" + DetailReply.HDescriptionSub + "','" + DetailReply.HDate + "','" + DetailReply.HCloseMan + "','" + "" + "'" + | 
 |  |  |                 "," + 0 + "," + DetailReply.HSourceInterID + "," + DetailReply.HSourceEntryID + ",'" + DetailReply.HSourceBillNo + "'" + | 
 |  |  |                 ",'" + DetailReply.HSourceBillType + "'," + DetailReply.HRelationQty + "," + DetailReply.HRelationMoney + | 
 |  |  |                 ") "); | 
 |  |  |  | 
 |  |  |                 sReturn = omodel.HInterID.ToString(); | 
 |  |  |                 oCn.Commit(); | 
 |  |  |                 return true; | 
 |  |  |             } | 
 |  |  |             catch (Exception e) | 
 |  |  |             { | 
 |  |  |                 sReturn = e.Message; | 
 |  |  |                 oCn.RollBack(); | 
 |  |  |                 throw (e); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         //删除单据 | 
 |  |  |         public virtual bool DeleteBill(Int64 lngBillKey,string HEntryID, ref string sReturn) | 
 |  |  |         { | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  |                 oCn.BeginTran(); | 
 |  |  |                 SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); | 
 |  |  |                 string sql = string.Format(@"select *  from "+MvarItemKeySub+ " where HInterID=" + lngBillKey.ToString() + " and HEntryID='" + HEntryID + "'"); | 
 |  |  |                 var dataSet = oCN.RunProcReturn(sql, ""+ MvarItemKeySub + "");                | 
 |  |  |                 //删除关联 | 
 |  |  |                 DeleteRelation(ref sReturn, lngBillKey); | 
 |  |  |                 //删除明细表 | 
 |  |  |                 oCn.RunProc("Delete From " + MvarItemKeySub + "  where HInterID=" + lngBillKey.ToString()+" and HEntryID='"+HEntryID+"'"); | 
 |  |  |                 //删除主表 | 
 |  |  |                 if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) | 
 |  |  |                 { | 
 |  |  |                     DeleteBillMain(lngBillKey); | 
 |  |  |                 } | 
 |  |  |                 sReturn = "删除单据成功!"; | 
 |  |  |                 oCn.Commit(); | 
 |  |  |                 return true; | 
 |  |  |             } | 
 |  |  |             catch (Exception e) | 
 |  |  |             { | 
 |  |  |                 sReturn = e.Message; | 
 |  |  |                 oCn.RollBack(); | 
 |  |  |                 throw (e); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         //显示单据 | 
 |  |  |         public override bool ShowBill(Int64 lngBillKey, ref string sReturn) | 
 |  |  |         { |