/// <summary>
    /// 到货单列表行事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void grid_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        BArriveDetailBB arriveDetailBB = new BArriveDetailBB();

        try
        {
            GridViewRow gvRow = (e.CommandSource as LinkButton).NamingContainer as GridViewRow;
            BArriveDetailData arriveDetailModel = new BArriveDetailData();

            #region 重新收货

            if (e.CommandName == "receive")
            {
                int id = Convert.ToInt32(this.grid.DataKeys[gvRow.RowIndex]["id"]);

                arriveDetailModel = arriveDetailBB.GetModel(id);

                arriveDetailModel.isFinishReceive = false;//收货未完成

                arriveDetailBB.ModifyRecord(arriveDetailModel);

                return;
            }

            #endregion 重新收货
        }
        finally
        {
            arriveDetailBB.Dispose();
        }
    }
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(BArriveDetailData model)
 {
     return this.arriveDetailDB.ModifyRecord(model);
 }
    /// <summary>
    /// 提交SAP
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnCommit_Click(object sender, EventArgs e)
    {
        DMWJEXECUTE services = new DMWJEXECUTE();
        IList<string> messList = new List<string>();
        messList.Clear();
        try
        {
            bool isChecked = false;

            //获取选中的数据Id
            foreach (GridViewRow gvrow in this.grid.Rows)
            {
                CheckBox chkId = (CheckBox)gvrow.FindControl("chkId");

                if (chkId.Checked == true)
                {
                    int financeBillId = 0, financeBillLineNum = 0;
                    string strMaterialNo = "", custNo = "", custNm = "";
                    DateTime stockDt, arriveDt;
                    double num = 0;

                    financeBillId = Convert.ToInt32(this.grid.DataKeys[gvrow.RowIndex]["financeBillId"]);
                    financeBillLineNum = Convert.ToInt32(this.grid.DataKeys[gvrow.RowIndex]["financeBillLineNum"]);
                    strMaterialNo = this.grid.DataKeys[gvrow.RowIndex]["materialNo"].ToString();
                    num = Convert.ToDouble(this.grid.DataKeys[gvrow.RowIndex]["num"]);
                    stockDt = Convert.ToDateTime(this.grid.DataKeys[gvrow.RowIndex]["stockDt"]);
                    arriveDt = Convert.ToDateTime(this.grid.DataKeys[gvrow.RowIndex]["arriveDt"]);
                    custNo = this.grid.DataKeys[gvrow.RowIndex]["custNo"].ToString();
                    custNm = this.grid.DataKeys[gvrow.RowIndex]["custNm"].ToString();

                    string mess = Convert.ToInt32(chkId.ValidationGroup).ToString() + ";" + financeBillId.ToString() + ";" + financeBillLineNum.ToString() + ";" + strMaterialNo + ";" + num.ToString() + ";" + stockDt + ";" + arriveDt + ";" + custNo + ";" + custNm;

                    messList.Add(mess);
                    //strResult = services.SAPInStock(Convert.ToInt32(chkId.ValidationGroup), financeBillId,
                    //    financeBillLineNum, strMaterialNo, num, stockDt, arriveDt, custNo, custNm);

                    //if (strResult.Split('&')[0] == "1")
                    //{
                    //    isChecked = true;
                    //}
                    //else if (strResult.Split('&')[0] == "0")
                    //{
                    //    this.BindGrid();
                    //    this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"" + strResult.Split('&')[1] + "\");", true);
                    //    return;
                    //}
                }
            }

            if (messList.Count > 0)
            {
                SapOnlineService.SapOnlineService sapService = new SapOnlineService.SapOnlineService();
                SapOnlineService.POR1[] list = new SapOnlineService.POR1[messList.Count];
                for (int i = 0; i < messList.Count; i++)
                {
                    SapOnlineService.POR1 por1 = new SapOnlineService.POR1();
                    por1.DocEntry = Convert.ToInt32(messList[i].Split(';')[1].ToString());
                    por1.LineNum = Convert.ToInt32(messList[i].Split(';')[2].ToString());
                    por1.ItemCode = messList[i].Split(';')[3].ToString();
                    por1.Quantity = Convert.ToDouble(messList[i].Split(';')[4].ToString());//数量
                    list[i] = por1;
                }
                string strResult = sapService.Web_AddPDN_For_POR1(messList[0].Split(';')[7].ToString(), messList[0].Split(';')[8].ToString(), Convert.ToDateTime(messList[0].Split(';')[5].ToString()), "由WMS同步", Convert.ToDateTime(messList[0].Split(';')[5].ToString()), "由WMS同步", Convert.ToDateTime(messList[0].Split(';')[6].ToString()), list);

                if (strResult.Split('&')[0] == "1")
                {
                    for (int i = 0; i < messList.Count; i++)
                    {
                        BArriveDetailData arriveDetailModel = new BArriveDetailData();
                        BArriveDetailBB arriveDetailBB = new BArriveDetailBB();
                        SCommBB commBB = new SCommBB();
                        arriveDetailModel = arriveDetailBB.GetModel(Convert.ToInt32(messList[i].Split(';')[0]));

                        arriveDetailModel.isSapInStock = true;//是否已提交SAP入库

                        arriveDetailBB.ModifyRecord(arriveDetailModel);

                        //更改物料箱的“是否已提交SAP入库”状态
                        commBB.ExecuteSql(@"update dbo.BArrangeBillBox set isSapInStock=1 where isSapInStock=0
                                       and inStockDt is not null and arriveBillNo='" + arriveDetailModel.arriveBillNo
                                         + "' and financeBillId='" + messList[i].Split(';')[1].ToString() + "' and financeBillLineNum='" + messList[i].Split(';')[2].ToString()
                                         + "' and materialNo='" + messList[i].Split(';')[3].ToString() + "'"
                                         +" or oldMaterialNo ='"+ messList[i].Split(';')[3].ToString() + "'"
                                         +" and  isSapInStock=0  and inStockDt is not null and arriveBillNo='" + arriveDetailModel.arriveBillNo
                                         + "' and financeBillId='" + messList[i].Split(';')[1].ToString() + "' and financeBillLineNum='" + messList[i].Split(';')[2].ToString()+"'");

                    }

                    isChecked = true;
                }
                else if (strResult.Split('&')[0] == "0")
                {
                    this.BindGrid();
                    this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"" + strResult.Split('&')[1] + "\");", true);
                    return;
                }

            }

            if (isChecked)
            {
                this.BindGrid();
                this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"SAP入库成功!\");", true);
            }
        }
        catch (Exception error)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"" + error.Message + "\");", true);
        }
        finally
        {
            services.Dispose();

        }
    }
    /// <summary>
    /// 提交按钮
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnCommit_Click(object sender, EventArgs e)
    {
        DMWJEXECUTE services = new DMWJEXECUTE();
        IList<string> messList = new List<string>();
        messList.Clear();
        try
        {
            bool isChecked = false;

            //获取选中的数据Id
            foreach (GridViewRow gvrow in this.grid.Rows)
            {
                CheckBox chkId = (CheckBox)gvrow.FindControl("chkId");

                if (chkId.Checked == true)
                {
                    int financeBillId = 0, financeBillLineNum = 0;
                    string strMaterialNo = "", custNo = "", custNm = "";
                    string financeBillNo = "";
                    DateTime stockDt, arriveDt;
                    double num = 0;
                    string SAPDocEntry = "";
                    string arrivebillNO = "";
                    //financeBillId = Convert.ToInt32(this.grid.DataKeys[gvrow.RowIndex]["financeBillId"]);
                    financeBillLineNum = Convert.ToInt32(this.grid.DataKeys[gvrow.RowIndex]["financeBillLineNum"]);
                    arrivebillNO = this.grid.DataKeys[gvrow.RowIndex]["arriveBillNo"].ToString();
                    financeBillNo = this.grid.DataKeys[gvrow.RowIndex]["financeBillNo"].ToString();
                    SAPDocEntry = arrivebillNO.Remove(0, 2);
                    strMaterialNo = this.grid.DataKeys[gvrow.RowIndex]["materialNo"].ToString();
                    num = Convert.ToDouble(this.grid.DataKeys[gvrow.RowIndex]["num"]);
                    stockDt = Convert.ToDateTime(this.grid.DataKeys[gvrow.RowIndex]["stockDt"]);
                    arriveDt = Convert.ToDateTime(this.grid.DataKeys[gvrow.RowIndex]["arriveDt"]);
                    custNo = this.grid.DataKeys[gvrow.RowIndex]["custNo"].ToString();
                    custNm = this.grid.DataKeys[gvrow.RowIndex]["custNm"].ToString();
                    SapOnlineService.SapOnlineService sapService = new SapOnlineService.SapOnlineService();
                    string strResult = sapService.IGN1_Web_Add_From_WMS(Convert.ToDateTime(stockDt), financeBillNo, int.Parse(SAPDocEntry), strMaterialNo, num, "01");

                    int id = Convert.ToInt32(chkId.ValidationGroup);
                    if (strResult.Split('&')[0] == "1")
                    {

                            BArriveDetailData arriveDetailModel = new BArriveDetailData();
                            BArriveDetailBB arriveDetailBB = new BArriveDetailBB();
                            SCommBB commBB = new SCommBB();
                            arriveDetailModel = arriveDetailBB.GetModel(id);

                            arriveDetailModel.isSapInStock = true;//是否已提交SAP入库

                            arriveDetailBB.ModifyRecord(arriveDetailModel);

                            //更改物料箱的“是否已提交SAP入库”状态
                            commBB.ExecuteSql(@"update dbo.BArrangeBillBox set isSapInStock=1 where isSapInStock=0
                                       and inStockDt is not null and arriveBillNo='" + arriveDetailModel.arriveBillNo
                                             + "'  and financeBillLineNum='" + financeBillLineNum
                                             + "' and materialNo='" +strMaterialNo + "'"
                                             + " or oldMaterialNo ='" +strMaterialNo+ "'"
                                             + " and  isSapInStock=0  and inStockDt is not null and arriveBillNo='" + arriveDetailModel.arriveBillNo
                                             + "'and financeBillLineNum='" + financeBillLineNum + "'");
                            isChecked = true;

                        }

                    else if (strResult.Split('&')[0] == "0")
                    {
                        this.BindGrid();
                        this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"" + strResult.Split('&')[1] + "\");", true);
                        return;
                    }
                }

                if (isChecked)
                {
                    this.BindGrid();
                    this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"SAP入库成功!\");", true);
                }

            }

        }
        catch (Exception error)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"" + error.Message + "\");", true);
        }
        finally
        {
            services.Dispose();

        }
    }
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(BArriveDetailData model)
 {
     return this.arriveDetailDB.AddRecord(model);
 }
        /// <summary>
        /// 增加一条数量
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(DataTable dtPlan, string arriveBillNo, string isrtDt, int isrtEmpid, string remark, string typeName)
        {
            BArriveDetailData model = new BArriveDetailData();

            int id = 0;
            SqlTransaction trans = null;
            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransAdd");
                    this.arriveDetailBB.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
                    model.isFinishReceive = false;
                    if (model.financeBillNo == "")
                    {
                        model.financeBillSort = "备货";
                    }
                    else if (model.financeBillNo.Substring(0, 4) == "EB16")
                    {
                        model.financeBillSort = "备货";
                    }
                    else
                    {
                        model.financeBillSort = "按单";
                    }
                    model.financeBillLineNum = 0;
                    model.partialBox = "0";

                    id = this.arriveDetailBB.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(BArriveDetailData model)
        {
            bool ret = false;
            SqlTransaction trans = null;
            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransModify");
                    this.arriveDetailBB.Transaction = trans;
                    this.errorDiaryBB.Transaction = trans;
                    this.operatDiaryBB.Transaction = trans;
                }

                this.arriveDetailBB.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;
        }
        //*****************************************************************************
        //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;
        }
        /// <summary>
        /// 增加一条"货单明细"信息
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(BArriveDetailData model)
        {
            int id = 0;
            SqlTransaction trans = null;
            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransAdd");
                    this.arriveDetailBB.Transaction = trans;
                    this.errorDiaryBB.Transaction = trans;
                    this.operatDiaryBB.Transaction = trans;
                }

                id = this.arriveDetailBB.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;
        }
