Exemple #1
0
        /// <summary>
        /// 得到新增sql
        /// </summary>
        public string GetAddBillSQL(RemoveBill RemoveBill)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into [RemoveBill](");
            strSql.Append("RemoveBillGuid,RemoveBillID,RemoveBillDate,DepotOut,DepotIn,HandlePerson,Remark,CreateGuid,CreateDate,CheckGuid,CheckDate");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("'" + RemoveBill.RemoveBillGuid + "',");
            strSql.Append("'" + RemoveBill.RemoveBillID + "',");
            strSql.Append("'" + RemoveBill.RemoveBillDate + "',");
            strSql.Append("'" + RemoveBill.DepotOut + "',");
            strSql.Append("'" + RemoveBill.DepotIn + "',");
            strSql.Append("'" + RemoveBill.HandlePerson + "',");
            strSql.Append("'" + RemoveBill.Remark + "',");
            strSql.Append("'" + RemoveBill.CreateGuid + "',");
            strSql.Append("'" + RemoveBill.CreateDate + "',");
            strSql.Append("'" + RemoveBill.CheckGuid + "',");
            if (RemoveBill.CheckDate == DateTime.Parse("1900-01-01"))
            {
                strSql.Append("null");
            }
            else
            {
                strSql.Append("'" + RemoveBill.CheckDate + "'");
            }
            strSql.Append(")");
            return(strSql.ToString());
        }
Exemple #2
0
        ///<summary>
        /// 保存数据
        /// </summary>
        /// <param name="pObj">信息集实体类</param>
        /// <returns>返回保存成功(true)或失败(false)</returns>
        public void SaveBill(RemoveBill RemoveBill, List <RemoveBillDetail> RemoveBillDetail)
        {
            CommonInterface pComm = CommonFactory.CreateInstance(CommonData.sql);

            try
            {
                pComm.BeginTrans();

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

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


                //删除明细表
                strDeleteSql = "Delete from RemoveBillDetail where  RemoveBillGuid='" + RemoveBill.RemoveBillGuid + "'";
                pComm.Execute(strDeleteSql);

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


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