Пример #1
0
        /// <summary>
        /// 得到新增sql
        /// </summary>
        public string GetAddBillSQL(ConsignOut ConsignOut)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ConsignOut(");
            strSql.Append("ConsignOutGuid,ConsignOutID,ConsignOutDate,Plant,OutcomeDepot,TransactorPerson,SatrapPerson,QualityPerson,DepotPerson,ArriveDate,InUnit,SupplierGuid,Remark,CreateGuid,CreateDate,CheckGuid,CheckDate");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("'" + ConsignOut.ConsignOutGuid + "',");
            strSql.Append("'" + ConsignOut.ConsignOutID + "',");
            strSql.Append("'" + ConsignOut.ConsignOutDate + "',");
            strSql.Append("'" + ConsignOut.Plant + "',");
            strSql.Append("'" + ConsignOut.OutcomeDepot + "',");
            strSql.Append("'" + ConsignOut.TransactorPerson + "',");
            strSql.Append("'" + ConsignOut.SatrapPerson + "',");
            strSql.Append("'" + ConsignOut.QualityPerson + "',");
            strSql.Append("'" + ConsignOut.DepotPerson + "',");
            strSql.Append("'" + ConsignOut.ArriveDate + "',");
            strSql.Append("'" + ConsignOut.InUnit + "',");
            strSql.Append("'" + ConsignOut.SupplierGuid + "',");
            strSql.Append("'" + ConsignOut.Remark + "',");
            strSql.Append("'" + ConsignOut.CreateGuid + "',");
            strSql.Append("'" + ConsignOut.CreateDate + "',");
            strSql.Append("'" + ConsignOut.CheckGuid + "',");
            if (ConsignOut.CheckDate == DateTime.Parse("1900-01-01"))
            {
                strSql.Append("null");
            }
            else
            {
                strSql.Append("'" + ConsignOut.CheckDate + "'");
            }
            strSql.Append(")");
            return(strSql.ToString());
        }
Пример #2
0
        ///<summary>
        /// 保存数据
        /// </summary>
        /// <param name="pObj">信息集实体类</param>
        /// <returns>返回保存成功(true)或失败(false)</returns>
        public void SaveBill(ConsignOut ConsignOut, List <ConsignOutDetail> ConsignOutDetail)
        {
            CommonInterface pComm = CommonFactory.CreateInstance(CommonData.sql);

            try
            {
                pComm.BeginTrans();

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

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


                //删除明细表
                strDeleteSql = "Delete from ConsignOutDetail where  ConsignOutGuid='" + ConsignOut.ConsignOutGuid + "'";
                pComm.Execute(strDeleteSql);

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


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