/// <summary> /// Run User Control /// </summary> /// <param name="userControl"></param> /// <param name="oContainerPanel"></param> public static void RunUserControl(XtraUserControl userControl, XtraPanel oContainerPanel) { if (CommonUserControl == null) { CommonUserControl = userControl; AddCotrolToPanel(oContainerPanel, CommonUserControl, typeof(XtraUserControl)); } else { if (CommonUserControl.GetType() != userControl.GetType()) { CommonUserControl = userControl; AddCotrolToPanel(oContainerPanel, CommonUserControl, typeof(XtraUserControl)); } } }
public static DelegationLib.DefinePermission CategoryPermission(XtraUserControl DanhMuc, string mainFeature) { #region DMGrid if (DanhMuc is DMGrid) { DMGrid basic = (DMGrid)DanhMuc; return delegate(object formCategory) { List<Object> items = new List<Object>(); ApplyPermissionAction.ApplyPermissionObject(items, basic, new PermissionItem(mainFeature, PermissionType.VIEW)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnAdd, new PermissionItem(mainFeature, PermissionType.ADD)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnDel, new PermissionItem(mainFeature, PermissionType.DELETE)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnUpdate, new PermissionItem(mainFeature, PermissionType.EDIT)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnSave, new PermissionItem(mainFeature, PermissionType.ADD_EDIT)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnNoSave, new PermissionItem(mainFeature, PermissionType.ADD_EDIT)); return items; }; } #endregion #region DMTreeGroup else if (DanhMuc is DMTreeGroup) { DMTreeGroup basic = (DMTreeGroup)DanhMuc; return delegate(object formCategory) { List<Object> items = new List<Object>(); ApplyPermissionAction.ApplyPermissionObject(items, basic, new PermissionItem(mainFeature, PermissionType.VIEW)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnAdd, new PermissionItem(mainFeature, PermissionType.ADD)); ApplyPermissionAction.ApplyPermissionObject(items, basic.addSameLevel, new PermissionItem(mainFeature, PermissionType.ADD)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnDel, new PermissionItem(mainFeature, PermissionType.DELETE)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnUpdate, new PermissionItem(mainFeature, PermissionType.EDIT)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnLuu, new PermissionItem(mainFeature, PermissionType.ADD_EDIT)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnKhongLuu, new PermissionItem(mainFeature, PermissionType.ADD_EDIT)); return items; }; } #endregion #region DMTreeGroupElement else if (DanhMuc is DMTreeGroupElement) { DMTreeGroupElement basic = (DMTreeGroupElement)DanhMuc; return delegate(object formCategory) { List<Object> items = new List<Object>(); ApplyPermissionAction.ApplyPermissionObject(items, basic, new PermissionItem(mainFeature, PermissionType.VIEW)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnAdd, new PermissionItem(mainFeature, PermissionType.ADD)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnDel, new PermissionItem(mainFeature, PermissionType.DELETE)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnUpdate, new PermissionItem(mainFeature, PermissionType.EDIT)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnSave, new PermissionItem(mainFeature, PermissionType.ADD_EDIT)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnNoSave, new PermissionItem(mainFeature, PermissionType.ADD_EDIT)); return items; }; } #endregion PLMessageBoxDev.ShowMessage("Loại danh mục mới " + DanhMuc.GetType().Name + " chưa được hỗ trợ"); return null; }
public static DelegationLib.DefinePermission CategoryPermission(XtraUserControl DanhMuc, string mainFeature, string description) { Permission per = new Permission(mainFeature, description); if (DanhMuc is PLDMGrid) { PLDMGrid basic1 = (PLDMGrid)DanhMuc; DMGrid basic = basic1.GetDMGrid; return delegate(object formCategory) { List<Object> items = new List<Object>(); //Lap vo tan xem lai tai sao ??? ApplyPermissionAction.ApplyPermissionObject(items, basic, per.GetPermissionItem(PermissionType.VIEW)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnAdd, per.GetPermissionItem(PermissionType.ADD)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnDel, per.GetPermissionItem(PermissionType.DELETE)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnUpdate, per.GetPermissionItem(PermissionType.EDIT)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnSave, per.GetPermissionItem(PermissionType.ADD_EDIT)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnNoSave, per.GetPermissionItem(PermissionType.ADD_EDIT)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnSelect, per.GetPermissionItem(PermissionType.VIEW)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnNoSelect, per.GetPermissionItem(PermissionType.VIEW)); return items; }; } #region DMGrid else if (DanhMuc is DMGrid) { DMGrid basic = (DMGrid)DanhMuc; return delegate(object formCategory) { List<Object> items = new List<Object>(); ApplyPermissionAction.ApplyPermissionObject(items, basic, per.GetPermissionItem(PermissionType.VIEW)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnAdd, per.GetPermissionItem(PermissionType.ADD)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnDel, per.GetPermissionItem(PermissionType.DELETE)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnUpdate, per.GetPermissionItem(PermissionType.EDIT)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnSave, per.GetPermissionItem(PermissionType.ADD_EDIT)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnNoSave, per.GetPermissionItem(PermissionType.ADD_EDIT)); return items; }; } #endregion #region DMTreeGroup else if (DanhMuc is DMTreeGroup) { DMTreeGroup basic = (DMTreeGroup)DanhMuc; return delegate(object formCategory) { List<Object> items = new List<Object>(); ApplyPermissionAction.ApplyPermissionObject(items, basic, per.GetPermissionItem(PermissionType.VIEW)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnAdd, per.GetPermissionItem(PermissionType.ADD)); ApplyPermissionAction.ApplyPermissionObject(items, basic.addSameLevel, per.GetPermissionItem(PermissionType.ADD)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnDel, per.GetPermissionItem(PermissionType.DELETE)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnUpdate, per.GetPermissionItem(PermissionType.EDIT)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnLuu, per.GetPermissionItem(PermissionType.ADD_EDIT)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnKhongLuu, per.GetPermissionItem(PermissionType.ADD_EDIT)); return items; }; } #endregion #region DMTreeGroupElement else if (DanhMuc is DMTreeGroupElement) { DMTreeGroupElement basic = (DMTreeGroupElement)DanhMuc; return delegate(object formCategory) { List<Object> items = new List<Object>(); ApplyPermissionAction.ApplyPermissionObject(items, basic, per.GetPermissionItem(PermissionType.VIEW)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnAdd, per.GetPermissionItem(PermissionType.ADD)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnDel, per.GetPermissionItem(PermissionType.DELETE)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnUpdate, per.GetPermissionItem(PermissionType.EDIT)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnSave, per.GetPermissionItem(PermissionType.ADD_EDIT)); ApplyPermissionAction.ApplyPermissionObject(items, basic.btnNoSave, per.GetPermissionItem(PermissionType.ADD_EDIT)); return items; }; } #endregion PLMessageBoxDev.ShowMessage("Loại danh mục " + DanhMuc.GetType().Name + " chưa được hỗ trợ"); return null; }
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) { } }