Ejemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(BTallyBillDetailData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into BTallyBillDetail(");
            strSql.Append(@"mainId,region,oldPalletNo,boxNo,isrtEmpId,isrtDt)");
            strSql.Append(" values (");
            strSql.Append(@"@mainId,@region,@oldPalletNo,@boxNo,@isrtEmpId,@isrtDt)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@mainId", SqlDbType.VarChar,20),
                    new SqlParameter("@region", SqlDbType.VarChar,10),
                    new SqlParameter("@oldPalletNo", SqlDbType.VarChar,20),
                    new SqlParameter("@boxNo", SqlDbType.VarChar,20),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int),
                    new SqlParameter("@isrtDt", SqlDbType.DateTime)
                };
            parameters[0].Value = model.mainId;
            parameters[1].Value = model.region;
            parameters[2].Value = model.oldPalletNo;
            parameters[3].Value = model.boxNo;
            parameters[4].Value = model.isrtEmpId;
            parameters[5].Value = model.isrtDt == string.Empty ? null : model.isrtDt;

            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;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(BTallyBillDetailData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update BTallyBillDetail set ");
            strSql.Append("mainId=@mainId,");
            strSql.Append("region=@region,");
            strSql.Append("oldPalletNo=@oldPalletNo,");
            strSql.Append("boxNo=@boxNo,");
            strSql.Append("isrtEmpId=@isrtEmpId,");
            strSql.Append("isrtDt=@isrtDt");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int),
                    new SqlParameter("@mainId", SqlDbType.VarChar,20),
                    new SqlParameter("@region", SqlDbType.VarChar,10),
                    new SqlParameter("@oldPalletNo", SqlDbType.VarChar,20),
                    new SqlParameter("@boxNo", SqlDbType.VarChar,20),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int),
                    new SqlParameter("@isrtDt", SqlDbType.DateTime)
                };
            parameters[0].Value = model.id;
            parameters[1].Value = model.mainId;
            parameters[2].Value = model.region;
            parameters[3].Value = model.oldPalletNo;
            parameters[4].Value = model.boxNo;
            parameters[5].Value = model.isrtEmpId;
            parameters[6].Value = model.isrtDt == string.Empty ? null : model.isrtDt;

            try
            {
                SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);
                ret = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ret;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(BTallyBillDetailData model)
 {
     return this.tallyBillDetailDB.ModifyRecord(model);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个model
        /// </summary>
        /// <param name="id">主键值</param>
        /// <returns>model</returns>
        public BTallyBillDetailData GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"select id,mainId,region,oldPalletNo,boxNo,isrtEmpId,isrtDt from BTallyBillDetail");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int)
                };
            parameters[0].Value = id;

            BTallyBillDetailData model = new BTallyBillDetailData();
            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["mainId"] != DBNull.Value)
                {
                    model.mainId = Convert.ToString(row["mainId"]);
                }
                if (row["region"] != DBNull.Value)
                {
                    model.region = Convert.ToString(row["region"]);
                }
                if (row["oldPalletNo"] != DBNull.Value)
                {
                    model.oldPalletNo = Convert.ToString(row["oldPalletNo"]);
                }
                if (row["boxNo"] != DBNull.Value)
                {
                    model.boxNo = Convert.ToString(row["boxNo"]);
                }
                if (row["isrtEmpId"] != DBNull.Value)
                {
                    model.isrtEmpId = Convert.ToInt32(row["isrtEmpId"]);
                }
                if (row["isrtDt"] != DBNull.Value)
                {
                    model.isrtDt = Convert.ToString(row["isrtDt"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(BTallyBillDetailData model)
 {
     return this.tallyBillDetailDB.AddRecord(model);
 }
Ejemplo n.º 6
0
        //*****************************************************************************
        //do it later      do it later      do it later
        //*****************************************************************************
        /// <summary>
        /// 保存称重理货明细信息,同时更改箱子称重数据
        /// </summary>
        /// <param name="mainId">称重理货单ID</param>
        /// <param name="regionId">区域ID</param>
        /// <param name="strNewPalletNo">新托盘条码号</param>
        /// <param name="strOldPalletNo">原托盘号</param>
        /// <param name="strBoxNo">箱号</param>
        /// <param name="weight">称重重量</param>
        /// <param name="factNum">实际数量</param>
        /// <param name="arriveDetailId">到货单明细ID</param>
        /// <param name="firstBoxSingleWeight">首箱单重</param>
        /// <param name="tallyNoPassReasonId">理货不合格原因</param>
        /// <returns></returns>
        public bool SaveRecord(int mainId, int regionId, string strNewPalletNo, string strOldPalletNo, string strBoxNo,
            float weight, int factNum, int arriveDetailId, double firstBoxSingleWeight, int tallyNoPassReasonId)
        {
            bool ret = false;
            SqlTransaction trans = null;
            SCommBB commBB = new SCommBB(this.connection);
            BArriveDetailBB arriveDetailBB = new BArriveDetailBB(this.connection);
            BArrangeBillBoxBB arrangeBillBoxBB = new BArrangeBillBoxBB(this.connection);

            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransSave");
                    this.tallyBillDetailBB.Transaction = trans;
                    commBB.Transaction = trans;
                    arriveDetailBB.Transaction = trans;
                    arrangeBillBoxBB.Transaction = trans;
                }
                else
                {
                    this.tallyBillDetailBB.Transaction = this.transaction;
                    commBB.Transaction = this.transaction;
                    arriveDetailBB.Transaction = this.transaction;
                    arrangeBillBoxBB.Transaction = this.transaction;
                }

                DataSet ds = new DataSet();
                DataTable dtArrangeBillBox = new DataTable();
                BTallyBillDetailData tallyBillDetailModel = new BTallyBillDetailData();
                StringBuilder strSql = new StringBuilder();
                DataTable dtWareLocator = new DataTable();

                //保存称重理货明细数据
                if (mainId != 0)
                {
                    tallyBillDetailModel.mainId = mainId.ToString();//称重理货单ID
                    tallyBillDetailModel.region = regionId.ToString();//区域ID
                    tallyBillDetailModel.oldPalletNo = strOldPalletNo;//原托盘号
                    tallyBillDetailModel.boxNo = strBoxNo;//箱号
                    tallyBillDetailModel.isrtDt = System.DateTime.Now.ToString();//添加时间
                    tallyBillDetailModel.isrtEmpId = this.empId;//添加人

                    tallyBillDetailBB.AddRecord(tallyBillDetailModel);

                    //获取排托区下线库位信息
                    strSql.Append(@"select wareLocator.wareNo,wareLocator.downWareLocatorNo as wareLocatorNo ");
                    strSql.Append(@"from dbo.BArrangeBillBox as arrangeBillBoxBox ");
                    strSql.Append(@"left join dbo.LWareLocator as wareLocator on wareLocator.wareLocatorNo=arrangeBillBoxBox.wareLocatorNo ");
                    strSql.Append(@"where arrangeBillBoxBox.boxNo='" + strBoxNo + "'");

                    dtWareLocator = commBB.Query(strSql.ToString()).Tables[0];
                    if (dtWareLocator.Rows.Count > 0
                        && dtWareLocator.Rows[0]["wareLocatorNo"] != DBNull.Value
                        && dtWareLocator.Rows[0]["wareLocatorNo"].ToString() != "")
                    {
                        dtArrangeBillBox = arrangeBillBoxBB.GetVList("boxNo='" + strBoxNo + "'").Tables[0];
                        //首先将语句完整后 再将数据传递到后台当中

                        string command = "update dbo.BArrangeBillBox set preWareLocatorNo=wareLocatorNo,wareLocatorNo='" + dtWareLocator.Rows[0]["wareLocatorNo"].ToString() + "',weight='" + weight.ToString()
                            + "',factNum=factNum-" + Convert.ToString(Convert.ToInt32(dtArrangeBillBox.Rows[0]["leavingNum"]) + Convert.ToInt32(dtArrangeBillBox.Rows[0]["DEPickOutNum"]) - factNum)
                            + ",oldPalletNo=palletNo,oldRegion=region,palletNo='" + strNewPalletNo
                            + "',region='" + regionId.ToString() + "',noPassReasonId='" + tallyNoPassReasonId.ToString() + "' where boxNo='" + strBoxNo + "'";

                        if(command.Contains("--"))
                        {
                            command =command.Replace("--", "+");
                        }
                        //更改箱子称重重量和实际数量
                        //commBB.ExecuteSql(command);
                        string conn = "Data Source=172.16.0.160;Initial Catalog=GMWJ;User=wms;Password=sasa";
                        try
                        {
                            SQLHelperDM.ExecuteNonQuery(conn, command);
                        }
                        catch (Exception ee)
                        {
                            string errorRecord = "Insert into SqlText values ('" + ee.Message + "','Hello World','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')";
                            SQLHelperDM.ExecuteNonQuery(conn, errorRecord);//在数据库表当中增加相应的判断错误处理,因为在程序运行当中经常出现将数据全部更改的错误
                            ret = false;

                            //在此处将所有的插入数据存储到一个表当中 用来进行记录
                        }

                        string record = "Insert into SqlText values ('" +command.Replace('\'',' ') + "','你好','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')";
                        SQLHelperDM.ExecuteNonQuery(conn, record);//在数据库表当中增加相应的判断错误处理,因为在程序运行当中经常出现将数据全部更改的错误
                    }

                    //更改到货单明细的首箱单重
                    if (firstBoxSingleWeight == 0)
                    {
                        BArriveDetailData arriveDetailModel = new BArriveDetailData();

                        arriveDetailModel = arriveDetailBB.GetModel(arriveDetailId);

                        if (arriveDetailModel != null)
                        {
                            arriveDetailModel.firstBoxSingleWeight = Math.Round(weight / factNum, 4);

                            arriveDetailBB.ModifyRecord(arriveDetailModel);
                        }
                    }
                }
                else
                {
                    ret = false;
                    throw new Exception("保存错误,不存在理货单!");
                }

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

            return ret;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 保存非标准箱从质检区入库信息
        /// </summary>
        /// <param name="strPalletNo">托盘条码号</param>
        /// <param name="strNextWareNo">目的库区编码</param>
        /// <param name="strNextWareLocatorNo">目的库位编码</param>
        /// <returns></returns>
        public bool SaveNoStandBoxInStockInfo(string strPalletNo, string strNextWareNo, string strNextWareLocatorNo)
        {
            bool ret = false;
            SqlTransaction trans = null;
            SCommBB commBB = new SCommBB(this.connection);
            BTallyBillBB tallyBillBB = new BTallyBillBB(this.connection);
            BArrangeBillBoxBB arrangeBillBoxBB = new BArrangeBillBoxBB(this.connection);
            BForkliftTaskBB forkliftTaskBB = new BForkliftTaskBB(this.connection);

            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransSave");
                    this.tallyBillDetailBB.Transaction = trans;
                    commBB.Transaction = trans;
                    tallyBillBB.Transaction = trans;
                    arrangeBillBoxBB.Transaction = trans;
                    forkliftTaskBB.Transaction = trans;
                }
                else
                {
                    this.tallyBillDetailBB.Transaction = this.transaction;
                    commBB.Transaction = this.transaction;
                    tallyBillBB.Transaction = this.transaction;
                    arrangeBillBoxBB.Transaction = this.transaction;
                    forkliftTaskBB.Transaction = this.transaction;
                }

                int mainId = 0;
                StringBuilder strSql = new StringBuilder();
                DataTable dtArrangeBillBox = new DataTable();
                BTallyBillData tallyBillModel = new BTallyBillData();
                BTallyBillDetailData tallyBillDetailModel = new BTallyBillDetailData();
                BForkliftTaskData forkliftTaskModel = new BForkliftTaskData();

                //保存理货信息
                tallyBillModel = new BTallyBillData();

                tallyBillModel.palletNo = strPalletNo;//托盘条码号
                tallyBillModel.isInStock = false;//是否入库
                tallyBillModel.isrtDt = System.DateTime.Now.ToString();//添加时间
                tallyBillModel.isrtEmpId = this.empId;//添加人
                tallyBillModel.instantState = "02";//理货完成

                mainId = tallyBillBB.AddRecord(tallyBillModel);//称重理货单ID赋值

                dtArrangeBillBox = arrangeBillBoxBB.GetList("palletNo='" + strPalletNo + "' and isnull(wareNo,'')<>''").Tables[0];
                foreach (DataRow row in dtArrangeBillBox.Rows)
                {
                    //保存称重理货明细数据
                    tallyBillDetailModel = new BTallyBillDetailData();

                    tallyBillDetailModel.mainId = mainId.ToString();//称重理货单ID
                    tallyBillDetailModel.region = "0";//区域ID
                    tallyBillDetailModel.oldPalletNo = strPalletNo;//原托盘号
                    tallyBillDetailModel.boxNo = row["boxNo"].ToString();//箱号
                    tallyBillDetailModel.isrtDt = System.DateTime.Now.ToString();//添加时间
                    tallyBillDetailModel.isrtEmpId = this.empId;//添加人

                    tallyBillDetailBB.AddRecord(tallyBillDetailModel);
                }

                //生成叉车任务
                if (dtArrangeBillBox.Rows.Count > 0)
                {
                    forkliftTaskModel = new BForkliftTaskData();

                    forkliftTaskModel.taskType = "11";//任务类型为:从质检区到正式区
                    forkliftTaskModel.palletNo = strPalletNo;//托盘号
                    forkliftTaskModel.preWareNo = dtArrangeBillBox.Rows[0]["wareNo"].ToString();//源库区
                    forkliftTaskModel.preLocatorNo = dtArrangeBillBox.Rows[0]["wareLocatorNo"].ToString();//源库位
                    forkliftTaskModel.nextWareNo = strNextWareNo;//目的库区
                    forkliftTaskModel.nextLocatorNo = strNextWareLocatorNo;//目的库位
                    forkliftTaskModel.effectDt = System.DateTime.Now.ToString();//生效时间
                    forkliftTaskModel.isDeal = false;//是否处理

                    forkliftTaskBB.AddRecord(forkliftTaskModel);

                    //更新目的库区占用状态
                    if (strNextWareLocatorNo != "")
                    {
                        //更改库位的使用状态
                        commBB.ExecuteSql("update dbo.LWareLocator set isUsing=1 where wareLocatorNo='"
                            + strNextWareLocatorNo + "'");
                    }
                }

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

            return ret;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 更新一条"称重理货单明细"信息
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(BTallyBillDetailData model)
        {
            bool ret = false;
            SqlTransaction trans = null;
            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransModify");
                    this.tallyBillDetailBB.Transaction = trans;
                    this.errorDiaryBB.Transaction = trans;
                    this.operatDiaryBB.Transaction = trans;
                }

                this.tallyBillDetailBB.ModifyRecord(model);

                SOperatDiaryData operatDiaryData = new SOperatDiaryData();
                operatDiaryData.empId = this.empId;
                operatDiaryData.functionId = "";
                operatDiaryData.recordId = model.id.ToString();
                operatDiaryData.operateContent = "称重理货单明细修改一条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 = "称重理货单明细修改记录“" + model.id.ToString() + "”时报错:" + ex.Message;
                this.errorDiaryBB.AddRecord(errorDiaryData);
                throw ex;
            }
            finally
            {
            }
            return ret;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 增加一条"称重理货单明细"信息
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(BTallyBillDetailData model)
        {
            int id = 0;
            SqlTransaction trans = null;
            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransAdd");
                    this.tallyBillDetailBB.Transaction = trans;
                    this.errorDiaryBB.Transaction = trans;
                    this.operatDiaryBB.Transaction = trans;
                }

                id = this.tallyBillDetailBB.AddRecord(model);

                SOperatDiaryData operatDiaryData = new SOperatDiaryData();
                operatDiaryData.empId = this.empId;
                operatDiaryData.functionId = "";
                operatDiaryData.recordId = id.ToString();
                operatDiaryData.operateContent = "称重理货单明细增加一条id为“" + id.ToString() + "”的记录";
                this.operatDiaryBB.AddRecord(operatDiaryData);

                if (this.transaction == null) trans.Commit();
            }
            catch (Exception ex)
            {
                if (this.transaction == null) trans.Rollback("TransAdd");
                SErrorDiaryData errorDiaryData = new SErrorDiaryData();
                errorDiaryData.empId = this.empId;
                errorDiaryData.functionId = "";
                errorDiaryData.errorText = "称重理货单明细增加记录时报错:" + ex.Message;
                this.errorDiaryBB.AddRecord(errorDiaryData);
                throw ex;
            }
            finally
            {
            }
            return id;
        }