/// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(CSaleDetailData model)
 {
     return this.saleDetailDB.AddRecord(model);
 }
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(CSaleDetailData model)
 {
     return this.saleDetailDB.ModifyRecord(model);
 }
Beispiel #3
0
    public string SAPOutStock(int saleDetailId, int docEntry, int lineNum, string strMaterialNo, double num, string strInvoiceNo, String palletNO)
    {
        SapOnlineService.SapOnlineService sapService = new SapOnlineService.SapOnlineService();
        CSaleDetailBB saleDetailBB = new CSaleDetailBB();

        try
        {
            SapOnlineService.DLN1New[] list = null;
            SapOnlineService.DLN1New por1 = new SapOnlineService.DLN1New();
            CSaleDetailData saleDetailModel = new CSaleDetailData();
            string strResult = "";

            //生成SAP出库单
            //需要传递:销售订单ID、行号、物料号、数量
            list = new SapOnlineService.DLN1New[1];

            por1.DocEntry = docEntry;
            por1.LineNum = lineNum;
            por1.ItemCode = strMaterialNo;
            por1.Quantity = num;

            list[0] = por1;

            //strResult = sapService.AddODLN(por1.DocEntry, System.DateTime.Today, "从仓库系统生成", strInvoiceNo, list);

            ////更改销售中间表数据
            //if (strResult.Split('&')[0] == "1")
            //{
            //    saleDetailModel = saleDetailBB.GetModel(saleDetailId);

            //    //首先要进行判断在CstockUpdetail当中是否所有的数据都已经是‘06’状态,新增06状态用于表示SAP出库已近完成
            //    //首先是将状态从05改为06,然后再进行别的处理

            //    CStockUpDetailBB bb = new CStockUpDetailBB();
            //    bb.ModifyRecord("06",palletNO);//首先将05的状态改成06 然后
            //    if (bb.GetStatus(saleDetailId))
            //    {
            //    saleDetailModel.isSapOutStock = true;//是否已提交SAP出库
            //    saleDetailBB.ModifyRecord(saleDetailModel);
            //    }
            //}

            return strResult;
        }
        finally
        {
            sapService.Dispose();
            saleDetailBB.Dispose();
        }
    }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(CSaleDetailData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into CSaleDetail(");
            strSql.Append(@"saleBillNo,materialNo,shipDate,wareNo,SubCatNum,num,partialBox,uintQty,boxqty,boxNum,
                            instantState,AbsEntry,DocEntry,financeBillNo,lineNum,financeBillSort,isSapOutStock)");
            strSql.Append(" values (");
            strSql.Append(@"@saleBillNo,@materialNo,@shipDate,@wareNo,@SubCatNum,@num,@partialBox,@uintQty,@boxqty,@boxNum,
                            @instantState,@AbsEntry,@DocEntry,@financeBillNo,@lineNum,@financeBillSort,@isSapOutStock)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@saleBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@materialNo", SqlDbType.VarChar,20),
                    new SqlParameter("@shipDate", SqlDbType.DateTime),
                    new SqlParameter("@wareNo", SqlDbType.VarChar,20),
                    new SqlParameter("@SubCatNum", 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("@instantState", SqlDbType.VarChar,10),
                    new SqlParameter("@AbsEntry", SqlDbType.Int),
                    new SqlParameter("@DocEntry", SqlDbType.Int),
                    new SqlParameter("@financeBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@lineNum", SqlDbType.Int),
                    new SqlParameter("@financeBillSort", SqlDbType.NVarChar,20),
                    new SqlParameter("@isSapOutStock", SqlDbType.Bit)
                };
            parameters[0].Value = model.saleBillNo;
            parameters[1].Value = model.materialNo;
            parameters[2].Value = model.shipDate == string.Empty ? null : model.shipDate;
            parameters[3].Value = model.wareNo;
            parameters[4].Value = model.SubCatNum;
            parameters[5].Value = model.num;
            parameters[6].Value = model.partialBox;
            parameters[7].Value = model.uintQty;
            parameters[8].Value = model.boxqty;
            parameters[9].Value = model.boxNum;
            parameters[10].Value = model.instantState;
            parameters[11].Value = model.AbsEntry;
            parameters[12].Value = model.DocEntry;
            parameters[13].Value = model.financeBillNo;
            parameters[14].Value = model.lineNum;
            parameters[15].Value = model.financeBillSort;
            parameters[16].Value = model.isSapOutStock;

            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(CSaleDetailData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update CSaleDetail set ");
            strSql.Append("saleBillNo=@saleBillNo,");
            strSql.Append("materialNo=@materialNo,");
            strSql.Append("shipDate=@shipDate,");
            strSql.Append("wareNo=@wareNo,");
            strSql.Append("SubCatNum=@SubCatNum,");
            strSql.Append("num=@num,");
            strSql.Append("partialBox=@partialBox,");
            strSql.Append("uintQty=@uintQty,");
            strSql.Append("boxqty=@boxqty,");
            strSql.Append("boxNum=@boxNum,");
            strSql.Append("instantState=@instantState,");
            strSql.Append("AbsEntry=@AbsEntry,");
            strSql.Append("DocEntry=@DocEntry,");
            strSql.Append("financeBillNo=@financeBillNo,");
            strSql.Append("lineNum=@lineNum,");
            strSql.Append("financeBillSort=@financeBillSort,");
            strSql.Append("isSapOutStock=@isSapOutStock");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int),
                    new SqlParameter("@saleBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@materialNo", SqlDbType.VarChar,20),
                    new SqlParameter("@shipDate", SqlDbType.DateTime),
                    new SqlParameter("@wareNo", SqlDbType.VarChar,20),
                    new SqlParameter("@SubCatNum", 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("@instantState", SqlDbType.VarChar,10),
                    new SqlParameter("@AbsEntry", SqlDbType.Int),
                    new SqlParameter("@DocEntry", SqlDbType.Int),
                    new SqlParameter("@financeBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@lineNum", SqlDbType.Int),
                    new SqlParameter("@financeBillSort", SqlDbType.NVarChar,20),
                    new SqlParameter("@isSapOutStock", SqlDbType.Bit)
                };
            parameters[0].Value = model.id;
            parameters[1].Value = model.saleBillNo;
            parameters[2].Value = model.materialNo;
            parameters[3].Value = model.shipDate == string.Empty ? null : model.shipDate;
            parameters[4].Value = model.wareNo;
            parameters[5].Value = model.SubCatNum;
            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.instantState;
            parameters[12].Value = model.AbsEntry;
            parameters[13].Value = model.DocEntry;
            parameters[14].Value = model.financeBillNo;
            parameters[15].Value = model.lineNum;
            parameters[16].Value = model.financeBillSort;
            parameters[17].Value = model.isSapOutStock;

            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 CSaleDetailData GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"select id,saleBillNo,materialNo,shipDate,wareNo,SubCatNum,num,partialBox,uintQty,boxqty,boxNum,
                            instantState,AbsEntry,DocEntry,financeBillNo,lineNum,financeBillSort,isSapOutStock from CSaleDetail");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int)
                };
            parameters[0].Value = id;

            CSaleDetailData model = new CSaleDetailData();
            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["saleBillNo"] != DBNull.Value)
                {
                    model.saleBillNo = Convert.ToString(row["saleBillNo"]);
                }
                if (row["materialNo"] != DBNull.Value)
                {
                    model.materialNo = Convert.ToString(row["materialNo"]);
                }
                if (row["shipDate"] != DBNull.Value)
                {
                    model.shipDate = Convert.ToString(row["shipDate"]);
                }
                if (row["wareNo"] != DBNull.Value)
                {
                    model.wareNo = Convert.ToString(row["wareNo"]);
                }
                if (row["SubCatNum"] != DBNull.Value)
                {
                    model.SubCatNum = Convert.ToString(row["SubCatNum"]);
                }
                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["instantState"] != DBNull.Value)
                {
                    model.instantState = Convert.ToString(row["instantState"]);
                }
                if (row["AbsEntry"] != DBNull.Value)
                {
                    model.AbsEntry = Convert.ToInt32(row["AbsEntry"]);
                }
                if (row["DocEntry"] != DBNull.Value)
                {
                    model.DocEntry = Convert.ToInt32(row["DocEntry"]);
                }
                if (row["financeBillNo"] != DBNull.Value)
                {
                    model.financeBillNo = Convert.ToString(row["financeBillNo"]);
                }
                if (row["lineNum"] != DBNull.Value)
                {
                    model.lineNum = Convert.ToInt32(row["lineNum"]);
                }
                if (row["financeBillSort"] != DBNull.Value)
                {
                    model.financeBillSort = Convert.ToString(row["financeBillSort"]);
                }
                if (row["isSapOutStock"] != DBNull.Value)
                {
                    model.isSapOutStock = Convert.ToBoolean(row["isSapOutStock"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }
    /// <summary>
    /// 提交SAP
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnCommit_Click(object sender, EventArgs e)
    {
        CSaleDetailBB saleDetailBB = new CSaleDetailBB();
        DMWJEXECUTE services = new DMWJEXECUTE();
        IList<string> messList = new List<string>();
        IList<string> datalist = 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)
                {
                    string strMaterialNo = "", strInvoiceNo = "", palletNO = "", custNo = "", custNm = "", outdata = ""; ;
                    int docEntry = 0, lineNum = 0;
                    double num = 0;
                    bool isSapOutstock = true;
                    CSaleDetailData saleDetailModel = new CSaleDetailData();

                    docEntry = Convert.ToInt32(this.grid.DataKeys[gvrow.RowIndex]["docEntry"].ToString());
                    lineNum = Convert.ToInt32(this.grid.DataKeys[gvrow.RowIndex]["lineNum"].ToString());
                    strMaterialNo = this.grid.DataKeys[gvrow.RowIndex]["materialNo"].ToString();
                    num = Convert.ToDouble(this.grid.DataKeys[gvrow.RowIndex]["num"]);
                    strInvoiceNo = this.grid.DataKeys[gvrow.RowIndex]["invoiceNo"].ToString();
                    palletNO = this.grid.DataKeys[gvrow.RowIndex]["palletNo"].ToString();
                   // palletNO = "1";
                    custNo = this.grid.DataKeys[gvrow.RowIndex]["custNo"].ToString();
                    custNm = this.grid.DataKeys[gvrow.RowIndex]["custNm"].ToString();
                    outdata = this.grid.DataKeys[gvrow.RowIndex]["outStockDt"].ToString();
                    string suid = this.grid.DataKeys[gvrow.RowIndex]["suid"].ToString();
                    //获取销售单明细实例
                    saleDetailModel = saleDetailBB.GetModel(Convert.ToInt32(chkId.ValidationGroup));

                    if (Convert.ToBoolean(saleDetailModel.isSapOutStock) == false)
                    {
                        isSapOutstock = false;
                    }

                    if (isSapOutstock == true)
                    {
                        this.BindGrid();
                        this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"当前到货单下的物料已经提交SAP入库!\");", true);
                        return;
                    }

                    string mess = docEntry + ";" + lineNum + ";"  + strMaterialNo + ";"  + num +";" + strInvoiceNo+";"+Convert.ToString(Convert.ToInt32(chkId.ValidationGroup))+";"+palletNO+";"+custNo+";"+custNm+";"+outdata+";"+suid;
                    messList.Add(mess);
                    datalist.Add(mess);
                    //if (datalist.Count == 0)
                    //{
                    //    datalist.Add(docEntry.ToString() + lineNum.ToString());
                    //}
                    //else
                    //{

                    //    int m = 0;
                    //    for (int i = 0; i < datalist.Count; i++)
                    //    {
                    //        if (docEntry.ToString() + lineNum.ToString() == datalist[i].ToString().ToString())
                    //        {
                    //            m = 1;
                    //            break;
                    //        }

                    //    }
                    //    if (m == 0)
                    //    {
                    //        datalist.Add(docEntry.ToString() + lineNum.ToString());
                    //    }

                    //}

                   // strResult = services.SAPOutStock(Convert.ToInt32(chkId.ValidationGroup), docEntry, lineNum, strMaterialNo, num, strInvoiceNo, palletNO);

                    //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)
            {
                try
                {
                    IList<string> newMessList = new List<string>();

                    for (int j = 0; j < datalist.Count; j++)
                    {
                        int num =0;
                        for(int i=0;i<messList.Count;i++)
                        {

                            if ((datalist[j].Split(';')[0].ToString() + datalist[j].Split(';')[1].ToString() + datalist[j].Split(';')[2].ToString() ) == (messList[i].Split(';')[0].ToString() + messList[i].Split(';')[1].ToString() + messList[i].Split(';')[2].ToString() ))
                            {
                                num=num+Convert.ToInt32(messList[i].Split(';')[3].ToString());
                               //num =Convert.ToInt32(messList[i].Split(';')[3].ToString());

                                //datalist[i].Split(';')[3] =Convert.ToString(Convert.ToInt32(datalist[i].Split(';')[3].ToString())+Convert.ToInt32(messList[i].Split(';')[3].ToString()));
                            }
                        }
                        string compare =datalist[j].Split(';')[0].ToString() + ";" + datalist[j].Split(';')[1].ToString() + ";" + datalist[j].Split(';')[2].ToString() + ";" + num + ";" + datalist[j].Split(';')[4].ToString() + ";" + datalist[j].Split(';')[5].ToString() + ";" + datalist[j].Split(';')[6].ToString() + ";" + datalist[j].Split(';')[7].ToString() + ";" + datalist[j].Split(';')[8].ToString() + ";" + datalist[j].Split(';')[9].ToString();
                        //datalist[j].Split(';')[3] =Convert.ToString(num);
                        if (newMessList.Count == 0)
                        {
                            newMessList.Add(compare);
                        }
                        else
                        {
                            int nn = 0;
                            for (int m = 0; m < newMessList.Count; m++)
                            {
                                if ((newMessList[m].Split(';')[0].ToString() + newMessList[m].Split(';')[1].ToString() + newMessList[m].Split(';')[2].ToString()) == (compare.Split(';')[0].ToString() + compare.Split(';')[1].ToString() + compare.Split(';')[2].ToString()))
                                {
                                    nn = 1;
                                    break;
                                }

                            }
                            if (nn == 0)
                            {
                                newMessList.Add(compare);
                            }
                        }

                    }

                        SapOnlineService.SapOnlineService sapService = new SapOnlineService.SapOnlineService();
                        SapOnlineService.DLN1New[] list = new SapOnlineService.DLN1New[newMessList.Count];

                        for (int i = 0; i < newMessList.Count; i++)
                        {
                            SapOnlineService.DLN1New por1 = new SapOnlineService.DLN1New();
                            por1.DocEntry = Convert.ToInt32(newMessList[i].Split(';')[0].ToString());
                            por1.LineNum = Convert.ToInt32(newMessList[i].Split(';')[1].ToString());
                            por1.ItemCode = newMessList[i].Split(';')[2].ToString();
                            por1.Quantity = Convert.ToInt32(newMessList[i].Split(';')[3].ToString());
                            list[i] = por1;
                        }

                      string strResult = sapService.AddODLN(newMessList[0].Split(';')[7].ToString(), newMessList[0].Split(';')[8].ToString(), Convert.ToDateTime(newMessList[0].Split(';')[9].ToString()), "由WMS同步", Convert.ToDateTime(newMessList[0].Split(';')[9].ToString()), "由WMS同步", newMessList[0].Split(';')[4].ToString(), list);

                        if (strResult.Split('&')[0] == "1")

                        {
                            for (int i = 0; i < datalist.Count; i++)
                            {
                                CSaleDetailData saleDetailModel = new CSaleDetailData();
                                saleDetailModel = saleDetailBB.GetModel(Convert.ToInt32(datalist[i].Split(';')[5]));

                                //首先要进行判断在CstockUpdetail当中是否所有的数据都已经是‘06’状态,新增06状态用于表示SAP出库已近完成
                                //首先是将状态从05改为06,然后再进行别的处理

                                CStockUpDetailBB bb = new CStockUpDetailBB();

                                bb.ModifyRecord1("06", datalist[i].Split(';')[10]);
                                //bb.ModifyRecord("06", datalist[i].Split(';')[6]);//首先将05的状态改成06 然后
                                if (bb.GetStatus(Convert.ToInt32(datalist[i].Split(';')[5])))
                                {
                                    saleDetailModel.isSapOutStock = true;//是否已提交SAP出库
                                    saleDetailBB.ModifyRecord(saleDetailModel);
                                }
                            }
                            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);
                        }

                        // this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"" + datalist[j].ToString() + "\");", true);

                        //SapOnlineService.SapOnlineService sapService = new SapOnlineService.SapOnlineService();

                        //SapOnlineService.DLN1New[] list = new SapOnlineService.DLN1New[messList.Count];
                        //IList<string> newMessList = new List<string>();
                        //for (int i = 0; i < messList.Count; i++)
                        //{
                        //    if (Convert.ToDateTime(messList[i].Split(';')[9].ToString()).ToString("yyyy-MM-dd") == datalist[j].ToString())
                        //    {
                        //        newMessList.Add(messList[i]);
                        //    }
                        //}
                        //SapOnlineService.SapOnlineService sapService = new SapOnlineService.SapOnlineService();
                        //SapOnlineService.DLN1New[] list = new SapOnlineService.DLN1New[newMessList.Count];

                        //for (int i = 0; i < newMessList.Count; i++)
                        //{
                        //    SapOnlineService.DLN1New por1 = new SapOnlineService.DLN1New();
                        //    por1.DocEntry = Convert.ToInt32(newMessList[i].Split(';')[0].ToString());
                        //    por1.LineNum = Convert.ToInt32(newMessList[i].Split(';')[1].ToString());
                        //    por1.ItemCode = newMessList[i].Split(';')[2].ToString();
                        //    por1.Quantity = Convert.ToInt32(newMessList[i].Split(';')[3].ToString());
                        //    list[i] = por1;
                        //}
                        //string strResult = sapService.AddODLN(newMessList[0].Split(';')[7].ToString(), newMessList[0].Split(';')[8].ToString(), Convert.ToDateTime(newMessList[0].Split(';')[9].ToString()), "由WMS同步", Convert.ToDateTime(newMessList[0].Split(';')[9].ToString()), "由WMS同步", newMessList[0].Split(';')[4].ToString(), list);
                        //if (strResult.Split('&')[0] == "1")
                        //{

                        //    for (int i = 0; i < newMessList.Count; i++)
                        //    {
                        //        CSaleDetailData saleDetailModel = new CSaleDetailData();
                        //        saleDetailModel = saleDetailBB.GetModel(Convert.ToInt32(newMessList[i].Split(';')[5]));

                        //        //首先要进行判断在CstockUpdetail当中是否所有的数据都已经是‘06’状态,新增06状态用于表示SAP出库已近完成
                        //        //首先是将状态从05改为06,然后再进行别的处理

                        //        CStockUpDetailBB bb = new CStockUpDetailBB();
                        //        bb.ModifyRecord("06", newMessList[i].Split(';')[6]);//首先将05的状态改成06 然后
                        //        if (bb.GetStatus(Convert.ToInt32(newMessList[i].Split(';')[5])))
                        //        {
                        //            saleDetailModel.isSapOutStock = true;//是否已提交SAP出库
                        //            saleDetailBB.ModifyRecord(saleDetailModel);
                        //        }
                        //    }
                       // isChecked = true;
                    //    }
                    //    //else if (strResult.Split('&')[0] == "0")
                    //    //{
                    //    //    isChecked = false;
                    //    //    this.BindGrid();
                    //    //    this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"日期是" + newMessList[0].Split(';')[9].ToString() + "的数据没有同步成功,SAP返回:"+strResult+"\");", true);
                    //    //    return;
                    //    //}
                    //}

                    //if (isChecked)
                    //{
                    //    this.BindGrid();
                    //    this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"SAP出库成功!\");", true);
                    //}
                }
                catch { }
            }
            else if (messList.Count == 0)
            {
                this.BindGrid();
                this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"对不起你没有选择数据!\");", true);
            }

            //if(messList.Count>0)
            //{
            //    SapOnlineService.SapOnlineService sapService = new SapOnlineService.SapOnlineService();

            //    SapOnlineService.DLN1New[] list = new SapOnlineService.DLN1New[messList.Count];
            //    for (int i = 0; i < messList.Count; i++)
            //    {
            //        SapOnlineService.DLN1New por1 = new SapOnlineService.DLN1New();
            //        por1.DocEntry = Convert.ToInt32(messList[i].Split(';')[0].ToString());
            //        por1.LineNum = Convert.ToInt32(messList[i].Split(';')[1].ToString());
            //        por1.ItemCode = messList[i].Split(';')[2].ToString();
            //        por1.Quantity = Convert.ToInt32(messList[i].Split(';')[3].ToString());
            //        list[i] = por1;
            //    }

            //    string strResult = sapService.AddODLN(messList[0].Split(';')[7].ToString(), messList[0].Split(';')[8].ToString(), Convert.ToDateTime(messList[0].Split(';')[9].ToString()), "由WMS同步", Convert.ToDateTime(messList[0].Split(';')[9].ToString()), "由WMS同步", messList[0].Split(';')[4].ToString(), list);
            //    // string strResult = sapService.AddODLN(Convert.ToInt32(messList[0].Split(';')[0].ToString()), System.DateTime.Today, "从仓库系统生成", messList[0].Split(';')[4].ToString(), list);
            //    // string  strResult = services.SAPOutStock(Convert.ToInt32(chkId.ValidationGroup), docEntry, lineNum, strMaterialNo, num, strInvoiceNo, palletNO);

            //    if (strResult.Split('&')[0] == "1")
            //    {

            //        for (int i = 0; i < messList.Count; i++)
            //        {
            //            CSaleDetailData saleDetailModel = new CSaleDetailData();
            //            saleDetailModel = saleDetailBB.GetModel(Convert.ToInt32(messList[i].Split(';')[5]));

            //            //首先要进行判断在CstockUpdetail当中是否所有的数据都已经是‘06’状态,新增06状态用于表示SAP出库已近完成
            //            //首先是将状态从05改为06,然后再进行别的处理

            //            CStockUpDetailBB bb = new CStockUpDetailBB();
            //            bb.ModifyRecord("06", messList[i].Split(';')[6]);//首先将05的状态改成06 然后
            //            if (bb.GetStatus(Convert.ToInt32(messList[i].Split(';')[5])))
            //            {
            //                saleDetailModel.isSapOutStock = true;//是否已提交SAP出库
            //                saleDetailBB.ModifyRecord(saleDetailModel);
            //            }
            //        }
            //        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);
            //    }
            //}
            //else if (messList.Count == 0)
            //{
            //    this.BindGrid();
            //    this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"对不起你没有选择数据!\");", true);
            //}

        }
        finally
        {
            saleDetailBB.Dispose();
            services.Dispose();
        }
    }