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

            strSql.Append("insert into OtherSellOrder(");
            strSql.Append("OtherSellOrderGuid,OtherSellOrderID,Client,OtherSellOrderDate,OutStorage,StoragePerson,QualityPerson,Remark,CreateGuid,CreateDate,CheckGuid,CheckDate");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("'" + OtherSellOrder.OtherSellOrderGuid + "',");
            strSql.Append("'" + OtherSellOrder.OtherSellOrderID + "',");
            strSql.Append("'" + OtherSellOrder.Client + "',");
            strSql.Append("'" + OtherSellOrder.OtherSellOrderDate + "',");
            strSql.Append("'" + OtherSellOrder.OutStorage + "',");
            strSql.Append("'" + OtherSellOrder.StoragePerson + "',");
            strSql.Append("'" + OtherSellOrder.QualityPerson + "',");
            strSql.Append("'" + OtherSellOrder.Remark + "',");
            strSql.Append("'" + OtherSellOrder.CreateGuid + "',");
            strSql.Append("'" + OtherSellOrder.CreateDate + "',");
            strSql.Append("'" + OtherSellOrder.CheckGuid + "',");
            if (OtherSellOrder.CheckDate == DateTime.Parse("1900-01-01"))
            {
                strSql.Append("null");
            }
            else
            {
                strSql.Append("'" + OtherSellOrder.CheckDate + "'");
            }
            strSql.Append(")");
            return(strSql.ToString());
        }
Exemple #2
0
        ///<summary>
        /// 保存数据
        /// </summary>
        /// <param name="pObj">信息集实体类</param>
        /// <returns>返回保存成功(true)或失败(false)</returns>
        public void SaveBill(OtherSellOrder OtherSellOrder, List <OtherSellOrderDetail> OtherSellOrderDetail)
        {
            CommonInterface pComm = CommonFactory.CreateInstance(CommonData.sql);

            try
            {
                pComm.BeginTrans();

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

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


                //删除明细表
                strDeleteSql = "Delete from OtherSellOrderDetail where  OtherSellOrderGuid='" + OtherSellOrder.OtherSellOrderGuid + "'";
                pComm.Execute(strDeleteSql);

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


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