Example #10
0
    public void FinishTSArriveDetail(int arriveDetailId)
    {
        BArriveDetailBB arriveDetailBB = new BArriveDetailBB();
        SCommBB commBB = new SCommBB();

        try
        {
            BArriveDetailData arriveDetailModel = new BArriveDetailData();
            object obj = null;
            string strArriveBillNo = "", strFinanceBillNo = "", strMaterialNo = "";

            arriveDetailModel = arriveDetailBB.GetModel(arriveDetailId);
            arriveDetailModel.isFinishReceive = true;//收货完成

            arriveDetailBB.ModifyRecord(arriveDetailModel);

            //更改到货单明细的排托数量
            strArriveBillNo = arriveDetailModel.arriveBillNo;
            strFinanceBillNo = arriveDetailModel.financeBillNo;
            strMaterialNo = arriveDetailModel.materialNo;

            obj = commBB.ExecuteScalar("select count(1) from dbo.BArrangeBillBox where arriveBillNo='"
                + strArriveBillNo + "' and financeBillNo='" + strFinanceBillNo + "' and materialNo='" + strMaterialNo + "'");
            if (obj != null)
            {
                commBB.ExecuteSql("update dbo.BarriveDetail set boxNum=" + obj.ToString() + " where id=" + arriveDetailId.ToString());
            }
        }
        finally
        {
            arriveDetailBB.Dispose();
            commBB.Dispose();
        }
    }
