/// <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>
    /// 提交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();

        }
    }
Beispiel #4
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();
        }
    }
Beispiel #5
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();
        }
    }
Beispiel #6
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();
        }
    }