public static void OpenTab(string dllName, string className, bool finishDelivery = false) { if (String.IsNullOrEmpty(dllName) || String.IsNullOrEmpty(className)) { return; } JsonRequest request = new JsonRequest(); ProcAction action = request.NewAction(); action.proc = "sql"; action.text = "SELECT menu_id, menu_name, dll_name, class_name, close_yn, open_yn, menu_type"; action.text += " FROM tb_sys_menu "; action.text += " WHERE dll_name = #{dll_name} AND class_name = #{class_name}"; action.table = "0"; action.param.Add("dll_name", dllName); action.param.Add("class_name", className); WebClient client = new WebClient(); DataSet ds = client.Execute(request); if (ds == null) { return; } DataTable dt = ds.Tables["0"]; MenuTabInfo info = new MenuTabInfo(); if (dt.Rows.Count == 1) { info.menuId = (int)dt.Rows[0]["menu_id"]; info.menuText = CommonUtil.Converter.GetNameDictionary(dt.Rows[0]["menu_name"].ToString()); info.dllName = dt.Rows[0]["dll_name"] as string; info.className = dt.Rows[0]["class_name"] as string; info.haveClose = dt.Rows[0]["close_yn"].ToString() == "Y" ? true : false; info.canOpen = dt.Rows[0]["open_yn"].ToString() == "Y" ? true : false; info.type = dt.Rows[0]["menu_type"] as string; OpenMenuTap(info, finishDelivery); } }
private static void OpenMenuTap(MenuTabInfo info, bool finishDelivery = false) { if (info == null) { return; } foreach (XtraTabPage page in tabControl.TabPages) { MenuTabInfo curInfo = page.Tag as MenuTabInfo; if (curInfo == null) { continue; } if (curInfo.menuId == info.menuId) { tabControl.SelectedTabPage = page; if (curInfo.form != null && (curInfo.form.Name == "COM_Home" || curInfo.form.Name == "SOD_Order" || curInfo.form.Name == "SOD_Pickup" || curInfo.form.Name == "SOD_Delivery" || curInfo.form.Name == "SOD_Return")) { curInfo.form.Focus(); } XtraUserControl form = curInfo.form; if (form == null) { return; } MethodInfo mInfo = null; if (!String.IsNullOrEmpty(ord_no)) { PropertyInfo ordNo = form.GetType().GetProperty("ordNo"); ordNo.SetValue(form, ord_no); if (curInfo.form.Name == "SOD_Delivery" && finishDelivery) { bolConfirmMessage = true; mInfo = form.GetType().GetMethod("InitFromDoubleClickAndHandle", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, new Type[0], null); } else { mInfo = form.GetType().GetMethod("InitFromDoubleClick", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, new Type[0], null); } ord_no = String.Empty; } else if (!(String.IsNullOrEmpty(pick_ord_yn) && String.IsNullOrEmpty(pick_yn) && String.IsNullOrEmpty(delv_ord_yn) && String.IsNullOrEmpty(delv_yn))) { PropertyInfo pickOrdYn = form.GetType().GetProperty("pickOrdYn"); pickOrdYn.SetValue(form, pick_ord_yn); PropertyInfo pickYn = form.GetType().GetProperty("pickYn"); pickYn.SetValue(form, pick_yn); PropertyInfo delvOrdYn = form.GetType().GetProperty("delvOrdYn"); delvOrdYn.SetValue(form, delv_ord_yn); PropertyInfo delvYn = form.GetType().GetProperty("delvYn"); delvYn.SetValue(form, delv_yn); mInfo = form.GetType().GetMethod("InitFromDoubleClick", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, new Type[0], null); } else { mInfo = form.GetType().GetMethod("Search", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, new Type[0], null); } if (mInfo != null) { mInfo.Invoke(form, null); } return; } } if (!info.canOpen) { return; } try { XtraTabPage page = new XtraTabPage(); page.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); page.Text = info.menuText[AccessDB.GetConfig("lang")]; page.Tag = info; page.Font = new System.Drawing.Font("맑은 고딕", 9F); page.Appearance.Header.Font = new System.Drawing.Font("맑은 고딕", 9F); page.Appearance.HeaderActive.Font = new System.Drawing.Font(page.Font.FontFamily.Name, page.Font.Size, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129))); page.Appearance.HeaderDisabled.Font = new System.Drawing.Font("맑은 고딕", 9F); page.Appearance.HeaderHotTracked.Font = new System.Drawing.Font("맑은 고딕", 9F); page.Appearance.PageClient.Font = new System.Drawing.Font("맑은 고딕", 9F); page.ShowCloseButton = info.haveClose ? DevExpress.Utils.DefaultBoolean.True : DevExpress.Utils.DefaultBoolean.False; tabControl.TabPages.Add(page); tabControl.SelectedTabPage = page; string dllPath = Application.StartupPath + @"\" + info.dllName + @".dll"; Type type = null; try { Assembly asm = Assembly.LoadFrom(dllPath); type = asm.GetType(info.dllName + "." + info.className); } catch (Exception er) { type = null; } if (type == null) { return; } XtraUserControl form = null; bolConfirmMessage = true; if (!String.IsNullOrEmpty(ord_no)) { form = Activator.CreateInstance(type, ord_no) as XtraUserControl; ord_no = String.Empty; } else if (!(String.IsNullOrEmpty(pick_ord_yn) && String.IsNullOrEmpty(pick_yn) && String.IsNullOrEmpty(delv_ord_yn) && String.IsNullOrEmpty(delv_yn))) { form = Activator.CreateInstance(type, pick_ord_yn, pick_yn, delv_ord_yn, delv_yn) as XtraUserControl; } else { form = Activator.CreateInstance(type) as XtraUserControl; } if (form == null) { return; } info.form = form; form.Tag = info; form.Visible = false; page.Controls.Add(form); form.Dock = DockStyle.Fill; form.Visible = true; if (form.Name == "COM_Home" || form.Name == "SOD_Order" || form.Name == "SOD_Pickup" || form.Name == "SOD_Delivery" || form.Name == "SOD_Return") { form.Focus(); } //MethodInfo mInfo = null; //if (!String.IsNullOrEmpty(ord_no)) //{ // PropertyInfo ordNo = form.GetType().GetProperty("ordNo"); // ordNo.SetValue(form, ord_no); // // if (form.Name == "SOD_Delivery" && finishDelivery) mInfo = form.GetType().GetMethod("InitFromDoubleClickAndHandle", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, new Type[0], null); // else mInfo = form.GetType().GetMethod("InitFromDoubleClick", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, new Type[0], null); // ord_no = String.Empty; // //} //else if (!(String.IsNullOrEmpty(pick_ord_yn) && String.IsNullOrEmpty(pick_yn) // && String.IsNullOrEmpty(delv_ord_yn) && String.IsNullOrEmpty(delv_yn))) //{ // PropertyInfo pickOrdYn = form.GetType().GetProperty("pickOrdYn"); // pickOrdYn.SetValue(form, pick_ord_yn); // PropertyInfo pickYn = form.GetType().GetProperty("pickYn"); // pickYn.SetValue(form, pick_yn); // PropertyInfo delvOrdYn = form.GetType().GetProperty("delvOrdYn"); // delvOrdYn.SetValue(form, delv_ord_yn); // PropertyInfo delvYn = form.GetType().GetProperty("delvYn"); // delvYn.SetValue(form, delv_yn); // // mInfo = form.GetType().GetMethod("InitFromDoubleClick", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, new Type[0], null); // //} //else //{ // mInfo = form.GetType().GetMethod("Search", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, new Type[0], null); // //} // //if (mInfo != null) //{ // mInfo.Invoke(form, null); //} } catch (Exception err) { } }