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 SignUpForm_FormClosing(object sender, System.ComponentModel.CancelEventArgs e) { if (!_success) { CustomerForm customerForm = Application.OpenForms.OfType <CustomerForm>().FirstOrDefault(); customerForm.EnableButtons(true); } }
private void CustomerMenu_Click(object sender, EventArgs e) { CustomerForm customerForm = new CustomerForm(); if (Application.OpenForms.OfType <ProfileForm>().FirstOrDefault() != null) { customerForm.EnableButtons(false); } customerForm.Dock = DockStyle.Right; customerForm.MdiParent = this; customerForm.TopLevel = false; customerForm.Closed += CustomerForm_Closed; EnableCustomerMenu(false); customerForm.Show(); }
private void ProfileForm_FormClosing(object sender, System.ComponentModel.CancelEventArgs e) { if (Application.OpenForms.OfType <CartForm>().Count() > 0) { e.Cancel = true; string message = "You have a pending purchase."; string caption = "Please checkout/close your cart first."; MessageBox.Show(message, caption, MessageBoxButtons.OK); } else { CustomerForm customerForm = Application.OpenForms.OfType <CustomerForm>().FirstOrDefault(); if (customerForm != null) { customerForm.EnableButtons(true); } else { MainForm mainForm = Application.OpenForms.OfType <MainForm>().FirstOrDefault(); mainForm.EnableCustomerMenu(true); } } }