Пример #1
0
        /// <summary>
        /// 得到新增sql
        /// </summary>
        public string GetAddBillSQL(FileApply FileApply)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into FileApply(");
            strSql.Append("FileApplyGuID,FileApplyID,FileApplyDate,FileApplyType,FileApplyPerson,FileApplyDept,Remark,CreateGuid,CreateDate,CheckGuid,CheckDate ");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("'" + FileApply.FileApplyGuID + "',");
            strSql.Append("'" + FileApply.FileApplyID + "',");
            strSql.Append("'" + FileApply.FileApplyDate + "',");
            strSql.Append("'" + FileApply.FileApplyType + "',");
            strSql.Append("'" + FileApply.FileApplyPerson + "',");
            strSql.Append("'" + FileApply.FileApplyDept + "',");
            strSql.Append("'" + FileApply.Remark + "',");
            strSql.Append("'" + FileApply.CreateGuid + "',");
            strSql.Append("'" + FileApply.CreateDate + "',");
            strSql.Append("'" + FileApply.CheckGuid + "',");
            if (FileApply.CheckDate == DateTime.Parse("1900-01-01"))
            {
                strSql.Append("null");
            }
            else
            {
                strSql.Append("'" + FileApply.CheckDate + "'");
            }


            strSql.Append(")");
            return(strSql.ToString());
        }
Пример #2
0
        ///<summary>
        /// 保存数据
        /// </summary>
        /// <param name="pObj">信息集实体类</param>
        /// <returns>返回保存成功(true)或失败(false)</returns>
        public void SaveBill(FileApply FileApply, List <FileApplyDetail> FileApplyDetail, List <FileApplyPersonDetail> lstFileApplyPersonDetail)
        {
            CommonInterface pComm = CommonFactory.CreateInstance(CommonData.sql);

            try
            {
                pComm.BeginTrans();

                //保存单据主表数据
                //先删除主表数据
                string strDeleteSql = "Delete from FileApply where  FileApplyGuid='" + FileApply.FileApplyGuID + "'";
                pComm.Execute(strDeleteSql);

                //插入主表数据
                string strInsertSql = GetAddBillSQL(FileApply);
                pComm.Execute(strInsertSql);


                //删除明细表
                strDeleteSql = "Delete from FileApplyDetail where  FileApplyGuid='" + FileApply.FileApplyGuID + "'";
                pComm.Execute(strDeleteSql);

                //插入明细表数据
                for (int i = 0; i < FileApplyDetail.Count; i++)
                {
                    strInsertSql = GetAddBillDetailSQL(FileApplyDetail[i]);
                    pComm.Execute(strInsertSql);
                }

                //删除申请人员明细
                strDeleteSql = "Delete from FileApplyPersonDetail where  FileApplyGuid='" + FileApply.FileApplyGuID + "'";
                pComm.Execute(strDeleteSql);



                //插入申请人员明细
                for (int i = 0; i < lstFileApplyPersonDetail.Count; i++)
                {
                    strInsertSql = GetAddBillPersonDetailSQL(lstFileApplyPersonDetail[i]);
                    pComm.Execute(strInsertSql);
                }


                pComm.CommitTrans();
            }
            catch (Exception e)
            {
                pComm.RollbackTrans();
                pComm.Close();
                throw e;
            }
        }