public void AccesstoUIFunctinality() { ConfigurationButton.Enabled = false; QualityControlButton.Enabled = false; ExportButton.Enabled = false; StatusChangeButton.Enabled = false; VFRSearchButton.Enabled = false; BatchRegistrationButton.Enabled = false; // Get User Information to control Accesst to Functionality if (Environment.UserName.ToUpper() == "ADMINISTRATOR") { ConfigurationButton.Enabled = true; QualityControlButton.Enabled = true; ExportButton.Enabled = true; StatusChangeButton.Enabled = true; VFRSearchButton.Enabled = true; BatchRegistrationButton.Enabled = true; } else { ResultUsers resultUsers = new ResultUsers(); List <User> users = new List <User>(); resultUsers = DBTransactions.GetUserByName(Environment.UserName); users = resultUsers.ReturnValue; foreach (UIFunctionality functionality in users[0].UIFunctionality) { switch (functionality.Description) { case "System Configuration": ConfigurationButton.Enabled = true; break; case "Quality Control": QualityControlButton.Enabled = true; break; case "Export": ExportButton.Enabled = true; break; case "Batch Administration": StatusChangeButton.Enabled = true; break; case "VFR Search": VFRSearchButton.Enabled = true; break; case "Batch Registration": BatchRegistrationButton.Enabled = true; break; } } } }
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); } }