Exemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(BBackDetailData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into BBackDetail(");
            strSql.Append(@"backBillNo,boxNo,backNum)");
            strSql.Append(" values (");
            strSql.Append(@"@backBillNo,@boxNo,@backNum)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@backBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@boxNo", SqlDbType.VarChar,20),
                    new SqlParameter("@backNum", SqlDbType.Int)
                };
            parameters[0].Value = model.backBillNo;
            parameters[1].Value = model.boxNo;
            parameters[2].Value = model.backNum;

            int id = 0;
            try
            {
                object ret = SqlHelper.ExecuteScalar(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

                if (ret != null && ret != DBNull.Value)
                {
                    id = Convert.ToInt32(ret);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return id;
        }
Exemplo n.º 2
0
        //*****************************************************************************
        //do it later      do it later      do it later
        //*****************************************************************************
        /// <summary>
        /// 保存退货单信息
        /// </summary>
        /// <param name="dtBox">退货箱</param>
        /// <param name="strFinanceBillNo">采购订单编号</param>
        /// <param name="strCustNo">供应商编码</param>
        /// <param name="strMaterialNo">物料编码</param>
        /// <returns></returns>
        public bool SaveRecord(DataTable dtBox, string strFinanceBillNo, string strCustNo, string strMaterialNo,string checkRemark)
        {
            bool ret = false;
            BBackDetailBB backDetailBB = new BBackDetailBB(this.connection);
            SqlTransaction trans = null;

            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransSave");
                    this.backBillBB.Transaction = trans;
                    backDetailBB.Transaction = trans;
                }
                else
                {
                    this.backBillBB.Transaction = this.transaction;
                    backDetailBB.Transaction = this.transaction;
                }

                BBackBillData backBillModel = new BBackBillData();
                BBackDetailData backDetailModel = new BBackDetailData();

                //保存退货单信息
                backBillModel.backBillNo = this.backBillBB.GetCurrentBackBillNoByPreBillNo();//退货单编号
                backBillModel.financeBillNo = strFinanceBillNo;//采购订单号
                backBillModel.custNo = strCustNo;//供应商
                backBillModel.materialNo = strMaterialNo;//物料编号
                backBillModel.backDt = System.DateTime.Today.ToString();//退货日期
                backBillModel.isrtDt = System.DateTime.Now.ToString();//添加时间
                backBillModel.isrtEmpId = this.empId;//添加人
                backBillModel.instantState = "01";//状态:01 未提交

                //2015-07-28 修改 增加质检的remark
                //this.backBillBB.AddRecord(backBillModel);
                this.backBillBB.AddRecordWihtRemark(backBillModel, checkRemark);
                //保存退货单明细信息
                foreach (DataRow dataRow in dtBox.Rows)
                {
                    backDetailModel = new BBackDetailData();

                    backDetailModel.backBillNo = backBillModel.backBillNo;//退货单编号
                    backDetailModel.boxNo = dataRow["boxNo"].ToString();//箱号
                    backDetailModel.backNum = Convert.ToInt32(dataRow["num"]);//退货数量

                    backDetailBB.AddRecord(backDetailModel);
                }

                if (this.transaction == null) trans.Commit();
                ret = true;
            }
            catch (Exception ex)
            {
                if (this.transaction == null) trans.Rollback("TransSave");
                throw ex;
            }
            finally
            {
                backDetailBB.Dispose();
            }

            return ret;
        }
Exemplo n.º 3
0
        /// <summary>
        /// 修改退货单信息
        /// 2015-07-28 新增修改remark的功能
        /// </summary>
        /// <param name="backBillModel">备货单实例</param>
        /// <param name="dtBox">退货箱</param>
        /// <returns></returns>
        public bool ModityRecord(BBackBillData backBillModel, DataTable dtBox,string fukingbuyerRemark)
        {
            bool ret = false;
            BBackDetailBB backDetailBB = new BBackDetailBB(this.connection);
            SqlTransaction trans = null;

            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransSave");
                    this.backBillBB.Transaction = trans;
                    backDetailBB.Transaction = trans;
                }
                else
                {
                    this.backBillBB.Transaction = this.transaction;
                    backDetailBB.Transaction = this.transaction;
                }

                BBackDetailData backDetailModel = new BBackDetailData();

                //保存退货单信息
                //2015-07-28修改
               // this.backBillBB.ModifyRecord(backBillModel);
                this.backBillBB.ModifyRecord(backBillModel,fukingbuyerRemark);

                //保存退货单明细信息
                foreach (DataRow dataRow in dtBox.Rows)
                {
                    if (Convert.ToBoolean(dataRow["isDel"]) == true)
                    {
                        backDetailBB.DeleteRecord(Convert.ToInt32(dataRow["id"]));
                    }
                }

                if (this.transaction == null) trans.Commit();
                ret = true;
            }
            catch (Exception ex)
            {
                if (this.transaction == null) trans.Rollback("TransSave");
                throw ex;
            }
            finally
            {
                backDetailBB.Dispose();
            }

            return ret;
        }
Exemplo n.º 4
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(BBackDetailData model)
 {
     return this.backDetailDB.ModifyRecord(model);
 }
Exemplo n.º 5
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(BBackDetailData model)
 {
     return this.backDetailDB.AddRecord(model);
 }
Exemplo n.º 6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(BBackDetailData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update BBackDetail set ");
            strSql.Append("backBillNo=@backBillNo,");
            strSql.Append("boxNo=@boxNo,");
            strSql.Append("backNum=@backNum");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int),
                    new SqlParameter("@backBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@boxNo", SqlDbType.VarChar,20),
                    new SqlParameter("@backNum", SqlDbType.Int)
                };
            parameters[0].Value = model.id;
            parameters[1].Value = model.backBillNo;
            parameters[2].Value = model.boxNo;
            parameters[3].Value = model.backNum;

            try
            {
                SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);
                ret = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ret;
        }
Exemplo n.º 7
0
        /// <summary>
        /// 得到一个model
        /// </summary>
        /// <param name="id">主键值</param>
        /// <returns>model</returns>
        public BBackDetailData GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"select id,backBillNo,boxNo,backNum from BBackDetail");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int)
                };
            parameters[0].Value = id;

            BBackDetailData model = new BBackDetailData();
            DataSet ds = SqlHelper.ExecuteDataset(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow row = ds.Tables[0].Rows[0];
                if (row["id"] != DBNull.Value)
                {
                    model.id = Convert.ToInt32(row["id"]);
                }
                if (row["backBillNo"] != DBNull.Value)
                {
                    model.backBillNo = Convert.ToString(row["backBillNo"]);
                }
                if (row["boxNo"] != DBNull.Value)
                {
                    model.boxNo = Convert.ToString(row["boxNo"]);
                }
                if (row["backNum"] != DBNull.Value)
                {
                    model.backNum = Convert.ToInt32(row["backNum"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }