Exemple #1
0
        private void menuItem_Click(object sender, System.EventArgs e)
        {
            string[]      formArg  = null;
            ToolStripItem menuItem = (ToolStripItem)sender;

            //传视图
            string name = menuItem.Text;

            FormArg.Name = name; //窗体名称
            FormArg.Name = name; //窗体名称
            string    sql = "select ctcs from xt_gn where gnmc='" + name + "'";
            DataTable dt  = new DataTable();

            dt = base.SqlDBAgent.GetDataTable(sql);
            if (dt.Rows.Count > 0)
            {
                FormArg.Arg = dt.Rows[0][0].ToString();//视图名称
            }
            string formName = menuItem.Name;

            if (formName.Length <= 0)
            {
                return;
            }
            try
            {
                Type Dlg;
                if (formName.Substring(0, 4) == "MZGL")
                {
                    Assembly assembly = Assembly.LoadFrom(Application.StartupPath + @"/MZGL.dll");
                    Dlg = assembly.GetType(formName);
                }
                else if (formName.Substring(0, 4) == "MZYS")
                {
                    Assembly assembly = Assembly.LoadFrom(Application.StartupPath + @"/MZYS.dll");
                    Dlg = assembly.GetType(formName);
                }
                else
                {
                    Dlg = Type.GetType(formName);
                }
                if (!ShowChildrenForm(menuItem.Name))
                {
                    Form f = (Form)Dlg.InvokeMember(null, System.Reflection.BindingFlags.CreateInstance, null, null, formArg);
                    f.MdiParent = objmainForm;
                    f.Show();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }