private void PurchaseHistoryListView_DoubleClick(object sender, System.EventArgs e) { if (purchaseListView.SelectedItems.Count > 0) { int id = purchaseListView.SelectedItems[0].SubItems[1].Text.ToInt(-1); CustomerForm customerForm = Application.OpenForms.OfType <CustomerForm>().FirstOrDefault(); if (customerForm != null) { customerForm.EnableButtons(false); } ProfileForm profileForm = Application.OpenForms.OfType <ProfileForm>().FirstOrDefault(); if (profileForm == null) { ProfileForm profileNewForm = new ProfileForm(id); profileNewForm.MdiParent = this.ParentForm; profileNewForm.Show(); this.Close(); } else { string caption = "Error."; string message = "Please close the current profile."; MessageBox.Show(message, caption, MessageBoxButtons.OK); } } }
private void ConfirmButton_Click(object sender, System.EventArgs e) { try { int id = textBoxMemberId.Text.ToInt(-1); Customer customer = _manager.GetById(id); if (customer == null) { string message = "Entered ID can't be found."; string caption = "Please try again."; MessageBox.Show(message, caption, MessageBoxButtons.OK); } else { EnableButtons(false); ProfileForm profileForm = new ProfileForm(id); profileForm.MdiParent = this.ParentForm; profileForm.Show(); } } catch (Exception ex) { Logger.log.Error(ex.ToString()); } }
private void CartForm_FormClosing(object sender, System.ComponentModel.CancelEventArgs e) { if (ComputeTotalPrice() <= 0) { List <Purchase> purchases = new List <Purchase>() { new Purchase { Id = _purchase.Id } }; if (!_purchaseManager.Delete(purchases)) { Logger.log.Error($"A pending purchase with id {_purchase.Id} can't be deleted."); } } ItemsForm itemsForm = Application.OpenForms.OfType <ItemsForm>().FirstOrDefault(); if (itemsForm != null) { itemsForm.Close(); } ProfileForm profileForm = Application.OpenForms.OfType <ProfileForm>().FirstOrDefault(); profileForm.LoadData(); profileForm.EnableNewPurchaseButton(true); }
private void SubmitButton_Click(object sender, EventArgs e) { try { if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) || string.IsNullOrWhiteSpace(textBoxMiddleName.Text) || string.IsNullOrWhiteSpace(textBoxLastName.Text) || string.IsNullOrWhiteSpace(textBoxAddress.Text) || string.IsNullOrWhiteSpace(textBoxEmail.Text) || string.IsNullOrWhiteSpace(textBoxPhone.Text) || Controls.OfType <RadioButton>().FirstOrDefault(x => x.Checked) == null) { string message = "All fields must be fill up."; string caption = "Please try again."; DialogResult result = MessageBox.Show(message, caption, MessageBoxButtons.OK); } else { Customer customer = new Customer(); customer.FirstName = textBoxFirstName.Text; customer.MiddleName = textBoxMiddleName.Text; customer.LastName = textBoxLastName.Text; customer.Gender = Controls.OfType <RadioButton>().FirstOrDefault(x => x.Checked).Text; customer.ContactNo = textBoxPhone.Text; customer.Email = textBoxEmail.Text; customer.Address = textBoxAddress.Text; if ((customer.Id = _manager.Add(customer)) > 0) { _success = true; CustomerForm customerForm = Application.OpenForms.OfType <CustomerForm>().FirstOrDefault(); customerForm.LoadData(); ProfileForm profileForm = new ProfileForm(customer.Id); profileForm.MdiParent = this.ParentForm; profileForm.Show(); this.Close(); } else { string message = string.Empty; string caption = "Please try again."; DialogResult result = MessageBox.Show(message, caption, MessageBoxButtons.OK); } } } catch (Exception ex) { Logger.log.Error(ex.ToString()); } }