示例#1
0
        private void bwReport_DoWork(object sender, DoWorkEventArgs e)
        {
            string productNo = e.Argument.ToString();
            List <CartonNumberingModel>       cartonNumberingList       = CartonNumberingController.Get(productNo).ToList();
            List <CartonNumberingDetailModel> cartonNumberingDetailList = CartonNumberingDetailController.Select(productNo);
            List <StoringModel> storingList = StoringController.SelectPerPO(productNo);

            DataTable dtCartonNumbering = new CartonNumberingDataSet().Tables[0];
            DataTable dtStoring         = new StoringReportDataSet().Tables[0];

            foreach (CartonNumberingModel cartonNumbering in cartonNumberingList)
            {
                DataRow drCartonNumbering = dtCartonNumbering.NewRow();
                drCartonNumbering["ProductNo"] = cartonNumbering.ProductNo;
                drCartonNumbering["SizeNo"]    = cartonNumbering.SizeNo;
                drCartonNumbering["Quantity"]  = cartonNumbering.Quantity;
                StoringModel storingPerSize = storingList.Where(p => p.SizeNo == cartonNumbering.SizeNo).FirstOrDefault();
                if (storingPerSize != null)
                {
                    drCartonNumbering["GrossWeight"]       = storingPerSize.ActualWeight;
                    drCartonNumbering["FirstCartonOfSize"] = storingPerSize.CartonNo;
                }

                dtCartonNumbering.Rows.Add(drCartonNumbering);

                List <CartonNumberingDetailModel> cartonNumberingDetail_D1 = cartonNumberingDetailList.Where(c => c.SizeNo == cartonNumbering.SizeNo).ToList();
                for (int i = 1; i <= cartonNumberingDetail_D1.Count(); i++)
                {
                    CartonNumberingDetailModel cartonNumberingDetail = cartonNumberingDetail_D1[i - 1];
                    StoringModel storing = storingList.Where(p => p.CartonNo == cartonNumberingDetail.CartonNo).FirstOrDefault();

                    DataRow drStoring = dtStoring.NewRow();
                    drStoring["ProductNo"]    = cartonNumberingDetail.CartonNo;
                    drStoring["ProductNo"]    = cartonNumbering.ProductNo;
                    drStoring["SizeNo"]       = cartonNumbering.SizeNo;
                    drStoring["NumberOf"]     = i;
                    drStoring["StoringValue"] = string.Format("{0} |", cartonNumberingDetail.CartonNo);
                    if (storing != null)
                    {
                        drStoring["StoringValue"] = string.Format("{0} | {1}", cartonNumberingDetail.CartonNo, storing.ActualWeight);

                        drStoring["IsPass"] = storing.IsPass;
                    }
                    dtStoring.Rows.Add(drStoring);
                }
            }
            string storingDate    = "";
            string quantityCarton = "";

            if (storingList.Count() > 0 && cartonNumberingDetailList.Count() > 0)
            {
                storingDate    = string.Format("{0:dd/MM/yyyy}", storingList.FirstOrDefault().CreatedTime);
                quantityCarton = string.Format("{0} of {1}", storingList.Count(), cartonNumberingDetailList.Select(s => s.CartonNo).Max());
            }
            double totalWeight = storingList.Sum(p => p.ActualWeight);

            object[] results = { productNo, storingDate, dtCartonNumbering, dtStoring, totalWeight, quantityCarton };
            e.Result = results;
        }
示例#2
0
        /// <summary>
        /// How many carton in this PO
        /// </summary>
        /// <param name="productNo">ProductNo</param>
        /// <returns>Quantity Per PO</returns>
        private int GetMaxCarton(string productNo)
        {
            var cartonNumberingDetailList = CartonNumberingDetailController.Select(productNo);

            if (cartonNumberingDetailList.Count() > 0)
            {
                return(cartonNumberingDetailList.Select(s => s.CartonNo).Max());
            }
            else
            {
                return(0);
            }
        }
