private void DetailClick(object sender, EventArgs e) { String Seqtx = "SELECT DFormName FROM Menu_Detail WHERE DMenuDescription='" + sender.ToString() + "'"; SqlDataAdapter datransaction = new SqlDataAdapter(Seqtx, con); DataTable dtransaction = new DataTable(); datransaction.Fill(dtransaction); Assembly frmAssembly = Assembly.LoadFile(Application.ExecutablePath); foreach (Type type in frmAssembly.GetTypes()) { if (type.BaseType == typeof(Form)) { if (type.Name == dtransaction.Rows[0][0].ToString()) { if (dtransaction.Rows[0][0].ToString() == "frmPO") { frmPO PO = new frmPO(); PO.EID = tsslEID.Text.ToString(); PO.CompID = tsslCompID.Text.ToString(); PO.ShowDialog(); PO.EID = tsslEID.Text.ToString(); PO.CompID = tsslCompID.Text.ToString(); } else if (dtransaction.Rows[0][0].ToString() == "frmSalesOrder") { frmSalesOrder SO = new frmSalesOrder(); SO.EID = tsslEID.Text.ToString(); SO.CompID = tsslCompID.Text.ToString(); SO.ShowDialog(); SO.EID = tsslEID.Text.ToString(); SO.CompID = tsslCompID.Text.ToString(); } else if (dtransaction.Rows[0][0].ToString() == "frmPOS") { frmPOS pos = new frmPOS(); pos.EID = tsslEID.Text.ToString(); //pos.CompID = tsslCompID.Text.ToString(); pos.ShowDialog(); pos.EID = tsslEID.Text.ToString(); //pos.CompID = tsslCompID.Text.ToString(); } else if (dtransaction.Rows[0][0].ToString() == "frmUOM") { frmUOM uom = new frmUOM(); uom.EID = tsslEID.Text.ToString(); uom.CompID = tsslCompID.Text.ToString(); uom.ShowDialog(); uom.EID = tsslEID.Text.ToString(); uom.CompID = tsslCompID.Text.ToString(); } else { Form frmShow = (Form)frmAssembly.CreateInstance(type.ToString()); // then we close all of the child Forms with simple below code foreach (Form form in this.MdiChildren) { form.Close(); } frmShow.ShowDialog(); } } } } }
private void button1_Click(object sender, EventArgs e) { frmUOM frmuom = new frmUOM(); frmuom.ShowDialog(); }