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

            strSql.Append("insert into HalfGoods(");
            strSql.Append("HalfGoodsGuid,HalfGoodsID,HalfGoodsDate,Plant,IncomeDepot,TransactorPerson,SatrapPerson,QualityPerson,DepotPerson,BatchNo,Remark,CreateGuid,CreateDate,CheckGuid,CheckDate");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("'" + HalfGoods.HalfGoodsGuid + "',");
            strSql.Append("'" + HalfGoods.HalfGoodsID + "',");
            strSql.Append("'" + HalfGoods.HalfGoodsDate + "',");
            strSql.Append("'" + HalfGoods.Plant + "',");
            strSql.Append("'" + HalfGoods.IncomeDepot + "',");
            strSql.Append("'" + HalfGoods.TransactorPerson + "',");
            strSql.Append("'" + HalfGoods.SatrapPerson + "',");
            strSql.Append("'" + HalfGoods.QualityPerson + "',");
            strSql.Append("'" + HalfGoods.DepotPerson + "',");
            strSql.Append("'" + HalfGoods.BatchNo + "',");
            strSql.Append("'" + HalfGoods.Remark + "',");
            strSql.Append("'" + HalfGoods.CreateGuid + "',");
            strSql.Append("'" + HalfGoods.CreateDate + "',");
            strSql.Append("'" + HalfGoods.CheckGuid + "',");
            if (HalfGoods.CheckDate == DateTime.Parse("1900-01-01"))
            {
                strSql.Append("null");
            }
            else
            {
                strSql.Append("'" + HalfGoods.CheckDate + "'");
            }
            strSql.Append(")");
            return(strSql.ToString());
        }
Example #2
0
        ///<summary>
        /// 保存数据
        /// </summary>
        /// <param name="pObj">信息集实体类</param>
        /// <returns>返回保存成功(true)或失败(false)</returns>
        public void SaveBill(HalfGoods HalfGoods, List <HalfGoodsDetail> HalfGoodsDetail)
        {
            CommonInterface pComm = CommonFactory.CreateInstance(CommonData.sql);

            try
            {
                pComm.BeginTrans();

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

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


                //删除明细表
                strDeleteSql = "Delete from HalfGoodsDetail where  HalfGoodsGuid='" + HalfGoods.HalfGoodsGuid + "'";
                pComm.Execute(strDeleteSql);

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


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