コード例 #1
0
        private void btnCheckFiles_Click(object sender, EventArgs e)
        {
            btnEncode.Enabled = false;

            GenerateService.CheckPaths();

            if (txtBoxBatchNo.Text.ToUpper() != "0000")
            {
                if (dteDeliveryDate.Value.ToShortDateString() == DateTime.Today.ToShortDateString())
                {
                    DialogResult result3 = MessageBox.Show("Please select Delivery Date", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                    dteDeliveryDate.Focus();

                    //return;
                }
                else if (txtBoxBatchNo.Text == "")
                {
                    DialogResult result3 = MessageBox.Show("Please input Batch No: ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                    dteDeliveryDate.Focus();

                    return;
                }
                else if (txtBoxProcessBy.Text == "")
                {
                    DialogResult result3 = MessageBox.Show("Please input Process by: ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                    dteDeliveryDate.Focus();

                    return;
                }
            }

            if (btnCheckFiles.Text == "Check Files on Head")
            {
                DialogResult result1 = MessageBox.Show("Are you sure you want to check " + lstFiles.Items.Count + " items?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

                if (result1 == DialogResult.No)
                {
                    return;
                }

                //ReturnMe.CreateTable();

                List <OrderModel> OrderList = new List <OrderModel>();

                int LoopCount = 0;

                lblStatus.Text = "Now Checking Files in Head Folder . . .";

                while (LoopCount < lstFiles.Items.Count)
                {
                    string filename = lstFiles.Items[LoopCount].ToString();

                    OrderList.AddRange(CheckFiles(filename));

                    LoopCount = LoopCount + 1;
                }

                CheckBranches(OrderList);

                DisplayData(OrderList);

                if (CheckingService.CheckBatchIfDuplicate(txtBoxBatchNo.Text))
                {
                    MessageBox.Show("Batch No is already been use ! ! !", "Error");
                }
                else
                {
                    btnCheckFiles.Text = "Process ! ! !";

                    MessageBox.Show("Data has been Checked. No Errors found!", " ", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    lblStatus.Text = "Ready . . .";
                }

                if (checkBoxSortRT.Checked == true)
                {
                    //For Sort RT
                    List <OrderModel> sortTemp = new List <OrderModel>();

                    sortTemp.AddRange(sortedList.RegularPersonal);
                    sortTemp.AddRange(sortedList.RegularCommercial);
                    GenerateService.GenerateSortRT("Regular", sortTemp);

                    sortTemp = new List <OrderModel>();
                    sortTemp.AddRange(sortedList.PersonalPreEncoded);
                    sortTemp.AddRange(sortedList.CommercialPreEncoded);
                    GenerateService.GenerateSortRT("Regular\\PreEncoded", sortTemp);

                    GenerateService.GenerateSortRT("MC", sortedList.ManagersCheck);

                    sortTemp = new List <OrderModel>();
                    sortTemp.AddRange(sortedList.CheckOnePersonal);
                    sortTemp.AddRange(sortedList.CheckOneCommerical);
                    GenerateService.GenerateSortRT("CheckOne", sortTemp);

                    sortTemp = new List <OrderModel>();
                    sortTemp.AddRange(sortedList.CheckPowerPersonal);
                    sortTemp.AddRange(sortedList.CheckPowerCommercial);
                    GenerateService.GenerateSortRT("CheckPower", sortTemp);

                    GenerateService.GenerateSortRT("GiftCheck", sortedList.GiftCheck);

                    GenerateService.GenerateSortRT("MC\\Continues", sortedList.ManagersCheckCont);

                    MessageBox.Show("SortRT File has been successfully generated", " ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                btnCheckFiles.Enabled = false;
                btnEncode.Enabled     = false;


                //GENERATE PRINTER FILES
                lblStatus.Text = "Generating Printer Files";
                Application.DoEvents();
                AddSerials();
                GenerateService.GeneratePrinterFiles(sortedList, txtBoxBatchNo.Text, txtBoxExt.Text);

                //GENERATE MDB FILE FOR Manager's Check
                if (sortedList.ManagersCheck.Count > 0 || sortedList.ManagersCheckCont.Count > 0)
                {
                    lblStatus.Text = "Generating MDB Files for Manager's Check";
                    Application.DoEvents();
                    GenerateService.GenerateMDBFile(sortedList, txtBoxBatchNo.Text, txtBoxExt.Text);
                }

                //GENERATE PACKING DBF
                lblStatus.Text = "Generating Packing DBF Files";
                Application.DoEvents();
                GenerateService.GeneratePackingDBF(sortedList, txtBoxBatchNo.Text, txtBoxExt.Text);

                //GENERATE DO BLOCK
                lblStatus.Text = "Generating DoBlock Files";
                Application.DoEvents();
                GenerateService.GenerateDoBlock(sortedList, txtBoxBatchNo.Text, txtBoxExt.Text, dteDeliveryDate.Value, txtBoxProcessBy.Text);

                //GENERATE PACKINGLIST
                lblStatus.Text = "Generating PackingList Files";
                Application.DoEvents();
                GenerateService.GeneratePackingList(sortedList, txtBoxBatchNo.Text, dteDeliveryDate.Value, branchList);

                if (txtBoxBatchNo.Text != "0000")
                {
                    //SAVE HISTORY
                    lblStatus.Text = "Saving History";
                    Application.DoEvents();
                    BackupService.SaveHistory(sortedList, txtBoxBatchNo.Text, txtBoxExt.Text, dteDeliveryDate.Value);

                    //SAVE NEW SERIES ON DATABASE
                    lblStatus.Text = "Saving New Serial in Database . . .";
                    Application.DoEvents();
                    BackupService.SaveNewSeries(branchList);

                    //WinZIP Process
                    lblStatus.Text = "Archiving Output Files . . .";
                    Application.DoEvents();
                    BackupService.ProcessArchiving(AutoBatch, txtBoxProcessBy.Text, sortedList);

                    DeleteHeadFiles();//DELETE FILES IN HEAD FOLDER
                }


                lblStatus.Text = "Processing Done. . .";

                MessageBox.Show("Processing Done . . .", " ", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }//END OF FUNCTION