Exemplo n.º 1
0
        private void tsbtnAnalysis_Click(object sender, EventArgs e)
        {
            //清除原数据
            TruncateTmpTable();
            var cWaveOrder     = tstxtcWaveOrderNumber.Text.ToUpper();
            var cWaveNumberMd5 = GetMd5OrderService(cWaveOrder);



            var strOrder = string.Empty;
            var strBody  = string.Empty;
            //通过WebService获取报单系统数据
            var js = new OrderService.WMS();

            js.Url = Properties.Settings.Default.JWMSY_OrderService_WMS;
            DataTable dt;

            try
            {
                strOrder = js.GetBatchRunno(cWaveOrder, cWaveNumberMd5);


                strBody = strOrder.Substring(strOrder.IndexOf("<root>") + 6, strOrder.IndexOf("</root>") - strOrder.IndexOf("<head>") - 7);

                dt = CXmlFileToDataSet(strBody).Tables[0];
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + strOrder + js.Url, @"Warning");
                return;
            }

            var cGuid = Guid.NewGuid().ToString();

            for (var i = 0; i < dt.Rows.Count; i++)
            {
                SaveOrderList(cWaveOrder, dt.Rows[i][0].ToString(), cGuid);
            }


            sds.OrderListDetail.Clear();
            sds.OrderListDetailSecond.Clear();
            //分析波次数据
            //GetWave(tstxtcGuid.Text);

            //取产品数据
            GetInventory(cGuid, sds.OrderListDetail);
            //获取订单数据
            var dtOrderNumber = GetOrderList(cGuid);

            sds.OrderListDetailSecond.Rows.Clear();

            pbMain.Maximum = sds.OrderListDetail.Rows.Count - 1;
            for (var i = 0; i < sds.OrderListDetail.Rows.Count; i++)
            {
                pbMain.Value = i;
                Application.DoEvents();
                var cInvCode = sds.OrderListDetail.Rows[i]["cInvCode"].ToString();
                var bFirst   = true;
                for (var j = 0; j < dtOrderNumber.Rows.Count; j++)
                {
                    var cOrderNumber = dtOrderNumber.Rows[j]["cOrderNumber"].ToString();
                    var dtQuantity   = GetInvAndQuantity(cInvCode, cOrderNumber, cGuid);
                    if (dtQuantity.Rows.Count > 0)
                    {
                        var dr = sds.OrderListDetailSecond.NewOrderListDetailSecondRow();

                        if (bFirst)
                        {
                            dr.cInvCode  = sds.OrderListDetail.Rows[i]["cInvCode"].ToString();
                            dr.iQuantity = sds.OrderListDetail.Rows[i]["iQuantity"].ToString();
                            dr.cInvName  = sds.OrderListDetail.Rows[i]["cInvName"].ToString();
                        }
                        bFirst = false; dr.cOrderNumber = cOrderNumber;

                        dr.iOrderQuantity = dtQuantity.Rows[0]["iQuantity"].ToString();
                        dr.cCusName       = dtQuantity.Rows[0]["cCusName"].ToString();

                        dr.iBox = string.IsNullOrEmpty(dtQuantity.Rows[0]["iBox"].ToString())
                            ? ""
                            : dtQuantity.Rows[0]["iBox"].ToString();
                        dr.iTa = dtQuantity.Rows[0]["iTa"].ToString().Equals("0")
                            ? ""
                            : dtQuantity.Rows[0]["iTa"].ToString();

                        dr.iOdd = dtQuantity.Rows[0]["iOdd"].Equals("0") || string.IsNullOrEmpty(dtQuantity.Rows[0]["iOdd"].ToString())
                            ? ""
                            : dtQuantity.Rows[0]["iOdd"].ToString();
                        sds.OrderListDetailSecond.Rows.Add(dr);
                    }
                }
            }
            uGridOrderMain.DataSource = sds.OrderListDetailSecond;
            //var data = from a in sds.OrderListDetailSecond
            //               group a by new { a.cInvCode, a.cInvName }
            //               into b
            //               select new {GroupId = b.Key.cInvCode,
            //                   Id = b.Key.cInvCode,
            //                   cSumBox = b.Sum(c => c.iBox),
            //                   cUnionBox = b.Sum(c => c.iOdd)
            //               };

            //uGridOrderMain.DataSource = sds.OrderListDetailSecond;

            //ugWave.DataSource = data;

            //分析波次数据
            GetUnionBox(cGuid);
        }
