Esempio n. 1
0
        /// <summary>
        /// 得到新增sql
        /// </summary>
        public string GetAddCheckBillSQL(CheckBill CheckBill)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into [CheckBill](");
            strSql.Append("CheckBillGuid,CreatePerson,CreateDate,CheckPerson,CheckDate,Remark,BillAutoID,BillDate,Depot,HandlePerson,BillID");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("'" + CheckBill.CheckBillGuid + "',");
            strSql.Append("'" + CheckBill.CreatePerson + "',");
            strSql.Append("'" + CheckBill.CreateDate + "',");
            strSql.Append("'" + CheckBill.CheckPerson + "',");
            if (CheckBill.CheckDate == DateTime.Parse("1900-01-01"))
            {
                strSql.Append("null,");
            }
            else
            {
                strSql.Append("'" + CheckBill.CheckDate + "',");
            }

            strSql.Append("'" + CheckBill.Remark + "',");
            strSql.Append("'" + CheckBill.BillAutoID + "',");
            strSql.Append("'" + CheckBill.BillDate + "',");
            strSql.Append("'" + CheckBill.Depot + "',");
            strSql.Append("'" + CheckBill.HandlePerson + "',");
            strSql.Append("'" + CheckBill.BillID + "'");
            strSql.Append(")");
            return(strSql.ToString());
        }
Esempio n. 2
0
        ///<summary>
        /// 保存数据
        /// </summary>
        /// <param name="pObj">信息集实体类</param>
        /// <returns>返回保存成功(true)或失败(false)</returns>
        public void SaveCheckBill(CheckBill CheckBill, List <CheckBillDetail> CheckBillDetail)
        {
            CommonInterface pComm = CommonFactory.CreateInstance(CommonData.sql);

            try
            {
                pComm.BeginTrans();

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

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


                //删除明细表
                strDeleteSql = "Delete from CheckBillDetail where  CheckBillGuid='" + CheckBill.CheckBillGuid + "'";
                pComm.Execute(strDeleteSql);

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


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