コード例 #1
0
        private void ApplyButton_Click(object sender, EventArgs e)
        {
            ResultBatches resultBatches       = new ResultBatches();
            ResultGeneric resultGeneric       = new ResultGeneric();
            string        originalBatchStatus = "";
            Batch         batch          = new Batch();
            DialogResult  result         = DialogResult.No;
            string        action         = "";
            DateTime      currentDate    = DateTime.Now;
            ResultUsers   resultUsers    = new ResultUsers();
            List <User>   users          = new List <User>();
            Boolean       allowDeletion  = false;
            Boolean       allowRecall    = false;
            Boolean       allowRejection = false;

            try
            {
                // Get User Information to control Accesst to Functionality
                resultUsers = DBTransactions.GetUserByName(Environment.UserName);
                users       = resultUsers.ReturnValue;
                foreach (UIFunctionality functionality in users[0].UIFunctionality)
                {
                    switch (functionality.Description)
                    {
                    case "Batch  Rejection":
                        allowRejection = true;
                        break;

                    case "Batch  Recall":
                        allowRecall = true;
                        break;

                    case "Batch  Removal":
                        allowDeletion = true;
                        break;
                    }
                }

                nlogger.Trace("     QC Transaction (Apply Action) for Batch: " + BatchNameTextBox.Text);
                resultBatches = DBTransactions.GetBatchesInformation("BatchNumber = \"" + BatchNameTextBox.Text + "\"", ""); // OR BatchAlias = \"" + BatchNumber.Text + "\"", "");

                batch = resultBatches.ReturnValue[0];
                originalBatchStatus = batch.StatusFlag;

                if (RejectedRadioButton.Checked)
                {
                    action = "Rejected";
                }

                if (RecallRadioButton.Checked)
                {
                    action = "Recall";
                }

                if (DeleteRadioButton.Checked)
                {
                    action = "Delete";
                }

                switch (action)
                {
                case "Rejected":
                    if (allowRejection)
                    {
                        result = MessageBox.Show(this, "Do you want to Reject this Batch : " + BatchNameTextBox.Text + " ?", "Confirmation...", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (result == DialogResult.Yes)
                        {
                            batch.RejectedBy       = OperatorTextBox.Text;
                            batch.RejectionReason  = RejectCommentsTextBox.Text;
                            batch.LastTimeRejected = currentDate;
                            batch.RejectedTimes    = batch.RejectedTimes + 1;
                            batch.StatusFlag       = "Rejected";

                            // Update Batch Information
                            nlogger.Trace("     Updating Batch information in Database ...");
                            resultGeneric = DBTransactions.BatchUpdate(batch);
                            if (resultGeneric.ReturnCode == 0)
                            {
                                // Batch Event Tracking
                                nlogger.Trace("     Adding transaction in Tracking Database Table ...");
                                DBTransactions.BatchTrackingEvent(batch.BatchNumber, originalBatchStatus, "Rejected", "Batch Rejected", OperatorTextBox.Text);
                            }
                        }
                    }
                    else
                    {
                        result = MessageBox.Show(this, "You are not auhorized to perform this operation.", "Information ...", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    }

                    break;

                case "Recall":
                    if (allowRecall)
                    {
                        result = MessageBox.Show(this, "Do you want to request a Recall this Batch : " + BatchNameTextBox.Text + " ?", "Confirmation...", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (result == DialogResult.Yes)
                        {
                            batch.RecallBy     = OperatorTextBox.Text;
                            batch.RecallReason = RecallCommentsTextBox.Text;
                            batch.RecallDate   = currentDate;
                            batch.RecallTimes  = batch.RecallTimes + 1;
                            batch.StatusFlag   = "Recall";

                            // Update Batch Information
                            nlogger.Trace("     Updating Batch information in Database ...");
                            resultGeneric = DBTransactions.BatchUpdate(batch);
                            if (resultGeneric.ReturnCode == 0)
                            {
                                // Batch Event Tracking
                                nlogger.Trace("     Adding transaction in Tracking Database Table ...");
                                DBTransactions.BatchTrackingEvent(batch.BatchNumber, originalBatchStatus, "Recall", "Batch tagged for Recall", OperatorTextBox.Text);
                            }
                        }
                    }
                    else
                    {
                        result = MessageBox.Show(this, "You are not auhorized to perform this operation.", "Information ...", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    }
                    break;

                case "Delete":
                    if (allowDeletion)
                    {
                        result = MessageBox.Show(this, "Do you want to Delete this Batch : " + BatchNameTextBox.Text + " ?", "Confirmation...", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (result == DialogResult.Yes)
                        {
                            // Tag Batch for deletion
                            batch.StatusFlag = "Waiting for Deletion";
                            // Update Batch Information
                            nlogger.Trace("     Updating Batch information in Database ...");
                            resultGeneric = DBTransactions.BatchUpdate(batch);
                            if (resultGeneric.ReturnCode == 0)
                            {
                                // Batch Event Tracking
                                nlogger.Trace("     Adding transaction in Tracking Database Table ...");
                                DBTransactions.BatchTrackingEvent(batch.BatchNumber, originalBatchStatus, "Waiting for Deletion", "Batch tagged for Deletion", OperatorTextBox.Text);
                            }
                            MessageBox.Show(this, "This operation is under Construction", "Alert...", MessageBoxButtons.YesNo, MessageBoxIcon.Hand);
                        }
                    }
                    else
                    {
                        result = MessageBox.Show(this, "You are not auhorized to perform this operation.", "Information ...", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    }
                    break;
                }
                ResetValues();
                DisableButtons();
                DisableOptions();
                ExitButton.Enabled = true;
            }
            catch (Exception ex)
            {
                General.ErrorMessage(ex);
            }
        }
コード例 #2
0
        private void CheckBatchNumber()
        {
            string             batchName          = "";
            ResultBatches      resultBatches      = new ResultBatches();
            ResultJobsExtended resultJobsExtended = new ResultJobsExtended();
            Batch        batch = new Batch();
            DialogResult result;
            string       originalBatchStatus = "";

            try
            {
                nlogger.Trace("         Operator entered the following Batch Name: " + BatchNumber.Text);

                if (BatchNumber.Text.Length > 0)
                {
                    resultBatches = DBTransactions.GetBatchesInformation("BatchNUmber = \"" + BatchNumber.Text + "\" OR BatchAlias = \"" + BatchNumber.Text + "\"", "");
                    if (resultBatches.RecordsCount == 0)
                    {
                        // Batch not found
                        nlogger.Trace("         Batch Name " + BatchNumber.Text + " entered could not be found");
                        result = MessageBox.Show(this, "The Batch Name entered could not be found.", "Info ....", MessageBoxButtons.OK,
                                                 MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                    }
                    else
                    {
                        // Batch Found
                        batch = resultBatches.ReturnValue[0];

                        resultJobsExtended = DBTransactions.GetJobByName(batch.JobType);

                        batchName = batch.BatchNumber;
                        if (BatchNumber.Text == resultBatches.ReturnValue[0].BatchAlias)
                        {
                            nlogger.Trace("         Batch Name " + BatchNumber.Text + " entered is an Alias. The corresponding Batch Name is: " + batchName);
                            result = MessageBox.Show(this, "The number entered is a Batch Alias Name. The corresponing Box Number/Name is: " + batchName, "Info ....", MessageBoxButtons.OK,
                                                     MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                        }
                        ResetValues();

                        BatchNameTextBox.Text      = batchName;
                        CurrentStatusTextBox.Text  = batch.StatusFlag;
                        originalBatchStatus        = batch.StatusFlag;
                        BatchAliasNameTextBox.Text = batch.BatchAlias;
                        RecallCommentsTextBox.Text = batch.RecallReason;
                        RejectCommentsTextBox.Text = batch.RejectionReason;

                        //Only Batches in the following stages are allowed to be change:
                        //Waiting for Validation, Waiting for QC, QC on Hold, QC Failed, Rejected, and Waiting for PDF Conversion
                        if (CurrentStatusTextBox.Text == "Waiting for Validation" || CurrentStatusTextBox.Text == "Waiting for QC" ||
                            CurrentStatusTextBox.Text == "QC on Hold" || CurrentStatusTextBox.Text == "QC Failed" ||
                            CurrentStatusTextBox.Text == "Waiting for Approval" || CurrentStatusTextBox.Text == "Waiting for PDF Conversion")
                        {
                            EnableButtons();
                            nlogger.Trace("         Enable / Disable Options based on current Status.");

                            switch (CurrentStatusTextBox.Text)
                            {
                            case "Waiting for Approval":
                                RejectedRadioButton.Enabled = true;
                                RecallRadioButton.Enabled   = true;
                                DeleteRadioButton.Enabled   = true;
                                break;

                            case "Waiting for Validation":
                            case "Waiting for PDF Conversion":
                            case "QC on Hold":
                            case "QC Failed":
                            case "Waiting for QC":
                                RejectedRadioButton.Enabled = false;
                                RecallRadioButton.Enabled   = true;
                                DeleteRadioButton.Enabled   = true;
                                break;
                            }
                        }
                        else
                        {
                            RejectedRadioButton.Enabled = false;
                            RecallRadioButton.Enabled   = false;
                            nlogger.Trace("         Batch Number " + batchName + " can only be set for Deletion.");
                            result = MessageBox.Show(this, "Batch Number " + batchName + " can only be set for Deletion.", "Message...", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                ApplyButton.Enabled = false;
                ClearButton.Enabled = true;
            }
            catch (Exception ex)
            {
                General.ErrorMessage(ex);
            }
        }