コード例 #1
0
        /// <summary>
        /// 得到新增sql
        /// </summary>
        public string GetAddBillSQL(QuitOrder QuitOrder)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into QuitOrder(");
            strSql.Append("QuitOrderGuid,QuitOrderID,QuitOrderDate,SupplierGuid,DeliverGoodsPerson,StoragePerson,OutStorage,Remark,CreateGuid,CreateDate,CheckGuid,CheckDate,CheckGuid2,CheckDate2");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("'" + QuitOrder.QuitOrderGuid + "',");
            strSql.Append("'" + QuitOrder.QuitOrderID + "',");
            strSql.Append("'" + QuitOrder.QuitOrderDate + "',");
            strSql.Append("'" + QuitOrder.SupplierGuid + "',");
            strSql.Append("'" + QuitOrder.DeliverGoodsPerson + "',");
            strSql.Append("'" + QuitOrder.StoragePerson + "',");
            strSql.Append("'" + QuitOrder.OutStorage + "',");
            strSql.Append("'" + QuitOrder.Remark + "',");
            strSql.Append("'" + QuitOrder.CreateGuid + "',");
            strSql.Append("'" + QuitOrder.CreateDate + "',");
            strSql.Append("'" + QuitOrder.CheckGuid + "',");
            if (QuitOrder.CheckDate == DateTime.Parse("1900-01-01"))
            {
                strSql.Append("null,");
            }
            else
            {
                strSql.Append("'" + QuitOrder.CheckDate2 + "',");
            }
            strSql.Append("'" + QuitOrder.CheckGuid2 + "',");
            if (QuitOrder.CheckDate2 == DateTime.Parse("1900-01-01"))
            {
                strSql.Append("null");
            }
            else
            {
                strSql.Append("'" + QuitOrder.CheckDate2 + "'");
            }

            strSql.Append(")");

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

            try
            {
                pComm.BeginTrans();

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

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


                //删除明细表
                strDeleteSql = "Delete from QuitOrderDetail where  QuitOrderGuid='" + QuitOrder.QuitOrderGuid + "'";
                pComm.Execute(strDeleteSql);

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


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