Beispiel #1
0
        ///<summary>
        /// 保存数据
        /// </summary>
        /// <param name="pObj">信息集实体类</param>
        /// <returns>返回保存成功(true)或失败(false)</returns>
        public void SaveBill(FileInStorage FileInStorage, List <FileInStorageDetail> FileInStorageDetail)
        {
            CommonInterface pComm = CommonFactory.CreateInstance(CommonData.sql);

            try
            {
                pComm.BeginTrans();

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

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


                //删除明细表
                strDeleteSql = "Delete from FileInStorageDetail where  FileInStorageGuid='" + FileInStorage.FileInStorageGuID + "'";
                pComm.Execute(strDeleteSql);

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


                pComm.CommitTrans();
            }
            catch (Exception e)
            {
                pComm.RollbackTrans();
                pComm.Close();
                throw e;
            }
        }
Beispiel #2
0
        /// <summary>
        /// 得到新增sql
        /// </summary>
        public string GetAddBillSQL(FileInStorage FileInStorage)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into FileInStorage(");
            strSql.Append("FileInStorageGuID,FileInStorageID,FileInStorageDate,FileInStoragePerson,Remark,CreateGuid,CreateDate,CheckGuid,CheckDate,CheckGuid2,CheckDate2");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("'" + FileInStorage.FileInStorageGuID + "',");
            strSql.Append("'" + FileInStorage.FileInStorageID + "',");
            strSql.Append("'" + FileInStorage.FileInStorageDate + "',");
            strSql.Append("'" + FileInStorage.FileInStoragePerson + "',");
            strSql.Append("'" + FileInStorage.Remark + "',");
            strSql.Append("'" + FileInStorage.CreateGuid + "',");
            strSql.Append("'" + FileInStorage.CreateDate + "',");
            strSql.Append("'" + FileInStorage.CheckGuid + "',");
            if (FileInStorage.CheckDate == DateTime.Parse("1900-01-01"))
            {
                strSql.Append("null,");
            }
            else
            {
                strSql.Append("'" + FileInStorage.CheckDate + "',");
            }

            strSql.Append("'" + FileInStorage.CheckGuid2 + "',");
            if (FileInStorage.CheckDate2 == DateTime.Parse("1900-01-01"))
            {
                strSql.Append("null");
            }
            else
            {
                strSql.Append("'" + FileInStorage.CheckDate2 + "'");
            }

            strSql.Append(")");
            return(strSql.ToString());
        }