Example #11
0
    public bool UpdateArriveDetailWeight(int arriveDetailId, double firstBoxSingleWeight)
    {
        BArriveDetailBB arriveDetailBB = new BArriveDetailBB();

        try
        {
            BArriveDetailData arriveDetailModel = new BArriveDetailData();

            arriveDetailModel = arriveDetailBB.GetModel(arriveDetailId);
            arriveDetailModel.firstBoxSingleWeight = firstBoxSingleWeight;

            return arriveDetailBB.ModifyRecord(arriveDetailModel);
        }
        finally
        {
            arriveDetailBB.Dispose();
        }
    }
Example #12
0
    public void SaveArriveBox(int arriveDetailId, string strArriveBillNo, string strFinanceBillNo, string strMaterialNo,
        string strBoxNo, string strPalletNo, int factNum, int isrtEmpId, string strWareLocatorNo)
    {
        BArriveDetailBB arriveDetailBB = new BArriveDetailBB();
        BArrangeBillBoxBB arrangeBillBoxBB = new BArrangeBillBoxBB();
        SCommBB commBB = new SCommBB();

        try
        {
            BArriveDetailData arriveDetailModel = new BArriveDetailData();
            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();
        }
    }
Example #13
0
    public string SAPInStock(int arriveDetailId, int financeBillId, int financeBillLineNum, string strMaterialNo,
        double num, DateTime stockDt, DateTime arriveDt, string custNo, string custNm)
    {
        SapOnlineService.SapOnlineService sapService = new SapOnlineService.SapOnlineService();
        SCommBB commBB = new SCommBB();
        BArriveDetailBB arriveDetailBB = new BArriveDetailBB();

        try
        {
            SapOnlineService.POR1[] list = null;
            SapOnlineService.POR1 por1 = new SapOnlineService.POR1();
            BArriveDetailData arriveDetailModel = new BArriveDetailData();
            string strResult = "";

            //SAP入库
            //需要传递:采购订单号、行号、物料号、数量
            list = new SapOnlineService.POR1[1];

            por1.DocEntry = financeBillId;//采购订单号
            por1.LineNum = financeBillLineNum;//采购订单行号
            por1.ItemCode = strMaterialNo;//物料编号
            por1.Quantity = num;//数量

            list[0] = por1;
            strResult = sapService.Web_AddPDN_For_POR1(custNo, custNm, stockDt, "由WMS同步", stockDt, "由WMS同步", stockDt, list);
            // strResult = sapService.Web_AddPDN_For_POR1(por1.DocEntry, stockDt, "从仓库系统生成", arriveDt, list);

            if (strResult.Split('&')[0] == "1")
            {
                //更改到货中间表数据
                arriveDetailModel = arriveDetailBB.GetModel(arriveDetailId);

                arriveDetailModel.isSapInStock = true;//是否已提交SAP入库

                arriveDetailBB.ModifyRecord(arriveDetailModel);

                //更改物料箱的“是否已提交SAP入库”状态
                commBB.ExecuteSql(@"update dbo.BArrangeBillBox set isSapInStock=1 where isSapInStock=0
                                    and inStockDt is not null and arriveBillNo='" + arriveDetailModel.arriveBillNo
                                    + "' and financeBillId='" + financeBillId + "' and financeBillLineNum='" + financeBillLineNum
                                    + "' and materialNo='" + strMaterialNo + "'");
            }

            return strResult;
        }
        finally
        {
            sapService.Dispose();
            arriveDetailBB.Dispose();
            commBB.Dispose();
        }
    }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(BArriveDetailData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into BArriveDetail(");
            strSql.Append(@"arriveBillNo,financeBillSort,financeBillNo,financeBillId,financeBillLineNum,materialNo,num,partialBox,uintQty,boxqty,
                            boxNum,planBoxNum,saleBillNo,customNo,firstBoxSingleWeight,isFinishReceive,isSapInStock)");
            strSql.Append(" values (");
            strSql.Append(@"@arriveBillNo,@financeBillSort,@financeBillNo,@financeBillId,@financeBillLineNum,@materialNo,@num,@partialBox,@uintQty,@boxqty,
                            @boxNum,@planBoxNum,@saleBillNo,@customNo,@firstBoxSingleWeight,@isFinishReceive,@isSapInStock)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@arriveBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@financeBillSort", SqlDbType.NVarChar,20),
                    new SqlParameter("@financeBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@financeBillId", SqlDbType.VarChar,20),
                    new SqlParameter("@financeBillLineNum", SqlDbType.Int),
                    new SqlParameter("@materialNo", SqlDbType.VarChar,20),
                    new SqlParameter("@num", SqlDbType.Float),
                    new SqlParameter("@partialBox", SqlDbType.Char,1),
                    new SqlParameter("@uintQty", SqlDbType.Float),
                    new SqlParameter("@boxqty", SqlDbType.Float),
                    new SqlParameter("@boxNum", SqlDbType.Float),
                    new SqlParameter("@planBoxNum", SqlDbType.Float),
                    new SqlParameter("@saleBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@customNo", SqlDbType.VarChar,20),
                    new SqlParameter("@firstBoxSingleWeight", SqlDbType.Float),
                    new SqlParameter("@isFinishReceive", SqlDbType.Bit),
                    new SqlParameter("@isSapInStock", SqlDbType.Bit)
                };
            parameters[0].Value = model.arriveBillNo;
            parameters[1].Value = model.financeBillSort;
            parameters[2].Value = model.financeBillNo;
            parameters[3].Value = model.financeBillId;
            parameters[4].Value = model.financeBillLineNum;
            parameters[5].Value = model.materialNo;
            parameters[6].Value = model.num;
            parameters[7].Value = model.partialBox;
            parameters[8].Value = model.uintQty;
            parameters[9].Value = model.boxqty;
            parameters[10].Value = model.boxNum;
            parameters[11].Value = model.planBoxNum;
            parameters[12].Value = model.saleBillNo;
            parameters[13].Value = model.customNo;
            parameters[14].Value = model.firstBoxSingleWeight;
            parameters[15].Value = model.isFinishReceive;
            parameters[16].Value = model.isSapInStock;

            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(BArriveDetailData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update BArriveDetail set ");
            strSql.Append("arriveBillNo=@arriveBillNo,");
            strSql.Append("financeBillSort=@financeBillSort,");
            strSql.Append("financeBillNo=@financeBillNo,");
            strSql.Append("financeBillId=@financeBillId,");
            strSql.Append("financeBillLineNum=@financeBillLineNum,");
            strSql.Append("materialNo=@materialNo,");
            strSql.Append("num=@num,");
            strSql.Append("partialBox=@partialBox,");
            strSql.Append("uintQty=@uintQty,");
            strSql.Append("boxqty=@boxqty,");
            strSql.Append("boxNum=@boxNum,");
            strSql.Append("planBoxNum=@planBoxNum,");
            strSql.Append("saleBillNo=@saleBillNo,");
            strSql.Append("customNo=@customNo,");
            strSql.Append("firstBoxSingleWeight=@firstBoxSingleWeight,");
            strSql.Append("isFinishReceive=@isFinishReceive,");
            strSql.Append("isSapInStock=@isSapInStock");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int),
                    new SqlParameter("@arriveBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@financeBillSort", SqlDbType.NVarChar,20),
                    new SqlParameter("@financeBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@financeBillId", SqlDbType.VarChar,20),
                    new SqlParameter("@financeBillLineNum", SqlDbType.Int),
                    new SqlParameter("@materialNo", SqlDbType.VarChar,20),
                    new SqlParameter("@num", SqlDbType.Float),
                    new SqlParameter("@partialBox", SqlDbType.Char,1),
                    new SqlParameter("@uintQty", SqlDbType.Float),
                    new SqlParameter("@boxqty", SqlDbType.Float),
                    new SqlParameter("@boxNum", SqlDbType.Float),
                    new SqlParameter("@planBoxNum", SqlDbType.Float),
                    new SqlParameter("@saleBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@customNo", SqlDbType.VarChar,20),
                    new SqlParameter("@firstBoxSingleWeight", SqlDbType.Float),
                    new SqlParameter("@isFinishReceive", SqlDbType.Bit),
                    new SqlParameter("@isSapInStock", SqlDbType.Bit)
                };
            parameters[0].Value = model.id;
            parameters[1].Value = model.arriveBillNo;
            parameters[2].Value = model.financeBillSort;
            parameters[3].Value = model.financeBillNo;
            parameters[4].Value = model.financeBillId;
            parameters[5].Value = model.financeBillLineNum;
            parameters[6].Value = model.materialNo;
            parameters[7].Value = model.num;
            parameters[8].Value = model.partialBox;
            parameters[9].Value = model.uintQty;
            parameters[10].Value = model.boxqty;
            parameters[11].Value = model.boxNum;
            parameters[12].Value = model.planBoxNum;
            parameters[13].Value = model.saleBillNo;
            parameters[14].Value = model.customNo;
            parameters[15].Value = model.firstBoxSingleWeight;
            parameters[16].Value = model.isFinishReceive;
            parameters[17].Value = model.isSapInStock;

            try
            {
                SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);
                ret = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ret;
        }
        /// <summary>
        /// 得到一个model
        /// </summary>
        /// <param name="id">主键值</param>
        /// <returns>model</returns>
        public BArriveDetailData GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"select id,arriveBillNo,financeBillSort,financeBillNo,financeBillId,financeBillLineNum,materialNo,num,partialBox,uintQty,boxqty,
                            boxNum,planBoxNum,saleBillNo,customNo,firstBoxSingleWeight,isFinishReceive,isSapInStock from BArriveDetail");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int)
                };
            parameters[0].Value = id;

            BArriveDetailData model = new BArriveDetailData();
            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["financeBillSort"] != DBNull.Value)
                {
                    model.financeBillSort = Convert.ToString(row["financeBillSort"]);
                }
                if (row["financeBillNo"] != DBNull.Value)
                {
                    model.financeBillNo = Convert.ToString(row["financeBillNo"]);
                }
                if (row["financeBillId"] != DBNull.Value)
                {
                    model.financeBillId = Convert.ToString(row["financeBillId"]);
                }
                if (row["financeBillLineNum"] != DBNull.Value)
                {
                    model.financeBillLineNum = Convert.ToInt32(row["financeBillLineNum"]);
                }
                if (row["materialNo"] != DBNull.Value)
                {
                    model.materialNo = Convert.ToString(row["materialNo"]);
                }
                if (row["num"] != DBNull.Value)
                {
                    model.num = Convert.ToDouble(row["num"]);
                }
                if (row["partialBox"] != DBNull.Value)
                {
                    model.partialBox = Convert.ToString(row["partialBox"]);
                }
                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["saleBillNo"] != DBNull.Value)
                {
                    model.saleBillNo = Convert.ToString(row["saleBillNo"]);
                }
                if (row["customNo"] != DBNull.Value)
                {
                    model.customNo = Convert.ToString(row["customNo"]);
                }
                if (row["firstBoxSingleWeight"] != DBNull.Value)
                {
                    model.firstBoxSingleWeight = Convert.ToDouble(row["firstBoxSingleWeight"]);
                }
                if (row["isFinishReceive"] != DBNull.Value)
                {
                    model.isFinishReceive = Convert.ToBoolean(row["isFinishReceive"]);
                }
                if (row["isSapInStock"] != DBNull.Value)
                {
                    model.isSapInStock = Convert.ToBoolean(row["isSapInStock"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }