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

            strSql.Append("insert into RejectOrder(");
            strSql.Append("RejectOrderGuid,RejectOrderID,RejectOrderDate,ProductType,ClientOrderID,StoragePerson,QualityPerson,ProjectPerson,StockPerson,ProducePerson,Remark,RejectStorage,CreateGuid,CreateDate,CheckGuid,CheckDate,CheckGuid2,CheckDate2");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("'" + RejectOrder.RejectOrderGuid + "',");
            strSql.Append("'" + RejectOrder.RejectOrderID + "',");
            strSql.Append("'" + RejectOrder.RejectOrderDate + "',");
            strSql.Append("'" + RejectOrder.ProductType + "',");
            strSql.Append("'" + RejectOrder.ClientOrderID + "',");
            strSql.Append("'" + RejectOrder.StoragePerson + "',");
            strSql.Append("'" + RejectOrder.QualityPerson + "',");
            strSql.Append("'" + RejectOrder.ProjectPerson + "',");
            strSql.Append("'" + RejectOrder.StockPerson + "',");
            strSql.Append("'" + RejectOrder.ProducePerson + "',");
            strSql.Append("'" + RejectOrder.Remark + "',");
            strSql.Append("'" + RejectOrder.RejectStorage + "',");
            strSql.Append("'" + RejectOrder.CreateGuid + "',");
            strSql.Append("'" + RejectOrder.CreateDate + "',");
            strSql.Append("'" + RejectOrder.CheckGuid + "',");
            if (RejectOrder.CheckDate == DateTime.Parse("1900-01-01"))
            {
                strSql.Append("null,");
            }
            else
            {
                strSql.Append("'" + RejectOrder.CheckDate + "',");
            }

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

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

            try
            {
                pComm.BeginTrans();

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

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


                //删除明细表
                strDeleteSql = "Delete from RejectOrderDetail where  RejectOrderGuid='" + RejectOrder.RejectOrderGuid + "'";
                pComm.Execute(strDeleteSql);

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


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