示例#3
0
        private void dispatcherTimerSendReport_Tick(object sender, EventArgs e)
        {
            var currentTime = DateTime.Now;

            if (currentTime.Hour == createReportHour && currentTime.Minute == createReportMinute && currentTime.Second == createReportSecond)
            {
                var storingReportPerDateList = new List <StoringModel>();
                storingReportPerDateList = StoringController.SelectByDate(DateTime.Now, account.UserName);
                if (storingReportPerDateList.Count > 0)
                {
                    // Send Email
                    mailAddressReceiveMessageList = MailAddressReceiveMessageController.Get();
                    foreach (MailAddressReceiveMessageModel mailAddressReceiveMessage in mailAddressReceiveMessageList)
                    {
                        MailAddress mailAddressReceive = new MailAddress(mailAddressReceiveMessage.MailAddress, mailAddressReceiveMessage.Name);
                        mailMessage.To.Add(mailAddressReceive);
                    }

                    string mailHeader = @"<html><table border='1' style='width:75%'>
                                    <tr><td style='width:20%'>ProductNo</td><td style='width:15%'>Total</td><td style='width:15%'>Inputted</td><td style='width:15%'>Total Inputted</td><td style='width:15%'>Balance</td><td style='width:20%'>Location</td></tr>";
                    string mailBody   = "";
                    foreach (var productNo in storingReportPerDateList.Select(s => s.ProductNo).Distinct().ToList())
                    {
                        //int total = storingTempList.Where(w => w.ProductNo == productNo).Select(s => s.CartonNo).Max();
                        int total    = CartonNumberingDetailController.Select(productNo).Select(s => s.CartonNo).Max();
                        int inputted = storingReportPerDateList.Where(w => w.ProductNo == productNo && w.IsPass == true && w.IsComplete == true).Count();
                        //int totalInputed = storingCurrentList.Where(w => w.StoringModel.ProductNo == productNo && w.StoringModel.IsPass == true && w.StoringModel.IsComplete == true).Count();
                        int totalInputted = StoringController.SelectPerPO(productNo).Where(w => w.IsPass == true && w.IsComplete == true).Count();
                        int balance       = total - totalInputted;
                        mailBody += string.Format("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td></tr>",
                                                  productNo, total, inputted, totalInputted, balance, electricScaleProfile.Location);
                    }
                    mailMessage.Body = mailHeader + mailBody + "</table></html>";

                    if (flagSending == false && mailMessage.To.Count > 0 && CheckInternetConnection.CheckConnection() == true)
                    {
                        smtpClient.SendAsync(mailMessage, mailMessage);
                        flagSending = true;
                        MessageBox.Show(String.Format("Đã gửi report ngày: {0:dd/MM/yyyy HH:mm:ss}", DateTime.Now), "Infor", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
            }
        }
示例#4
0
        private void btnProductNo_Click(object sender, RoutedEventArgs e)
        {
            txtProductNo.Text = txtProductNo.Text.ToUpper().Trim();

            productNo = txtProductNo.Text.ToUpper().Trim();
            if (productNo == "")
            {
                MessageBox.Show("Nhập PO# !", "Input Error", MessageBoxButton.OK, MessageBoxImage.Error);
                HighLightTextblock(txtProductNo, btnProductNo);
                return;
            }

            // Reload StoreProcedure
            cartonNumberingDetail_POList = CartonNumberingDetailController.Select(productNo);

            if (cartonNumberingDetail_POList.Count() == 0)
            {
                MessageBox.Show("Mã Đơn Hàng Không Đúng !", "Input Error", MessageBoxButton.OK, MessageBoxImage.Error);
                HighLightTextblock(txtProductNo, btnProductNo);
                return;
            }

            // If ProductNo has been inputted and PO is correctly.
            //var storingCurrent_POList = storingCurrentList.Where(w => w.StoringModel.ProductNo == productNo).OrderBy(o => o.StoringModel.CartonNo).ToList();
            //if (storingCurrent_POList.Count > 2)
            //{
            //    var firstModel = storingCurrent_POList.FirstOrDefault();
            //    var lastModel = storingCurrent_POList.LastOrDefault();

            //    int cartonSum = lastModel.StoringModel.CartonNo - firstModel.StoringModel.CartonNo;
            //    int digitSum = ConvertBarcodeToSerial(lastModel.StoringModel.Barcode) - ConvertBarcodeToSerial(firstModel.StoringModel.Barcode);

            //    if (cartonSum == digitSum)
            //    {
            //        MessageBox.Show(String.Format("Đơn: {0} Đã Được Nhập !", productNo), "Input Error", MessageBoxButton.OK, MessageBoxImage.Error);
            //        HighLightTextblock(txtProductNo, btnProductNo);
            //        return;
            //    }
            //}

            // Checking ProductNo was loaded or not
            var cartonNumberingDetailLoadedPOList = CartonNumberingDetailController.SelectPOLoaded(productNo).ToList();

            if (cartonNumberingDetailLoadedPOList.Count > 0)
            {
                MessageBox.Show(String.Format("Đơn: {0} Đã Được Xuất Hàng !", productNo), "Input Error", MessageBoxButton.OK, MessageBoxImage.Error);
                HighLightTextblock(txtProductNo, btnProductNo);
                return;
            }

            NoneHighLightTextblock(txtProductNo);

            btnProductNo.IsEnabled = false;
            txtProductNo.IsEnabled = false;

            txtCartonNo.IsEnabled = true;
            txtCartonNo.Focus();
            txtCartonNo.SelectAll();

            btnCartonNo.IsEnabled = true;
            btnCartonNo.IsDefault = true;
        }
示例#5
0
        private void btnBarcodeComplete_Click(object sender, RoutedEventArgs e)
        {
            ClearValue();
            barcode = txtBarCodeComplete.Text.Trim();

            // Check Label is temporary label or OCL Barcode Label
            if (barcode.Length != MAX_LENGHT)
            {
                if (barcode.Contains(","))
                {
                    productNo = barcode.Split(',')[0].Trim().ToString();
                    var cartonNumberingDetailOnLabelList = CartonNumberingDetailController.Select(productNo).ToList();
                    Int32.TryParse(barcode.Split(',')[1].Trim().ToString(), out cartonNo);
                    var sizeNoOnLabel = cartonNumberingDetailOnLabelList.Where(w => w.CartonNo == cartonNo).FirstOrDefault();
                    if (cartonNumberingDetailOnLabelList.Count() == 0 || cartonNo == 0 || sizeNoOnLabel == null)
                    {
                        MessageBox.Show("Kiểm Tra Lại Barocde !", "Input Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        HighLightTextblock(txtBarCodeComplete, btnBarcodeComplete);
                        return;
                    }
                    sizeNo = sizeNoOnLabel.SizeNo;
                }
                else
                {
                    MessageBox.Show("Barocde ( Mã Thùng ) Không Hợp Lệ !", "Input Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    HighLightTextblock(txtBarCodeComplete, btnBarcodeComplete);
                    return;
                }
            }
            else
            {
                var serialDigitList = storingTempList.Select(s => s.SerialNo).Distinct().ToList();
                var serialNo        = ConvertBarcodeToSerial(barcode);
                if (serialDigitList.Contains(serialNo) == false)
                {
                    InputPOStatus();
                    return;
                }
                else
                {
                    var storingTemp_SerialNo = storingTempList.Where(w => w.SerialNo == serialNo).FirstOrDefault();
                    cartonNo  = storingTemp_SerialNo.CartonNo;
                    productNo = storingTemp_SerialNo.ProductNo;
                    sizeNo    = storingTemp_SerialNo.SizeNo;
                }
            }
            NoneHighLightTextblock(txtBarCodeComplete);

            // Check Inputted Or Not
            var storingByBarcode = storingCurrentList.Where(w => (w.StoringModel.Barcode == barcode ||
                                                                  (w.StoringModel.ProductNo == productNo && w.StoringModel.CartonNo == cartonNo)) &&
                                                            w.StoringModel.IsComplete == completeCarton)
                                   .Select(s => s.StoringModel).FirstOrDefault();

            if (storingByBarcode != null && storingByBarcode.IsPass == true)
            {
                MessageBox.Show(string.Format("Thùng {0}, PO {1} Đã Được Cân !", storingByBarcode.CartonNo, storingByBarcode.ProductNo), "Infor", MessageBoxButton.OK, MessageBoxImage.Information);
                tblProductNo.Text = storingByBarcode.ProductNo;
                tblSizeItemQuantityCartonNo.Text = String.Format("Size: {0}\nCartonNo: {1} of {2}", storingByBarcode.SizeNo, storingByBarcode.CartonNo, GetMaxCarton(storingByBarcode.ProductNo));

                txtBarCodeComplete.Focus();
                txtBarCodeComplete.SelectAll();
                btnBarcodeComplete.IsEnabled = true;
                btnBarcodeComplete.IsDefault = true;

                return;
            }
            BarcodeProcess();
        }
示例#6
0
        private void bwLoad_DoWork(object sender, DoWorkEventArgs e)
        {
            storingWeighedList = StoringController.SelectIsNotLoad();
            outputtedList      = OutputingController.SelectIsNotLoad();

            int storingIndex = 1;

            foreach (StoringModel storing in storingWeighedList)
            {
                var current = new StoringCurrent()
                {
                    StoringModel = storing,
                };
                storingCurrentList.Add(current);

                Dispatcher.Invoke(new Action(() =>
                {
                    tempTitle  = string.Format("Downloading Carton: {0} / {1}", storingIndex, storingWeighedList.Count);
                    this.Title = tempTitle;
                }));

                storingIndex++;
            }

            // If this carton was outputted, allow reweigh
            if (outputtedList.Count > 0)
            {
                var barcodeOutputedList = outputtedList.Select(s => s.Barcode).Distinct().ToList();
                storingCurrentList.RemoveAll(r => barcodeOutputedList.Contains(r.StoringModel.Barcode));
            }

            var POScannedList = storingWeighedList.Where(w => w.Barcode.Contains(",") == false).Select(s => s.ProductNo).Distinct().ToList();

            // Create barcode temp
            int poCreatedIndex = 1;

            foreach (var PO in POScannedList)
            {
                var cartonNumberingDetail_POScannedList = CartonNumberingDetailController.Select(PO);
                // If total carton current in po equals total carton in cartonnumberingdetail. PO will be ignore.
                if (storingWeighedList.Where(w => w.ProductNo == PO).Count() == cartonNumberingDetail_POList.Count())
                {
                    poCreatedIndex++;
                    continue;
                }
                var firstStoringWeighedList = storingWeighedList.Where(w => w.ProductNo == PO).FirstOrDefault();
                int serialCarton_0          = ConvertBarcodeToSerial(firstStoringWeighedList.Barcode) - firstStoringWeighedList.CartonNo;
                int cartonIndex             = 1;
                foreach (var cartonDetail in cartonNumberingDetail_POScannedList)
                {
                    var storingTemp = new StoringTemp()
                    {
                        SizeNo    = cartonDetail.SizeNo,
                        ProductNo = cartonDetail.ProductNo,
                        CartonNo  = cartonDetail.CartonNo,
                        SerialNo  = serialCarton_0 + cartonDetail.CartonNo,
                    };
                    storingTempList.Add(storingTemp);

                    Dispatcher.Invoke(new Action(() =>
                    {
                        tempTitle = String.Format("Creating Barcode: {0} of {1} for {2} / {3} PO#",
                                                  cartonIndex,
                                                  cartonNumberingDetail_POScannedList.Select(s => s.CartonNo).Max(),
                                                  poCreatedIndex,
                                                  POScannedList.Count);
                        this.Title = tempTitle;
                    }));

                    cartonIndex++;
                }
                poCreatedIndex++;
            }
        }
        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            string productNo = "";

            productNo = txtProductNo.Text;
            orderSearchByProductNo = OrdersController.SelectByProductNo(productNo);
            if (orderSearchByProductNo == null)
            {
                MessageBox.Show("Mã Đơn Hàng Không Đúng.", "Warning", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            outputList = OutputtingController.SelectByProductNo(productNo);

            List <CartonNumberingDetailModel> totalCartonList = new List <CartonNumberingDetailModel>();

            totalCartonList = CartonNumberingDetailController.SelectByProductNo(productNo);

            tblTotalOutpput.Text = outputList.Count().ToString();
            tblTotalCarton.Text  = totalCartonList.Count().ToString();
            tblPass.Text         = outputList.Where(w => w.DifferencePercent >= -1 && w.DifferencePercent <= 1).Count().ToString();
            tblHi.Text           = outputList.Where(w => w.DifferencePercent > 1).Count().ToString();
            tblLow.Text          = outputList.Where(w => w.DifferencePercent < -1).Count().ToString();

            // Add Output
            foreach (OutputtingModel model in outputList)
            {
                string status = "";
                if (model.DifferencePercent >= -1 && model.DifferencePercent <= 1)
                {
                    status = "Pass";
                }
                if (model.DifferencePercent < -1)
                {
                    status = "Low";
                }
                if (model.DifferencePercent > 1)
                {
                    status = "Hi";
                }

                OutputDetail outputDetail = new OutputDetail()
                {
                    ProductNo         = model.ProductNo,
                    Barcode           = model.Barcode,
                    CartonNo          = model.CartonNo,
                    SizeNo            = model.SizeNo,
                    GrossWeight       = model.GrossWeight,
                    ActualWeight      = model.ActualWeight,
                    DifferencePercent = model.DifferencePercent,
                    CreatedAccount    = model.CreatedAccount,
                    Status            = status,
                    OutputDate        = model.CreatedTime.ToShortDateString(),
                };
                outputDetailList.Add(outputDetail);
                allOutputDetailList.Add(outputDetail);
            }

            // Add not output
            List <CartonNumberingDetailModel> cartonListNotOutput = new List <CartonNumberingDetailModel>();

            cartonListNotOutput = CartonNumberingDetailController.SelectCartonNoNotOutput(productNo);
            foreach (CartonNumberingDetailModel model in cartonListNotOutput)
            {
                OutputDetail outputDetail = new OutputDetail()
                {
                    ProductNo = model.ProductNo,
                    CartonNo  = model.CartonNo,
                    SizeNo    = model.SizeNo,
                };
                notOutputDetailList.Add(outputDetail);
                allOutputDetailList.Add(outputDetail);
            }

            dgOutput.ItemsSource = allOutputDetailList;
        }
示例#8
0
 private void bwLoad_DoWork(object sender, DoWorkEventArgs e)
 {
     cartonNumberingDetailList = CartonNumberingDetailController.Select(productNo).OrderBy(o => o.CartonNo).ToList();
 }