private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem item = sender as MenuItem;

            switch (item.Header)
            {
            case "Reprint label": {
                string msg          = "";
                string lot_selected = "";

                try {
                    msaccdb_ProductionLOT row = (msaccdb_ProductionLOT)this.datagrid_recentlot.SelectedValue;
                    lot_selected = row.Lot;
                }
                catch { }

                if (lot_selected != "")
                {
                    Thread t = new Thread(new ThreadStart(() => {
                            bool r = new ReprintProductionLot(lot_selected).Print(out msg);
                            MessageBox.Show(r ? "Success" : "Fail\n" + msg, "Reprint", MessageBoxButton.OK, r ? MessageBoxImage.Information : MessageBoxImage.Error);
                        }));
                    t.IsBackground = true;
                    t.Start();
                }
                else
                {
                    MessageBox.Show("Please select a production lot.", "Reprint", MessageBoxButton.OK, MessageBoxImage.Error);
                }

                break;
            }
            }
        }
Exemplo n.º 2
0
        bool _save_log_()
        {
            bool r = false;

            r = new io_msaccdb_tbDataProductionLot().UpdateReworkData(Proj_Rework.ProductionLot, Proj_Rework.ReworkSerial, Proj_Rework.NewProductSerial, Proj_Rework.Reason, Proj_Rework.Operator);
            r = new io_msaccdb_tbDataProductionLot().WriteData(Proj_Rework);

            //print label
            if (Proj_Rework.AutoPrintLabel == true)
            {
                Thread t = new Thread(new ThreadStart(() => {
                    string msg;
                    bool ret = new ReprintProductionLot(Proj_Rework.ProductionLot).Print(out msg);
                    MessageBox.Show(ret ? "Success" : "Fail\n" + msg, "Reprint LOT " + Proj_Rework.ProductionLot, MessageBoxButton.OK, r ? MessageBoxImage.Information : MessageBoxImage.Error);
                }));
                t.IsBackground = true;
                t.Start();
            }

            Proj_Rework.NewProductSerial = ""; //clear product serial number
            return(r);
        }
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem menu = sender as MenuItem;

            string lot_selected = "";
            msaccdb_tbDataProductionLOT row_selected = null;

            try {
                row_selected = (msaccdb_tbDataProductionLOT)this.data_grid_lot.SelectedValue;
                lot_selected = row_selected.Lot;
            }
            catch { return; }


            switch (menu.Header)
            {
            case "Reprint label": {
                string msg = "";

                if (lot_selected != "")
                {
                    Thread t = new Thread(new ThreadStart(() => {
                            bool r = new ReprintProductionLot(lot_selected).Print(out msg);
                            MessageBox.Show(r ? "Success" : "Fail\n" + msg, "Reprint LOT " + lot_selected, MessageBoxButton.OK, r ? MessageBoxImage.Information : MessageBoxImage.Error);
                        }));
                    t.IsBackground = true;
                    t.Start();
                }
                else
                {
                    MessageBox.Show("Please select a production lot.", "Reprint", MessageBoxButton.OK, MessageBoxImage.Error);
                }

                break;
            }

            case "Rework": {
                Init_Product product = MyGlobal.Products.Single(x => x.name.Equals(row_selected.ProductName));

                this.Proj_Rework = new Proj_ReworkInformation()
                {
                    ProductionLot = row_selected.Lot,
                    LotProgress   = row_selected.LotProgress,
                    ProductName   = row_selected.ProductName,
                    ReworkSerial  = row_selected.ProductSerial,
                    ProductInfo   = product.ToString(),
                    Line          = row_selected.Line,
                    LotQuantity   = row_selected.LotQuantity,
                    WeightLimit   = string.Format("{0} ~ {1}", double.Parse(product.weight) - double.Parse(product.bias), double.Parse(product.weight) + double.Parse(product.bias))
                };

                MyGlobal.myWindow.WindowOpacity = 0.3;

                ReasonWindow reason = new ReasonWindow(ref Proj_Rework);
                reason.ShowDialog();
                if (Proj_Rework.Operator.Trim() == "" || Proj_Rework.Reason.Trim() == "")
                {
                    MessageBox.Show("Tên người thao tác hoặc lý do rework không hợp lệ.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    break;
                }

                ReworkWindow rework = new ReworkWindow(Proj_Rework, product);
                rework.ShowDialog();
                break;
            }

            case "Refresh": {
                break;
            }
            }
            MyGlobal.myWindow.WindowOpacity = 1;
        }