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 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> /// Uploads a file to a drive /// </summary> /// <param name="stream">Stream of your file to upload</param> /// <param name="contentType">MimeType of a file</param> /// <param name="body">Metadata of future file</param> /// <param name="parentFolderId">Id of parent folder for a new file</param> /// <returns>PGDriveResult which contains uploaded file metadata in response body</returns> public PGDriveResult <File> CreateFile(System.IO.Stream stream, string contentType, File body, string parentFolderId = null) { PGDriveResult <File> pGDriveResult = new PGDriveResult <File>(); try { FilesResource.CreateMediaUpload request; if (parentFolderId != null) { var folder = driveService.Files.Get(parentFolderId).Execute(); if (!folder.MimeType.Contains("folder")) { throw CustomExceptions.isNotAFolder(parentFolderId, driveService); } body.Parents = new List <string>() { parentFolderId }; } request = driveService.Files.Create(body, stream, contentType); request.Fields = DefaultFileFieldsOnResponse; request.Upload(); var file = request.ResponseBody; pGDriveResult.SetResponseBody(file); return(pGDriveResult); } catch (Google.GoogleApiException exception) { pGDriveResult.InitializeError(exception); return(pGDriveResult); } }
/// <summary> /// Creates a folder at the drive /// </summary> /// <param name="name">Name of folder</param> /// <param name="parentFolderId">Id of parent folder for new folder</param> /// <returns>PGDriveResult which contains created folder metadata in response body</returns> public PGDriveResult <File> CreateFolder(string name, string parentFolderId = null) { PGDriveResult <File> pGDriveResult = new PGDriveResult <File>(); try { FilesResource.CreateRequest request; var fileMetadata = new File(); fileMetadata.Name = name; fileMetadata.MimeType = "application/vnd.google-apps.folder"; if (parentFolderId != null) { var folder = driveService.Files.Get(parentFolderId).Execute(); if (!folder.MimeType.Contains("folder")) { throw CustomExceptions.isNotAFolder(parentFolderId, driveService); } fileMetadata.Parents = new List <string>() { parentFolderId }; } request = driveService.Files.Create(fileMetadata); request.Fields = DefaultFileFieldsOnResponse; var file = request.Execute(); pGDriveResult.SetResponseBody(file); return(pGDriveResult); } catch (Google.GoogleApiException exception) { pGDriveResult.InitializeError(exception); return(pGDriveResult); } }
private void btnAddComp_Click(object sender, EventArgs e) { if (ValidateComponentInfo()) { bool exist = false; SystemComponents sc = new SystemComponents("", p, redCompDesc.Text, "Active", txtCompManufacturer.Text, txtCompModel.Text); foreach (SystemComponents item in addComponents) { if ((item.Model == sc.Model) && (item.Manufacturer == sc.Manufacturer)) { item.Description = sc.Description; exist = true; break; } } if (!exist) { addComponents.Add(sc); lbComponents.Items.Add(sc); txtCompModel.Clear(); txtCompManufacturer.Clear(); redCompDesc.Clear(); } } else { CustomExceptions error = new CustomExceptions("Please fill in all required fields.", "Something went wrong.."); } }
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(); }
/// <summary> /// Moves file from one folder to another /// </summary> /// <param name="fileOrFolderId">Id of file or folder which yu want to move</param> /// <param name="newFolderId">Id of folder to which you want to move a file</param> /// <returns>PGDriveResult with moved file in response body</returns> public PGDriveResult <File> MoveFileToAntherFolder(string fileOrFolderId, string newFolderId) { PGDriveResult <File> pGDriveResult = new PGDriveResult <File>(); try { var getRequest = driveService.Files.Get(fileOrFolderId); var folderGetRequest = driveService.Files.Get(newFolderId); folderGetRequest.Fields = "mimeType"; var folder = folderGetRequest.Execute(); if (!folder.MimeType.Contains("folder")) { throw CustomExceptions.isNotAFolder(newFolderId, driveService); } getRequest.Fields = "parents"; var file = getRequest.Execute(); var previousParents = String.Join(",", file.Parents); var updateRequest = driveService.Files.Update(new File(), fileOrFolderId); updateRequest.Fields = "id, parents"; updateRequest.AddParents = newFolderId; updateRequest.RemoveParents = previousParents; file = updateRequest.Execute(); pGDriveResult.SetResponseBody(file); return(pGDriveResult); } catch (Google.GoogleApiException exception) { pGDriveResult.InitializeError(exception); return(pGDriveResult); } }
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 btnAddConf_Click(object sender, EventArgs e) { if (ValidateConfInfo()) { bool exist = false; Configurations c = new Configurations("", txtConfName.Text, redConfDesc.Text, (SystemComponents)lbComponentsConf.SelectedItem, Convert.ToDouble(txtAddCost.Text), "Active"); foreach (Configurations item in addConfigurations) { if (item.Name == c.Name) { item.Name = txtConfName.Text; item.Description = redConfDesc.Text; item.AddCost = Convert.ToDouble(txtAddCost.Text); exist = true; break; } } if (!exist) { addConfigurations.Add(c); lbComponentsConf.SelectedIndex = 0; } txtConfName.Clear(); redConfDesc.Clear(); txtAddCost.Clear(); } else { CustomExceptions error = new CustomExceptions("Please complete all fields.", "Failure!"); } }
public static void SetErrorMessageforLongOperations(String sMessage) { if (HttpContext.Current != null) { CustomExceptions.SetMessageVariable(HttpContext.Current, SPContext.Current.Web, sMessage + Constants.UNIQUE_KEY_CODE_FAILURE); } }
public static void ClearMessageFromUI(SPWeb web) { if (HttpContext.Current != null) { CustomExceptions.SetMessageVariable(HttpContext.Current, web, String.Empty); } }
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!"); } }
private bool ValidateUser() { bool valid = true; if (!Validation.ValidateTextbox(1, 50, "STRING", ref txtName)) { valid = false; } if (!Validation.ValidateTextbox(1, 50, "STRING", ref txtSurname)) { valid = false; } if (!Validation.ValidateTextbox(1, 50, "STRING", ref txtUsername)) { valid = false; } if (!Validation.ValidateTextbox(1, 50, "STRING", ref txtEmail)) { valid = false; } else { if (txtEmail.Text.IndexOf('@') == -1 || txtEmail.Text.IndexOf('.') == -1) { valid = false; CustomExceptions error = new CustomExceptions("Invalid Email", "Email error!"); } } if (!Validation.ValidateCombo(ref cmbAccess)) { valid = false; } return(valid); }
private void btnNextComp_Click(object sender, EventArgs e) { if (ValidateProductInfo()) { ContractProducts cp = new ContractProducts(contract, product); if (!products.Contains(cp)) { products.Add(cp); List <SystemComponents> comps = new SystemComponents(product).GetSystemComponents(); foreach (SystemComponents item in comps) { if (item.Status == "Discontinued") { comps.Remove(item); } } compBind.DataSource = comps; lbComponents.DataSource = compBind; pnlProducts.Hide(); pnlComponents.Show(); } else { CustomExceptions error = new CustomExceptions("This product has already been added to the contract.", "Duplicate Product"); } } else { CustomExceptions error = new CustomExceptions("Please select a product before you continue.", "No product selected"); } }
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!"); } }
public static void SetSuccessMessageforUI(SPWeb web, String sErrorMessage) { if (HttpContext.Current != null) { if (!String.IsNullOrEmpty(sErrorMessage)) { String sMessage = Constants.SUCCESS_MESSAGE_SYMBOL + sErrorMessage; CustomExceptions.SetMessageVariable(HttpContext.Current, web, sMessage); } } }
public static void SetErrorMessageforUI(String sErrorMessage) { if (HttpContext.Current != null) { if (!String.IsNullOrEmpty(sErrorMessage)) { String sMessage = Constants.ERROR_MESSAGE_SYMBOL + sErrorMessage; CustomExceptions.SetMessageVariable(HttpContext.Current, SPContext.Current.Web, sMessage); } } }
private void btnAnotherProduct_Click(object sender, EventArgs e) { if (CheckAllComponentsConfigured()) { pnlComponents.Hide(); pnlProducts.Show(); } else { CustomExceptions error = new CustomExceptions("Not all components have been configured.", "Configuration failed."); } }
public HttpResponseMessage Get(int id) { try { var result = _memberBusinessLogic.GetMemberById(id); return(Request.CreateResponse(HttpStatusCode.OK, result)); } catch (Exception exception) { CustomExceptions.WriteExceptionMessageToFile(exception); return(Request.CreateErrorResponse(HttpStatusCode.NotFound, exception.Message)); } }
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 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 bool ValidateVendor() { bool valid = true; if (!Validation.ValidateCombo(ref cmbVends)) { valid = false; } if (!Validation.ValidateTextbox(1, 50, "STRING", ref txtName)) { valid = false; } if (!Validation.ValidateTextbox(1, 30, "STRING", ref txtLine1)) { valid = false; } if (!Validation.ValidateTextbox(1, 30, "STRING", ref txtLine2)) { valid = false; } if (!Validation.ValidateTextbox(1, 20, "STRING", ref txtCity)) { valid = false; } if (!Validation.ValidateTextbox(1, 10, "INT", ref txtPostalCode)) { valid = false; } if (!Validation.ValidateTextbox(1, 50, "STRING", ref txtEmail)) { valid = false; } else { if (txtEmail.Text.IndexOf('@') == -1 || txtEmail.Text.IndexOf('.') == -1) { valid = false; CustomExceptions error = new CustomExceptions("Invalid Email", "Email error!"); } } if (!Validation.ValidateTextbox(10, 10, "INT", ref txtCell)) { valid = false; } return(valid); }
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.."); } }
private void btnDial_Click(object sender, EventArgs e) { lblDialing.Visible = true; if (cmbClients.SelectedIndex != -1) { current = (Client)bind1.Current; Thread.Sleep(10000); start = DateTime.UtcNow; callTime.Start(); tabCall.SelectedIndex = 1; btnAnswer.Visible = false; } else { CustomExceptions error = new CustomExceptions("Please select a client to call.", "Unable to call"); } }
public IHttpActionResult Post([FromBody] MemberViewModel memberViewModel) { try { if (memberViewModel == null) { return(BadRequest()); } var result = _memberBusinessLogic.CreateMember(memberViewModel); return(Ok(result)); } catch (Exception exception) { CustomExceptions.WriteExceptionMessageToFile(exception); return(InternalServerError(exception)); } }
private bool ValidatePassword() { bool valid = true; string password = ""; char[] specialChars = new char[] { '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '<', '>', '?', ',', '.', '/', '|', '-', '_' }; char[] upperCase = new char[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' }; char[] lowerCase = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' }; char[] nums = new char[] { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' }; if ((!Validation.ValidateTextbox(1, 8, "STRING", ref txtPassword)) || (!Validation.ValidateTextbox(1, 8, "STRING", ref txtRePw))) { CustomExceptions error_length = new CustomExceptions("Password should be exactly 8 characters long.", "Password Error!"); valid = false; } if (txtPassword.Text != txtRePw.Text) { CustomExceptions error_equals = new CustomExceptions("Password entry boxes does not match.", "Password Error!"); } else { password = txtPassword.Text; if (password.IndexOfAny(specialChars) == -1) { CustomExceptions error_special = new CustomExceptions("Password should contains at least 1 special character.", "Password Error!"); valid = false; } if (password.IndexOfAny(upperCase) == -1) { CustomExceptions error_upper = new CustomExceptions("Password should contains at least 1 uppercase character.", "Password Error!"); valid = false; } if (password.IndexOfAny(lowerCase) == -1) { CustomExceptions error_lower = new CustomExceptions("Password should contains at least 1 lowercase character.", "Password Error!"); valid = false; } if (password.IndexOfAny(nums) == -1) { CustomExceptions error_nums = new CustomExceptions("Password should contains at least 1 digit.", "Password Error!"); valid = false; } } return(valid); }
private void btnNextComp_Click(object sender, EventArgs e) { if (ValidateProductInfo()) { compBind.DataSource = new SystemComponents((Product)prodBind.Current).GetSystemComponents(); lbComponents.DataSource = compBind; txtCompName.DataBindings.Add("Text", compBind, "Model"); txtCompManufacturer.DataBindings.Add("Text", compBind, "Manufacturer"); redCompDesc.DataBindings.Add("Text", compBind, "Description"); cmbCompStatus.DataBindings.Add("Text", compBind, "Status"); pnlProduct.Hide(); pnlComp.Show(); } else { CustomExceptions error = new CustomExceptions("Please complete all fields correctly.", "Product cannot be created."); } }
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!"); } }
public async Task <IActionResult> Get() { try { var result = await _carService.GetCarsShowDetail(); return(Ok(new CustomResponse <List <CarMake> > { Code = ResponseHelpers.StatusCode.Success, Data = result })); } catch (Exception ex) { CommonLogger.LogError(ex); } return(Ok(CustomExceptions.GenerateExceptionForApp("Error getting cars"))); }