private async void btnDelete_Click(object sender, EventArgs e) { Loans loans = new Loans(); if (MetroFramework.MetroMessageBox.Show(this, "Are you sure you want to delete this borrower?", "Borrower", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, this.Height / 2) == DialogResult.Yes) { if (loans.IfHasLoan(id) == 0) { if (await borrower.Delete(id)) { this.Message(borrower.msg, "Borrower", false); this.Hide(); using (frmViewBorrowers frm = new frmViewBorrowers()) { frm.ShowDialog(); } } else { this.Message(borrower.msg, "Borrower", true); } } else { this.Message("Warning! Borrower has an active loan, you can't delete him.", "Borrower", true); } } }
private void btnBorrowers_Click(object sender, EventArgs e) { using (frmViewBorrowers frm = new frmViewBorrowers()) { frm.ShowDialog(); } }
private void metroTile5_Click(object sender, EventArgs e) { this.Hide(); using (frmViewBorrowers frm = new frmViewBorrowers()) { frm.ShowDialog(); } }
private async void btnSave_Click(object sender, EventArgs e) { if (this.ValidateInputs(txtFirstName.Text, txtLastname.Text, txtMiddlename.Text, txtAddress.Text, txtContacts.Text, txtBday.Text, txtOccupation.Text, txtMonthlySalary.Text)) { this.Message("Warning! Please Fill Up All Fields.", "Input Validation", true); return; } if (ValidateAlpha(txtFirstName.Text) || ValidateAlpha(txtLastname.Text) || ValidateAlpha(txtOccupation.Text) || ValidateNumeric(txtContacts.Text) || ValidateNumeric(txtMonthlySalary.Text)) { this.Message("Warning! Invalid Characters are Detected. Please use letters and spaces only.", "Input Validation", true); return; } if (bdayValidation) { this.Message("Warning! Please input correct birthday.", "Input Validation", true); return; } string[] dob = txtBday.Text.Split('/'); DateTime birthday = new DateTime(int.Parse(dob[2]), int.Parse(dob[0]), int.Parse(dob[1])); BorrowerModel b = new BorrowerModel() { Id = id, FirstName = txtFirstName.Text.ToUpper(), LastName = txtLastname.Text.ToUpper(), MiddleName = txtMiddlename.Text.ToUpper(), Address = txtAddress.Text.ToUpper(), ContactNumber = txtContacts.Text, Birthday = birthday, Occupation = txtOccupation.Text.ToUpper(), MonthlySalary = Convert.ToDecimal(txtMonthlySalary.Text), Gender = optMale.Checked == true ? "MALE" : "FEMALE", CivilStatus = cboCivilStatus.SelectedItem.ToString(), }; if (operation == "update") { b.Image = _image; if (await borrower.Update(b)) { if (b.Image.Contains("default") && b.Image != _image) { img.CopyImage(_image, b.Image); } this.Message(borrower.msg, "Borrower", false); this.Hide(); using (frmViewBorrowers frm = new frmViewBorrowers()) { frm.ShowDialog(); } } else { this.Message(borrower.msg, "Borrower", true); } } else { b.Image = _image == "default.png" ? "images/" + _image : "images/" + img.RenameImage(_image); if (await borrower.Add(b)) { if (_image != "default.png") { MessageBox.Show(_image); img.CopyImage(_image, b.Image); } this.Message(borrower.msg, "Borrower", false); this.Hide(); using (frmViewBorrowers frm = new frmViewBorrowers()) { frm.ShowDialog(); } } else { this.Message(borrower.msg, "Borrower", true); } } }