1
wangbin
2024-07-08 4548e24916ac5f63eef736cabdcd634864f8de16
DAL/ÐÅϢƽ̨/ClsOA_WorkLinkBill.cs
@@ -266,9 +266,129 @@
                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);
            }
        }
    }
}