/// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(TSBarriveDetailData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into TSBarriveDetail(");
            strSql.Append(@"arriveBillNo,financeBillNo,materialNo,num,uintQty,boxqty,boxNum,planBoxNum,isFinishReceive)");
            strSql.Append(" values (");
            strSql.Append(@"@arriveBillNo,@financeBillNo,@materialNo,@num,@uintQty,@boxqty,@boxNum,@planBoxNum,@isFinishReceive)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@arriveBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@financeBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@materialNo", SqlDbType.VarChar,50),
                    new SqlParameter("@num", SqlDbType.Float),
                    new SqlParameter("@uintQty", SqlDbType.Float),
                    new SqlParameter("@boxqty", SqlDbType.Float),
                    new SqlParameter("@boxNum", SqlDbType.Float),
                    new SqlParameter("@planBoxNum", SqlDbType.Float),
                    new SqlParameter("@isFinishReceive", SqlDbType.Bit)
                };
            parameters[0].Value = model.arriveBillNo;
            parameters[1].Value = model.financeBillNo;
            parameters[2].Value = model.materialNo;
            parameters[3].Value = model.num;
            parameters[4].Value = model.uintQty;
            parameters[5].Value = model.boxqty;
            parameters[6].Value = model.boxNum;
            parameters[7].Value = model.planBoxNum;
            parameters[8].Value = model.isFinishReceive;

            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;
        }
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(TSBarriveDetailData model)
 {
     return this.sBarriveDetailDB.ModifyRecord(model);
 }
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(TSBarriveDetailData model)
 {
     return this.sBarriveDetailDB.AddRecord(model);
 }
        /// <summary>
        /// 更新一条"TSBarriveDetail"信息
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(TSBarriveDetailData model)
        {
            bool ret = false;
            SqlTransaction trans = null;
            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransModify");
                    this.sBarriveDetailBB.Transaction = trans;
                    this.errorDiaryBB.Transaction = trans;
                    this.operatDiaryBB.Transaction = trans;
                }

                this.sBarriveDetailBB.ModifyRecord(model);

                SOperatDiaryData operatDiaryData = new SOperatDiaryData();
                operatDiaryData.empId = this.empId;
                operatDiaryData.functionId = "";
                operatDiaryData.recordId = model.id.ToString();
                operatDiaryData.operateContent = "TSBarriveDetail修改一条id为“" + model.id.ToString() + "”的记录";
                this.operatDiaryBB.AddRecord(operatDiaryData);

                if (this.transaction == null) trans.Commit();
                ret = true;
            }
            catch (Exception ex)
            {
                if (this.transaction == null) trans.Rollback("TransModify");
                SErrorDiaryData errorDiaryData = new SErrorDiaryData();
                errorDiaryData.empId = this.empId;
                errorDiaryData.functionId = "";
                errorDiaryData.errorText = "TSBarriveDetail修改记录“" + model.id.ToString() + "”时报错:" + ex.Message;
                this.errorDiaryBB.AddRecord(errorDiaryData);
                throw ex;
            }
            finally
            {
            }
            return ret;
        }
        /// <summary>
        /// 增加一条"TSBarriveDetail"信息
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(DataTable dtPlan,string arriveBillNo,string isrtDt,int isrtEmpid,string remark,string typeName)
        {
            TSBarriveDetailData model = new TSBarriveDetailData();

            int id = 0;
            SqlTransaction trans = null;
            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransAdd");
                    this.sBarriveDetailBB.Transaction = trans;

                }

                foreach (DataRow dr in dtPlan.Rows)
                {
                    model.arriveBillNo = arriveBillNo ;//其他入库单号,手动赋值
                    model.boxNum = 0.00;// 实际箱数
                    model.boxqty = double.Parse(dr["boxqty"].ToString());//整箱数量
                    model.num = double.Parse(dr["num"].ToString());//收货数量
                    model.uintQty = double.Parse(dr["unitQty"].ToString());//单体数量
                    model.planBoxNum = double.Parse(dr["planBoxNum"].ToString());//计划收货箱数
                    model.financeBillNo = dr["financeBillNo"].ToString();//采购合同号
                    model.materialNo = dr["materialNo"].ToString();//物料号
                    model.isFinishReceive = false;//开始的时候 都是false
                    id = this.sBarriveDetailBB.AddRecord(model);
                }
                string command = "Insert into TSBarriveBill (arriveBillNo,financeBillNo,isrtEmpId,isrtDt,instantState,remark,tsIntypeName) values ('" + arriveBillNo + "','" + model.financeBillNo + "'," + isrtEmpid + ",'" + isrtDt + "','01','" + remark + "','"+typeName+"')";
                 SQLHelperDM.ExecuteNonQuery(HS.Config.SqlDataObject.GetJoeyConnectionString, command);

                if (this.transaction == null) trans.Commit();
            }
            catch (Exception ex)
            {
                if (this.transaction == null) trans.Rollback("TransAdd");

                throw ex;
            }
            finally
            {

            }
            return id;
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(TSBarriveDetailData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update TSBarriveDetail set ");
            strSql.Append("arriveBillNo=@arriveBillNo,");
            strSql.Append("financeBillNo=@financeBillNo,");
            strSql.Append("materialNo=@materialNo,");
            strSql.Append("num=@num,");
            strSql.Append("uintQty=@uintQty,");
            strSql.Append("boxqty=@boxqty,");
            strSql.Append("boxNum=@boxNum,");
            strSql.Append("planBoxNum=@planBoxNum,");
            strSql.Append("isFinishReceive=@isFinishReceive");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int),
                    new SqlParameter("@arriveBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@financeBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@materialNo", SqlDbType.VarChar,50),
                    new SqlParameter("@num", SqlDbType.Float),
                    new SqlParameter("@uintQty", SqlDbType.Float),
                    new SqlParameter("@boxqty", SqlDbType.Float),
                    new SqlParameter("@boxNum", SqlDbType.Float),
                    new SqlParameter("@planBoxNum", SqlDbType.Float),
                    new SqlParameter("@isFinishReceive", SqlDbType.Bit)
                };
            parameters[0].Value = model.id;
            parameters[1].Value = model.arriveBillNo;
            parameters[2].Value = model.financeBillNo;
            parameters[3].Value = model.materialNo;
            parameters[4].Value = model.num;
            parameters[5].Value = model.uintQty;
            parameters[6].Value = model.boxqty;
            parameters[7].Value = model.boxNum;
            parameters[8].Value = model.planBoxNum;
            parameters[9].Value = model.isFinishReceive;

            try
            {
                SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);
                ret = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ret;
        }
        /// <summary>
        /// 得到一个model
        /// </summary>
        /// <returns>model</returns>
        public TSBarriveDetailData GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"select id,arriveBillNo,financeBillNo,materialNo,num,uintQty,boxqty,boxNum,planBoxNum,isFinishReceive from TSBarriveDetail");
            strSql.Append(" where id = "+id+" ");
            SqlParameter[] parameters = {

                };

            TSBarriveDetailData model = new TSBarriveDetailData();
            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["arriveBillNo"] != DBNull.Value)
                {
                    model.arriveBillNo = Convert.ToString(row["arriveBillNo"]);
                }
                if (row["financeBillNo"] != DBNull.Value)
                {
                    model.financeBillNo = Convert.ToString(row["financeBillNo"]);
                }
                if (row["materialNo"] != DBNull.Value)
                {
                    model.materialNo = Convert.ToString(row["materialNo"]);
                }
                if (row["num"] != DBNull.Value)
                {
                    model.num = Convert.ToDouble(row["num"]);
                }
                if (row["uintQty"] != DBNull.Value)
                {
                    model.uintQty = Convert.ToDouble(row["uintQty"]);
                }
                if (row["boxqty"] != DBNull.Value)
                {
                    model.boxqty = Convert.ToDouble(row["boxqty"]);
                }
                if (row["boxNum"] != DBNull.Value)
                {
                    model.boxNum = Convert.ToDouble(row["boxNum"]);
                }
                if (row["planBoxNum"] != DBNull.Value)
                {
                    model.planBoxNum = Convert.ToDouble(row["planBoxNum"]);
                }
                if (row["isFinishReceive"] != DBNull.Value)
                {
                    model.isFinishReceive = Convert.ToBoolean(row["isFinishReceive"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }
Esempio n. 8
0
    public void SaveTSArriveBox(int arriveDetailId, string strArriveBillNo, string strFinanceBillNo, string strMaterialNo,
        string strBoxNo, string strPalletNo, int factNum, int isrtEmpId, string strWareLocatorNo)
    {
        TSBarriveDetailBB arriveDetailBB = new TSBarriveDetailBB();
        BArrangeBillBoxBB arrangeBillBoxBB = new BArrangeBillBoxBB();
        SCommBB commBB = new SCommBB();

        try
        {
            TSBarriveDetailData arriveDetailModel = new TSBarriveDetailData();
            BArrangeBillBoxData arrangeBillBoxModel = new BArrangeBillBoxData();
            DataTable dtWareLocator = new DataTable();

            //获取某库位信息
            dtWareLocator = this.GetWareLocatorInfo(strWareLocatorNo);

            //获取到货单明细实例
            arriveDetailModel = arriveDetailBB.GetModel(arriveDetailId);

            arrangeBillBoxModel.arriveBillNo = strArriveBillNo;//到货单号
            arrangeBillBoxModel.financeBillNo = strFinanceBillNo;//采购单号
            //arrangeBillBoxModel.financeBillId = arriveDetailModel.financeBillId;//采购订单ID
            //arrangeBillBoxModel.financeBillLineNum = arriveDetailModel.financeBillLineNum;//采购订单行号
            arrangeBillBoxModel.materialNo = strMaterialNo;//物料号
            arrangeBillBoxModel.boxNo = strBoxNo;//箱号
            arrangeBillBoxModel.palletNo = strPalletNo;//托盘号
            arrangeBillBoxModel.wareNo = dtWareLocator.Rows[0]["wareNo"].ToString();//库区
            arrangeBillBoxModel.wareLocatorNo = strWareLocatorNo;//库位
            arrangeBillBoxModel.isBoxArrange = false;//箱子是否已经排托
            arrangeBillBoxModel.isPalletUsing = false;//托盘是否占用
            arrangeBillBoxModel.acceptEmpId = isrtEmpId;//收货人
            arrangeBillBoxModel.acceptDt = System.DateTime.Now.ToString();//收货时间
            arrangeBillBoxModel.factNum = factNum;//收货数量

            arrangeBillBoxBB.AddRecord(arrangeBillBoxModel);

            //锁定库位
            commBB.ExecuteSql("update dbo.LWareLocator set isUsing=1 where wareLocatorNo='" + strWareLocatorNo + "'");
        }
        finally
        {
            arriveDetailBB.Dispose();
            arrangeBillBoxBB.Dispose();
            commBB.Dispose();
        }
    }