Exemple #1
0
        private void ChildClick(object sender, EventArgs e)
        {
            String         Seqtx         = "SELECT FormName FROM Menu_Sub WHERE MenuDescription='" + 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() == "frmDepartment")
                        {
                            frmDepartment D = new frmDepartment();
                            D.EID    = tsslEID.Text.ToString();
                            D.CompID = tsslCompID.Text.ToString();
                            D.ShowDialog();
                            D.EID    = tsslEID.Text.ToString();
                            D.CompID = tsslCompID.Text.ToString();
                        }
                        else if (dtransaction.Rows[0][0].ToString() == "frmProductHirachy")
                        {
                            frmProductHirachy ph = new frmProductHirachy();
                            ph.EID    = tsslEID.Text.ToString();
                            ph.CompID = tsslCompID.Text.ToString();
                            ph.ShowDialog();
                            ph.EID    = tsslEID.Text.ToString();
                            ph.CompID = tsslCompID.Text.ToString();
                        }

                        else if (dtransaction.Rows[0][0].ToString() == "FrmTable")
                        {
                            FrmTable tab = new FrmTable();
                            tab.EID    = tsslEID.Text.ToString();
                            tab.CompID = tsslCompID.Text.ToString();
                            tab.ShowDialog();
                            tab.EID    = tsslEID.Text.ToString();
                            tab.CompID = tsslCompID.Text.ToString();
                        }
                        else if (dtransaction.Rows[0][0].ToString() == "frmsupplier")
                        {
                            frmsupplier sup = new frmsupplier();
                            sup.EID    = tsslEID.Text.ToString();
                            sup.CompID = tsslCompID.Text.ToString();
                            sup.ShowDialog();
                            sup.EID    = tsslEID.Text.ToString();
                            sup.CompID = tsslCompID.Text.ToString();
                        }
                        else if (dtransaction.Rows[0][0].ToString() == "frmCustomer")
                        {
                            frmCustomer c = new frmCustomer();
                            c.EID    = tsslEID.Text.ToString();
                            c.CompID = tsslCompID.Text.ToString();
                            c.ShowDialog();
                            c.EID    = tsslEID.Text.ToString();
                            c.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();
                        }
                    }
                }
            }
        }
Exemple #2
0
        private void btnSupplier_Click(object sender, EventArgs e)
        {
            frmsupplier frmsup = new frmsupplier();

            frmsup.ShowDialog();
        }