Ejemplo n.º 1
0
 private void ShowAssortedDetailAndSyncModelList()
 {
     listviewScan.Items.Clear();
     try
     {
         AssortedService.GetMathPalletPlanDetailByIce(StaticModel.MathchPalletCode).ForEach(it =>
         {
             var mathchPalletDetail = new MatchPalletPlanDetailModel
             {
                 ProductCode       = it.ProductCode,
                 ProductName       = it.ProductName,
                 MatchPalletCode   = it.MatchPalletCode,
                 WarehouseQuantity = it.WarehouseQuantity,
                 WarehouseUnitCode = it.WarehouseUnitCode,
                 WorkshopQuantity  = it.WorkshopQuantity,
                 WorkshopUnitCode  = it.WorkshopUnitCode,
                 WorkshopUnitName  = it.WorkshopUnitName
             };
             modelList.Add(mathchPalletDetail);
             ListViewItem lvi = new ListViewItem(new string[] { mathchPalletDetail.ProductName, mathchPalletDetail.WorkshopQuantity.ToString(), "0", mathchPalletDetail.ProductCode });
             listviewScan.Items.Add(lvi);
         });
     }
     catch (Exception e)
     {
         MessageBox.Show("出现异常,异常信息:" + e.Message);
         this.Hide();
     }
 }
        private void btnNext_Click(object sender, EventArgs e)
        {
            string palletBarcode = this.txtScanCode.Text.Trim().ToString();

            StaticModel.ScanBarCode = palletBarcode;
            txtScanCode.Focus();

            if (string.IsNullOrEmpty(palletBarcode))
            {
                MessageBox.Show("请扫托盘条码!", "消息提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                return;
            }

            if (txtScanCode.Text.Length != 8)
            {
                MessageBox.Show("8位托盘条码长度,请重扫!");
                txtScanCode.Text = "";
                return;
            }

            var locationBarcode = AssortedService.GetPalletByBarcode(palletBarcode);

            if (locationBarcode != null)
            {
                MessageBox.Show("托盘条码  " + palletBarcode + "已入库,货位名称:" + locationBarcode.LocationName);
                this.txtScanCode.Text = "";
                return;
            }

            var assortedBill = AssortedService.GetAssortedBillByBarcode(palletBarcode);

            if (assortedBill != null)
            {
                MessageBox.Show("托盘条码  " + palletBarcode + "已拼盘,拼盘单号:" + assortedBill.AssortedBillNo);
                this.txtScanCode.Text = "";
                return;
            }
            this.txtScanCode.Text = "";
            if (Glob.CurrentMatchPalletCode != StaticModel.MathchPalletCode)
            {
                Glob.ClearAssortedProductModelList();
                AssortedService.GetMathPalletPlanDetailByIce(StaticModel.MathchPalletCode).ForEach(each =>
                {
                    Glob.AddOrUpdateAssortedProductModel(new AssortedProductModelModel()
                    {
                        ProductCode  = each.ProductCode,
                        ProductName  = each.ProductName,
                        Quantity     = each.WorkshopQuantity * each.WorkshopTransferRate, //必须数量乘以转化率,是为了配合原有系统,也防止小数点
                        UnitCode     = each.WorkshopUnitCode,
                        UnitName     = each.WorkshopUnitName,
                        TransferRate = 1
                    });
                });
                Glob.CurrentMatchPalletCode = StaticModel.MathchPalletCode;
            }

            var frmAssortedDetail = new FrmAssortedDetail(this, FrmAssorted, AssortedService);

            frmAssortedDetail.Show();
            this.Hide();
            this.txtScanCode.Text = "";

            //var dlg = new FrmProductFacture();
            //if (DialogResult.OK == dlg.ShowDialog())
            //{
            //    var frmAssortedDetail = new FrmAssortedDetail(this, FrmAssorted, AssortedService);
            //    frmAssortedDetail.Show();
            //}
            //dlg.Dispose();
        }