Exemplo n.º 2
0
        private void SaveOrderList(string cWaveOrderNumber, string cOrderNumber, string cGuid)
        {
            var ckNo    = cOrderNumber;
            var ckNoMd5 = GetMd5OrderService(ckNo);



            var strOrder  = string.Empty;
            var strHeader = string.Empty;
            var strBody   = string.Empty;
            //通过WebService获取报单系统数据
            var js = new OrderService.WMS();

            js.Url = Properties.Settings.Default.JWMSY_OrderService_WMS;
            DataTable dtHeader;
            DataTable dtBody;

            try
            {
                strOrder = js.GetProductDetail2(ckNo, ckNoMd5);
                if (!strOrder.Contains("<head>"))
                {
                    MessageBox.Show("无法连接到下载服务器!" + strOrder + js.Url + ckNoMd5 + ckNo, @"Warning");
                    return;
                }
                strHeader = strOrder.Substring(strOrder.IndexOf("<head>"), strOrder.IndexOf("</head>") - strOrder.IndexOf("<head>") + 7);
                strBody   = strOrder.Remove(strOrder.IndexOf("<head>"), strOrder.IndexOf("</head>") - strOrder.IndexOf("<head>") + 7);
                dtHeader  = CXmlFileToDataSet(strHeader).Tables[0];
                dtBody    = CXmlFileToDataSet(strBody).Tables[0];
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + strOrder + js.Url + ckNoMd5 + ckNo, @"Warning");
                return;
            }



            if (dtBody == null || dtHeader == null)
            {
                MessageBox.Show(@"下载出错,请联系管理员", @"Warning");
                return;
            }


            if (dtBody.Rows.Count < 1 || dtHeader.Rows.Count < 1)
            {
                MessageBox.Show(@"无此出库单号!", @"Warning");
                return;
            }
            var xname = dtHeader.Rows[0]["xname"].ToString();
            var addr  = dtHeader.Rows[0]["addr"].ToString();
            var KH    = dtHeader.Rows[0]["KH"].ToString();

            var wf = new WmsFunction(BaseStructure.WmsCon);

            //进行循环判断是否属于当前库区
            for (var i = 0; i < dtBody.Rows.Count; i++)
            {
                var cmd = new SqlCommand
                {
                    CommandText = "insert into Tmp_OrderList(cGuid,cWaveOrderNumber,cOrderNumber,cInvCode,cInvName,iQuantity,cCusName,cCusAddress,cCardNumber) values(@cGuid,@cWaveOrderNumber,@cOrderNumber,@cInvCode,@cInvName,@iQuantity,@cCusName,@cCusAddress,@cCardNumber)"
                };
                cmd.Parameters.AddWithValue("@cGuid", cGuid);
                cmd.Parameters.AddWithValue("@cWaveOrderNumber", cWaveOrderNumber);
                cmd.Parameters.AddWithValue("@cOrderNumber", ckNo);
                cmd.Parameters.AddWithValue("@cInvCode", dtBody.Rows[i]["erpNo"].ToString());
                cmd.Parameters.AddWithValue("@cInvName", dtBody.Rows[i]["pName"].ToString());
                cmd.Parameters.AddWithValue("@iQuantity", dtBody.Rows[i]["Num"].ToString());
                cmd.Parameters.AddWithValue("@cCusName", xname);
                cmd.Parameters.AddWithValue("@cCusAddress", addr);
                cmd.Parameters.AddWithValue("@cCardNumber", KH);
                wf.ExecSqlCmd(cmd);
            }
        }