private void btnSaveConfiguration_Click(object sender, EventArgs e) { bool found = false; config = (Configurations)configBind.Current; foreach (ContractConfigurations item in configs) { if (item.ContractConfigurations_Configuration.Configuration_Component == config.Configuration_Component) { item.ContractConfigurations_Configuration = config; found = true; break; } } if (found == false) { if (ValidateConfInfo()) { configs.Add(new ContractConfigurations(contract, config, txtCompSerial.Text)); MessageBoxShower.ShowInfo("Configuration saved!", "Success!"); } else { CustomExceptions error = new CustomExceptions("Please complete all fields.", "Configuration failed."); } } txtCompSerial.Clear(); }
private void btnRecPayment_Click(object sender, EventArgs e) { if (ValidateBilling()) { clientBilling = new Billing((Client)clientBind.Current, DateTime.UtcNow, 0, 0).GetClientBilling(); double paid = (from pBill in clientBilling select pBill.AmountPaid).Sum(); double due = (from pBill in clientBilling select pBill.AmountDue).Sum(); double currentDue = due - paid; try { double amount = Convert.ToDouble(txtAmount.Text); Billing b = new Billing((Client)clientBind.Current, dtpPayDate.Value, currentDue, Convert.ToDouble(txtAmount.Text)); if (b.InsertBilling()) { MessageBoxShower.ShowInfo("Payment Recorded!", "Success!"); this.Close(); } else { CustomExceptions error = new CustomExceptions("The payment could not be recorded. Please try again later.", "Failure!"); } } catch (Exception) { CustomExceptions error = new CustomExceptions("The payment could not be recorded. Please try again later.", "Failure!"); } } else { CustomExceptions error = new CustomExceptions("Please complete all fields correctly.", "Failure!"); } }
private void btnRecPw_Click(object sender, EventArgs e) { User u = new User(); string email = "*****@*****.**"; //string email = Microsoft.VisualBasic.Interaction.InputBox("Please enter the email address associated with your account:", "Email Address", "", -1, -1); if (email != "") { u = u.GetAllUsers(email)[0]; if (u.Password != "") { if (u.RecoverPassword(u)) { MessageBoxShower.ShowInfo("Your password have been emailed to: " + u.Email, "Password Recovered."); this.Close(); } else { CustomExceptions error = new CustomExceptions("Could not recover password. Please try again...", "Password Recovery Failed!"); } } else { MessageBoxShower.ShowInfo("Your account could not be found. Please try again or contact your administrator.", "Password Recovery failed!"); } } }
private void btnAddClient_Click(object sender, EventArgs e) { if (ValidateForm()) { Client client = (Client)bind1.Current; if (cmbPayment.SelectedItem.ToString() == "Debit Order") { if (client.UpdateClientWithPaymentDetails(txtAccNr.Text, txtBank.Text, txtBranch.Text)) { MessageBoxShower.ShowInfo("The Client was updated successfully!", "Success!"); } else { CustomExceptions error = new CustomExceptions("The client could not be updated, Please try again later.", "Something went wrong.."); } } else { if (client.UpdateClient()) { MessageBoxShower.ShowInfo("The Client was updated successfully!", "Success!"); } else { CustomExceptions error = new CustomExceptions("The client could not be updated, Please try again later.", "Something went wrong.."); } } } else { CustomExceptions error = new CustomExceptions("Please complete all fields correctly.", "Failure!"); } }
private void btnAddVendor_Click(object sender, EventArgs e) { if (ValidateVendor()) { Vendor vend = new Vendor("", txtName.Text, new Address("", txtLine1.Text, txtLine2.Text, txtCity.Text, txtPostalCode.Text), new Contact("", txtCell.Text, txtEmail.Text)); if (NoDuplicates(vend)) { if (vend.InsertVendor()) { MessageBoxShower.ShowInfo("The Vendor was added successfully!", "Success"); this.Close(); } else { CustomExceptions error = new CustomExceptions("The vendor could not be added. Please try again later.", "Something went wrong.."); } } else { CustomExceptions error = new CustomExceptions("A Vendor with this name has already been added. Please update.", "The vendor could not be added."); } } else { CustomExceptions error = new CustomExceptions("Please complete all fields correctly.", "Validation Error!"); } }
private void btnDecline_Click(object sender, EventArgs e) { btnClose.Visible = true; if (ValidateForm()) { current = (Client)bind1.Current; if (start != null) { end = DateTime.UtcNow; callTime.Stop(); CallOperators co = frmMain.loggedIn.GetMatchingCallOperator(); CallLog call = new CallLog(co, current, start, end, rtxtRemarks.Text); if (call.InsertCall()) { MessageBoxShower.ShowInfo("This called has been logged. Thank you.", "Call Log"); } else { CustomExceptions error = new CustomExceptions("This call could not be logged. Please try again", "Logging Error!"); } } } else { CustomExceptions error = new CustomExceptions("Please complete all fields!", "Validation Error!"); } }
public static byte[] LoadAsBinary(string path) { try { using (var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read)) { using (var binReader = new BinaryReader(fileStream)) { return(binReader.ReadBytes((int)binReader.BaseStream.Length)); } } } catch (FileNotFoundException e) { MessageBoxShower.DisplayDialog("❌Error", "ファイルパスに間違いがあります。\n" + e.Message, "OK"); return(null); } catch (ArgumentException e) { MessageBoxShower.DisplayDialog("❌Error", "ファイルパスが空欄です。\n" + e.Message, "OK"); return(null); } catch (DirectoryNotFoundException e) { MessageBoxShower.DisplayDialog("❌Error", "ファイルパスに間違いがあります。\n" + e.Message, "OK"); return(null); } }
private void btnUpdateEmp_Click(object sender, EventArgs e) { if (ValidateForm()) { if (empBind.Current is Technicians) { Technicians t = (Technicians)empBind.Current; if (t.UpdateTech()) { MessageBoxShower.ShowInfo("The Technician was successfully updated!", "Success"); } else { CustomExceptions error = new CustomExceptions("The Technician could not be updated.Please try again later.", "Something went wrong.."); } } else if (empBind.Current is CallOperators) { CallOperators co = (CallOperators)empBind.Current; if (co.UpdateCallOperator()) { MessageBoxShower.ShowInfo("The Call Operator was successfully updated!", "Success"); } else { CustomExceptions error = new CustomExceptions("The Call Operator could not be updated.Please try again later.", "Something went wrong.."); } } } }
/// <summary> /// その他のメッセージ(定型文)を表示 /// </summary> /// <param name="type">どのメッセージを表示するか</param> public static void MessageShow(string type) { switch (type) { case "GenerateStopped": MessageBoxShower.GenerateStoppedMessage(); break; } }
private void btnNextConf_Click(object sender, EventArgs e) { if (addComponents != null) { pnlComponnts.Hide(); pnlConfiguration.Show(); lbComponentsConf.DataSource = addComponents; } else { MessageBoxShower.ShowInfo("Please add product Components.", "Unable to proceed"); } }
private void btnAddEmp_Click(object sender, EventArgs e) { if (ValidateForm()) { if (cmbType.SelectedItem.ToString() == "Technician") { Technicians t = new Technicians(txtId.Text, txtName.Text, txtSurname.Text, new Address("", txtLine1.Text, txtLine2.Text, txtCity.Text, txtPostalCode.Text), new Contact("", txtCell.Text, txtEmail.Text), cmbStatus.SelectedItem.ToString(), cmbSkill.SelectedItem.ToString()); if (NoDuplicates(t)) { if (t.AddTech()) { MessageBoxShower.ShowInfo("The Technician was added to the system.", "Success!"); this.Close(); } else { CustomExceptions error = new CustomExceptions("The Technician could not be added. Please try again.", "Failure!"); } } else { CustomExceptions error = new CustomExceptions("A technician with this ID has already been added. Please update.", "Cannot add technician."); } } else if (cmbType.SelectedItem.ToString() == "Call Operator") { CallOperators c = new CallOperators(txtId.Text, txtName.Text, txtSurname.Text, new Address("", txtLine1.Text, txtLine2.Text, txtCity.Text, txtPostalCode.Text), new Contact("", txtCell.Text, txtEmail.Text), cmbStatus.SelectedItem.ToString()); if (NoDuplicates(c)) { if (c.InsertCallOperator()) { MessageBoxShower.ShowInfo("The Call Operator was added to the system.", "Success!"); this.Close(); } else { CustomExceptions error = new CustomExceptions("The Call Operator could not be added. Please try again.", "Failure!"); } } else { CustomExceptions error = new CustomExceptions("A Call Operator with this ID has already been added. Please update.", "Cannot add Call Operator."); } } } else { CustomExceptions error = new CustomExceptions("Please complete all fields.", "Cannot add Employee."); } }
private void btnCalculateOutstanding_Click(object sender, EventArgs e) { if (Validation.ValidateCombo(ref cmbClients)) { Client current = (Client)bind1.Current; List <Contract> contracts = new Contract().GetAllContracts(current.ClientIdentifier); if (contracts.Count > 0) { foreach (Contract item in contracts) { if (item.DateOfIssue.AddMonths(item.TermDuration) > DateTime.UtcNow) { ServiceLevel sl = new ServiceLevel().GetServiceLevels(item.SLevel.Level)[0]; List <ContractProducts> cp = new ContractProducts(item, new Product()).GetContractProducts(); List <ContractConfigurations> cc = new ContractConfigurations(item).GetContractConfigurations(); List <Billing> b = new Billing(current, DateTime.UtcNow, 0, 0).GetClientBilling(); int monthsLeft = DateDifference.GetMonthDifference(item.DateOfIssue, item.DateOfIssue.AddMonths(item.TermDuration)); if (monthsLeft > 0) { chcDiffPaid.Visible = true; int monthsPaid = DateDifference.GetMonthDifference(item.DateOfIssue, DateTime.UtcNow); double serviceFeePaid = monthsPaid * sl.MonthlyCost; double sumProductCost = (from cProd in cp select cProd.ContractProducts_Product.BasePrice).Sum(); double sumAddCosts = (from cConf in cc select cConf.ContractConfigurations_Configuration.AddCost).Sum(); double sumProductCostPaid = (from bProd in b select bProd.AmountPaid).Sum() - serviceFeePaid; outstandingAmount = (sumProductCost + sumAddCosts) - sumProductCostPaid; } else { chcDiffPaid.Visible = false; } txtOutstanding.Text = "R" + outstandingAmount.ToString(); txtOutstanding.Visible = true; lblOutstanding.Visible = true; btnCalculateOutstanding.Visible = false; break; } } } else { MessageBoxShower.ShowInfo("This client does not have any active contracts.", "Cannot Cancel contract"); txtOutstanding.Visible = false; lblOutstanding.Visible = false; chcDiffPaid.Visible = false; } } }
private void btnLogin_Click(object sender, EventArgs e) { User u = new User(txtUsername.Text, txtPassword.Text, "", "", "", ""); if (u.TestLogin(ref u)) { frmMain.loggedIn = u; frmMain.lh.LogIn(); MessageBoxShower.ShowInfo("Welcome " + u.Username, "Log in succesful!"); this.Close(); } else { CustomExceptions error = new CustomExceptions("Could not Log in. Please try again.", "Login Failed!"); } }
private void btnCancelClient_Click(object sender, EventArgs e) { if (Validation.ValidateCombo(ref cmbClients)) { Client current = (Client)bind1.Current; Contract c = new Contract().GetAllContracts(current.ClientIdentifier)[0]; current.Status = "Inactive"; c.TermDuration = c.TermDuration - Convert.ToInt32((DateAndTime.DateDiff(DateInterval.Month, c.DateOfIssue.AddMonths(c.TermDuration), DateTime.UtcNow))); if ((outstandingAmount > 0) && (chcDiffPaid.Checked)) { Billing b = new Billing(current, DateTime.UtcNow, outstandingAmount, outstandingAmount); if (b.InsertBilling()) { if (current.UpdateClient() && c.UpdateContract()) { MessageBoxShower.ShowInfo("Client Deactivated", "Cancel Contract"); this.Close(); } else { CustomExceptions error = new CustomExceptions("The client contract could not be cancelled.", "Contract Cancel Failed!"); } } else { CustomExceptions error = new CustomExceptions("The client payment could not be recorded.", "Contract Cancel Failed!"); } } else if (outstandingAmount <= 0) { if (current.UpdateClient() && c.UpdateContract()) { MessageBoxShower.ShowInfo("Client Deactivated", "Cancel Contract"); this.Close(); } else { CustomExceptions error = new CustomExceptions("The client contract could not be cancelled.", "Contract Cancel Failed!"); } } } else { CustomExceptions error = new CustomExceptions("No client selected!", "Something went wrong.."); } }
public static string CatchError(Func <string, string> func, string argument) { try { return(func(argument)); } catch (Exception e) when(e is FileNotFoundException || e is DirectoryNotFoundException) { MessageBoxShower.DisplayDialog("❌Error", "ファイルパスに間違いがあります。\n" + e.Message, "OK"); return(e.Message); } catch (ArgumentException e) { MessageBoxShower.DisplayDialog("❌Error", "ファイルパスが空欄です。\n" + e.Message, "OK"); return(e.Message); } }
private void btnUpdateVendor_Click(object sender, EventArgs e) { if (ValidateVendor()) { Vendor vend = (Vendor)vendBind.Current; if (vend.UpdateVendor()) { MessageBoxShower.ShowInfo("Vendor updated!", "Success!"); } else { CustomExceptions error = new CustomExceptions("The vendor could not be updated. Please try again later.", "Something went wrong"); } } else { CustomExceptions error = new CustomExceptions("Please complete all fields correctly.", "Validation Error"); } }
private void btnUpdateUser_Click(object sender, EventArgs e) { if (ValidateUser() && ValidatePassword()) { User u = (User)userBind.Current; if (u.UpdateUser()) { MessageBoxShower.ShowInfo("The user was successfully updated.", "Success!"); } else { CustomExceptions error = new CustomExceptions("The user could not be updated.Please try again later.", "Something went wrong.."); } } else { CustomExceptions error = new CustomExceptions("Please complete all fields correctly.", "Validation Error!"); } }
private void btnAddClient_Click(object sender, EventArgs e) { if (ValidateForm()) { Client client = new Client(txtId.Text, txtName.Text, txtSurname.Text, new Address("", txtLine1.Text, txtLine2.Text, txtCity.Text, txtPostalCode.Text), new Contact("", txtCell.Text, txtEmail.Text), cmbPayment.SelectedItem.ToString(), "Active"); if (NoDuplicates(client)) { if (cmbPayment.SelectedItem.ToString() == "Debit Order") { if (client.NewClientWithPaymentDet(txtAccNr.Text, txtBank.Text, txtBranch.Text)) { MessageBoxShower.ShowInfo("The client was added succesfully!", "Success!"); this.Close(); } else { CustomExceptions error = new CustomExceptions("The client could not be added. Please try again.", "Failure!"); } } else { if (client.NewClient()) { MessageBoxShower.ShowInfo("The client was added succesfully!", "Success!"); this.Close(); } else { CustomExceptions error = new CustomExceptions("The client could not be added. Please try again.", "Failure!"); } } } else { CustomExceptions error = new CustomExceptions("The client already exists.", "Cannot add client"); } } else { CustomExceptions error = new CustomExceptions("Please fill in all fields correctly.", "Faulure!"); } }
private void btnUpdate_Click(object sender, EventArgs e) { bool success = true; Product p = (Product)prodBind.Current; if (p.UpdateProduct()) { foreach (SystemComponents item in compsToUpdate) { if (ValidateComponentInfo(item)) { if (!item.UpdateComponent()) { success = false; } } else { CustomExceptions error = new CustomExceptions("Cannot update component " + item.Model + " due to incorrect input.", "Validation error!"); } } foreach (Configurations item in confsToUpdate) { if (!item.UpdateConfig()) { success = false; } } } else { CustomExceptions error = new CustomExceptions("The product could not be updated. Please try again.", "Something went wrong.."); } if (!success) { CustomExceptions error = new CustomExceptions("Not all configurations was updated. Please try again.", "Something went wrong.."); } else { MessageBoxShower.ShowInfo("The product and its configurations was updated successfully!", "Success!"); } }
private void btnReqEvent_Click(object sender, EventArgs e) { if (ValidateEvent()) { RequestedEvents reqEvent = new RequestedEvents((Client)clientBind.Current, dtpReqDate.Value, cmbStatus.SelectedItem.ToString(), txtRemarks.Text, cmbSkill.SelectedItem.ToString()); if (reqEvent.NewEvent()) { MessageBoxShower.ShowInfo("The event has been logged succesfully.", "Success"); Scheduler.ScheduleEvents(); } else { CustomExceptions error = new CustomExceptions("The event could not be scheduled. Please try again later.", "Success"); } } else { CustomExceptions error = new CustomExceptions("Please complete all fields correctly.", "Validation Error!"); } }
private void btnRemoveUser_Click(object sender, EventArgs e) { if (Validation.ValidateCombo(ref cmbUsers)) { User u = (User)userBind.Current; if (u.RemoveUser()) { MessageBoxShower.ShowInfo("The User have been successfully removed!", "User Removed!"); this.Close(); } else { CustomExceptions error = new CustomExceptions("The user could not be removed. Please try again later.", "Failure!"); } } else { CustomExceptions error = new CustomExceptions("Please select a client to remove.", "No client selected."); } }
private void btnUpdateEvent_Click(object sender, EventArgs e) { if (Validation.ValidateCombo(ref cmbEvents) && Validation.ValidateCombo(ref cmbTechs)) { RequestedEvents currentEvent = (RequestedEvents)eventBind.Current; TechnicalLog tl = new TechnicalLog(currentEvent, (Technicians)techBind.Current); if (currentEvent.UpdateEvent() && tl.LogEvent()) { MessageBoxShower.ShowInfo("The event was successfully updated.", "Success!"); } else { CustomExceptions error = new CustomExceptions("The event could not be updated. Please try again later.", "Something went wrong.."); } Scheduler.ScheduleEvents(); } else { CustomExceptions error = new CustomExceptions("Please complete all fields correctly.", "Validation Error"); } }
public void Execute() { if (Process != null) { return; } try { ExecuteProcess(); } catch (Win32Exception e) { EndProcess(this, EventArgs.Empty); MessageBoxShower.DisplayDialog("❌Error", "ファイルパスに間違いがあります。\n" + e.Message, "OK"); } catch (InvalidOperationException e) { EndProcess(this, EventArgs.Empty); MessageBoxShower.DisplayDialog("❌Error", "ファイルパスが存在しません。\n" + e.Message, "OK"); } }
private void btnAddUser_Click(object sender, EventArgs e) { if (ValidateUser() && ValidatePassword()) { User u = new User(txtUsername.Text, txtPassword.Text, txtName.Text, txtSurname.Text, txtEmail.Text, cmbAccess.SelectedItem.ToString()); if (NoDuplicates(u)) { if (u.InsertUser()) { MessageBoxShower.ShowInfo("User Inserted!", "Success!"); this.Close(); } else { CustomExceptions error = new CustomExceptions("The user could not be inserted. Please try again.", "Something went wrong.."); } } else { CustomExceptions error = new CustomExceptions("A User with this email has already been added. Please update.", "Cannot add user."); } } }
private void btnFinish_Click(object sender, EventArgs e) { if (contract.InsertContract() && SubmitAllProducts() && SubmitAllConfigs()) { MessageBoxShower.ShowInfo("The Contract has been recorded successfully.", "Success!"); Client current = client; double outstandingAmount = 0; List <Contract> contracts = new Contract().GetAllContracts(current.ClientIdentifier); if (contracts.Count > 0) { foreach (Contract item in contracts) { if (item.DateOfIssue.AddMonths(item.TermDuration) > DateTime.UtcNow) { ServiceLevel sl = new ServiceLevel().GetServiceLevels(item.SLevel.Level)[0]; List <ContractProducts> cp = new ContractProducts(item, new Product()).GetContractProducts(); List <ContractConfigurations> cc = new ContractConfigurations(item).GetContractConfigurations(); List <Billing> b = new Billing(current, DateTime.UtcNow, 0, 0).GetClientBilling(); int monthsLeft = DateDifference.GetMonthDifference(item.DateOfIssue, item.DateOfIssue.AddMonths(item.TermDuration)); if (monthsLeft > 0) { int monthsPaid = DateDifference.GetMonthDifference(item.DateOfIssue, DateTime.UtcNow); double serviceFeePaid = monthsPaid * sl.MonthlyCost; double sumProductCost = (from cProd in cp select cProd.ContractProducts_Product.BasePrice).Sum(); double sumAddCosts = (from cConf in cc select cConf.ContractConfigurations_Configuration.AddCost).Sum(); double sumProductCostPaid = (from bProd in b select bProd.AmountPaid).Sum() - serviceFeePaid; outstandingAmount = (sumProductCost + sumAddCosts) - sumProductCostPaid; } Billing bill = new Billing(client, DateTime.UtcNow, outstandingAmount, 0); bill.InsertBilling(); } } } } this.Close(); }
private void btnFinish_Click(object sender, EventArgs e) { bool success = true; if (p.InsertProduct()) { foreach (SystemComponents item in addComponents) { if (!item.InsertComponent()) { success = false; } } foreach (Configurations item in addConfigurations) { if (!item.InsertConfig()) { success = false; } } } else { CustomExceptions error = new CustomExceptions("The product could not be added succesfully. Please try again.", "Product Error!"); } if (success) { MessageBoxShower.ShowInfo("The product and its components have been registered.", "Success"); this.Close(); } else { CustomExceptions error = new CustomExceptions("The product could not be extended/configured succesfully. Please update to ensure correctness.", "Product Error!"); } }
public EditorController() { _questionShower = new QuestionMessageBoxShower(); _warningShower = new WarningMessageBoxShower(); }
/// <summary> /// インフォメーションメッセージを表示 /// </summary> /// <param name="message">表示したいメッセージ</param> public static void InfoMessageShow(string message) { MessageBoxShower.InfoMessage(message); }
public SelectFileFromDbController() { _messageBoxShower = new WarningMessageBoxShower(); }
public EnterFileNameController() { _messageBoxShower = new WarningMessageBoxShower(); }