private void viewTicketDetailsToolStripMenuItem_Click(object sender, EventArgs e) { string ticketnumber; if (lsvData.SelectedItems.Count == 0) { return; } else { ListViewItem item = lsvData.SelectedItems[0]; ticketnumber = item.SubItems[0].Text; string status = item.SubItems[5].Text; if (status == "Open") { frmSearchTicket searchticket = new frmSearchTicket(); searchticket.endorsed_ = true; searchticket.doubleclicked_ = true; searchticket.ticketnumber_ = ticketnumber; searchticket.username_ = lblUsername_.Text; searchticket.workgroup_ = lblWorkgroup_.Text; searchticket.db_ = lblDatabase_.Text; searchticket.Show(); getInfo(); } else { frmSearchTicket searchticket = new frmSearchTicket(); searchticket.doubleclicked_ = true; searchticket.ticketnumber_ = ticketnumber; searchticket.username_ = lblUsername_.Text; searchticket.workgroup_ = lblWorkgroup_.Text; searchticket.db_ = lblDatabase_.Text; searchticket.Show(); getInfo(); } } }
private void viewTicketDetailsToolStripMenuItem_Click(object sender, EventArgs e) { string ticketnumber; if (lsvData.SelectedItems.Count == 0) { return; } else { ListViewItem item = lsvData.SelectedItems[0]; ticketnumber = item.SubItems[0].Text; bool formRead = true; try { foreach (Form f in Application.OpenForms) { if (f is frmSearchTicket && formRead != false) { var Question = MessageBox.Show("Ticket registry is already open. Open another instance?", "System", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (Question == DialogResult.No) { f.Close(); formIsOpen = true; } else if (Question == DialogResult.Cancel) { return; } else { formRead = false; } } else { formIsOpen = false; } } } catch { frmSearchTicket searchticket = new frmSearchTicket(); searchticket.doubleclicked_ = true; searchticket.ticketnumber_ = ticketnumber; searchticket.username_ = lblUsername_.Text; searchticket.workgroup_ = lblWorkgroup_.Text; searchticket.db_ = lblDatabase_.Text; searchticket.Show(); } } switch (formIsOpen) { case false: { frmSearchTicket searchticket = new frmSearchTicket(); searchticket.doubleclicked_ = true; searchticket.ticketnumber_ = ticketnumber; searchticket.username_ = lblUsername_.Text; searchticket.workgroup_ = lblWorkgroup_.Text; searchticket.db_ = lblDatabase_.Text; searchticket.Show(); break; } default: { break; } } }