void ModulesExplorer_MouseClick(object sender, MouseEventArgs e) { TreeList tree = sender as TreeList; if (e.Button == MouseButtons.Left && ModifierKeys == Keys.None && tree.State == TreeListState.NodePressed) { Point pt = tree.PointToClient(MousePosition); TreeListHitInfo info = tree.CalcHitInfo(pt); if (info.HitInfoType == HitInfoType.Cell || info.HitInfoType == HitInfoType.StateImage) { tree.FocusedNode = info.Node; ViewNode obj = (ViewNode)this.GetDataRecordByNode(info.Node); if (obj == null || obj.InnerData == null || obj.InnerData is STViewsInfo == false) { return; } STViewsInfo viewInfo = (STViewsInfo)obj.InnerData; if (viewInfo != null) { ABCHelper.ABCWaitingDialog.Show("", "Đang mở . . .!"); ABCScreen.ABCBaseScreen scr = ABCScreen.ABCScreenFactory.GetABCScreen(viewInfo, ViewMode.Runtime); if (scr != null) { scr.Show(); } ABCHelper.ABCWaitingDialog.Close(); } } } }
void ViewTree_DragOver(object sender, DragEventArgs e) { if (e.Data is DataObject) { DataObject data = (DataObject)e.Data; DevExpress.XtraTreeList.Nodes.TreeListNode objNode = (DevExpress.XtraTreeList.Nodes.TreeListNode)data.GetData(typeof(DevExpress.XtraTreeList.Nodes.TreeListNode)); if (objNode != null) { MyData obj = (MyData)this.GetDataRecordByNode(objNode); if (obj == null || obj.InnerData == null) { return; } STViewsInfo info = (STViewsInfo)obj.InnerData; ABCToolboxItem toolboxItem = new ABCToolboxItem(typeof(ABCControls.ABCView)); toolboxItem.Binding = new ABCControls.ABCBindingInfo(); toolboxItem.Binding.ViewInfo = info; data = OwnerStudio.Toolbox.SerializeToolboxItem(toolboxItem) as DataObject; try { OwnerStudio.Toolbox.DoDragDrop(data, DragDropEffects.Copy); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
public void RunLink(STViewsInfo viewIfo, ViewMode mode, bool isShowDialog, Guid iMainID, ABCScreenAction action) { if (viewIfo != null) { ABCHelper.ABCWaitingDialog.Show("", "Đang mở . . .!"); ABCScreen.ABCBaseScreen scr = ABCScreenFactory.GetABCScreen(viewIfo, mode); if (scr != null) { scr.InvalidateData(iMainID); ABCHelper.ABCWaitingDialog.Close(); if (action != ABCScreenAction.None) { scr.DoAction(action, true); } if (action == ABCScreenAction.Disable) { scr.UIManager.View.ShowToolbar = false; } if (isShowDialog) { scr.ShowDialog(); } else { scr.Show(); } } ABCHelper.ABCWaitingDialog.Close(); } }
public static ABCBaseScreen GetABCScreen(String strLayoutXMLPath, STViewsInfo viewInfo, ViewMode mode) { //if ( ABCBaseProvider.BaseInstance.CheckViewPermission( viewInfo.STViewNo , ViewPermission.AllowView )==false ) //{ // ABCHelper.ABCMessageBox.Show( "Bạn không đủ quyền hạn sử dụng tính năng này!" , "Thông báo" , MessageBoxButtons.OK , MessageBoxIcon.Error ); // return null; //} ABCBaseScreen screen = null; Type type = null; if (viewInfo != null) { type = GetABCScreenType(viewInfo.STViewID); } if (type == null) { type = typeof(ABCBaseScreen); } screen = (ABCBaseScreen)ABCDynamicInvoker.CreateInstanceObject(type); if (screen != null) { screen.LoadScreen(strLayoutXMLPath, mode); } return(screen); }
public void CustomizeView(STViewsInfo viewInfo) { if (viewInfo == null) { return; } ABCStudio.ABCStudioManager.Start(viewInfo); }
public static void RunScreen(STViewsInfo info, ViewMode mode) { ABCBaseScreen screen = GetABCScreen(info, mode); if (screen != null) { screen.ShowDialog(); } }
public static Assembly CompileScreenSouceCode(STViewsInfo info) { if (String.IsNullOrWhiteSpace(info.STViewCode)) { return(null); } return(CompileScreenSouceCode(info.STViewCode, info.STViewNo)); }
public void OpenFromDatabase(STViewsInfo viewInfo) { ABCWaitingDialog.Show("", "Opening . . .!"); HostControl hc = OwnerStudio.SurfaceManager.OpenNewForm(viewInfo); AddHostToTabManager(hc); ABCWaitingDialog.Close(); }
public void RunLink(String strTableName, ViewMode mode, bool isShowDialog, Guid iMainID, ABCScreenAction action) { STViewsInfo viewResult = null; STViewsController viewCtrl = new STViewsController(); String strViewNo = VoucherProvider.GetViewNo(strTableName, iMainID); if (!String.IsNullOrWhiteSpace(strViewNo)) { viewResult = viewCtrl.GetObjectByNo(strViewNo) as STViewsInfo; } if (viewResult == null) { #region Without Voucher BusinessObjectController controller = BusinessControllerFactory.GetBusinessController(strTableName); if (controller == null) { return; } BusinessObject obj = controller.GetObjectByID(iMainID); if (obj == null) { return; } List <BusinessObject> lstViews = viewCtrl.GetListFromDataset(viewCtrl.GetDataSet(String.Format("SELECT * FROM STViews WHERE [MainTableName] = '{0}' ", strTableName))); foreach (STViewsInfo viewIfo in lstViews) { if (String.IsNullOrWhiteSpace(viewIfo.MainFieldName) == false && DataStructureProvider.IsTableColumn(strTableName, viewIfo.MainFieldName)) { object objValue = ABCBusinessEntities.ABCDynamicInvoker.GetValue(obj, viewIfo.MainFieldName); if (objValue != null && objValue.ToString().ToUpper().Trim() == viewIfo.MainValue.ToUpper()) { viewResult = viewIfo; break; } } } if (viewResult == null && lstViews.Count > 0) { viewResult = lstViews[0] as STViewsInfo; } #endregion } if (viewResult != null) { ABCScreenManager.Instance.RunLink(viewResult, mode, isShowDialog, iMainID, action); } }
void OnFinishClick(object sender, CancelEventArgs e) { if (chkToXML.Checked) { #region XML FileInfo fileInfo = null; try { fileInfo = new FileInfo(btnXMLFile.Text); } catch (Exception ex) { } XmlDocument doc = ABCControls.ABCView.GetEmptyXMLLayout(fileInfo.Name); doc.Save(btnXMLFile.Text); OwnerStudio.Worker.OpenFromXMLFile(btnXMLFile.Text); #endregion } if (chkToDatabase.Checked) { #region Database STViewGroupsController groupCtrl = new STViewGroupsController(); STViewGroupsInfo groupInfo = (STViewGroupsInfo)groupCtrl.GetObjectByNo(lkeGroup.Text); if (groupInfo == null) { groupInfo = new STViewGroupsInfo(); groupInfo.No = lkeGroup.Text; groupInfo.Name = lkeGroup.Text; groupCtrl.CreateObject(groupInfo); } STViewsController viewCtrl = new STViewsController(); STViewsInfo viewInfo = (STViewsInfo)viewCtrl.GetObjectByNo(txtViewName.Text); if (viewInfo == null) { viewInfo = new STViewsInfo(); viewInfo.STViewNo = txtViewName.Text; viewInfo.STViewName = txtViewName.Text; viewInfo.FK_STViewGroupID = groupInfo.STViewGroupID; String strXML = ABCControls.ABCView.GetEmptyXMLLayout(txtViewName.Text).InnerXml; viewInfo.STViewXML = ABCHelper.StringCompressor.CompressString(strXML); viewCtrl.CreateObject(viewInfo); } OwnerStudio.Worker.OpenFromDatabase(viewInfo); OwnerStudio.ViewTreeList.RefreshViewList(); #endregion } this.Close(); }
public static void RunScreen(String strLayoutXMLPath, STViewsInfo info, ViewMode mode) { ABCBaseScreen screen = GetABCScreen(strLayoutXMLPath, info, mode); if (screen != null) { Form frm = screen.GetDialog(); if (info.STViewDesc != null) { frm.Text = info.STViewDesc; } frm.ShowDialog(); } }
public static Form GetMainScreen( ) { STViewsInfo info = (STViewsInfo) new STViewsController().GetObjectByNo("View0"); if (info == null) { return(null); } ABCScreen.ABCBaseScreen scr = ABCScreen.ABCScreenFactory.GetABCScreen(info, ViewMode.Runtime); if (scr != null) { return(scr.GetDialog()); } return(null); }
void OnNextClick(object sender, DevExpress.XtraWizard.WizardCommandButtonClickEventArgs e) { dxErrorProvider1.ClearErrors(); if (e.Page == InputInfoPage) { #region InputInfoPage if (chkToXML.Checked) { FileInfo file = null; try { new FileInfo(btnXMLFile.Text); } catch (Exception ex) { dxErrorProvider1.SetError(btnXMLFile, "Please choose a location to save XML file"); e.Handled = true; return; } } if (chkToDatabase.Checked) { if (String.IsNullOrWhiteSpace(txtViewName.Text)) { dxErrorProvider1.SetError(txtViewName, "View name can not be empty!"); e.Handled = true; } if (String.IsNullOrWhiteSpace(lkeGroup.Text)) { dxErrorProvider1.SetError(lkeGroup, "Please choose a group !"); e.Handled = true; } if (String.IsNullOrWhiteSpace(txtViewName.Text) == false && String.IsNullOrWhiteSpace(lkeGroup.Text) == false) { STViewsInfo viewInfo = (STViewsInfo) new STViewsController().GetObjectByNo(txtViewName.Text); if (viewInfo != null) { dxErrorProvider1.SetError(txtViewName, "View name has been existed!"); e.Handled = true; } } } #endregion } }
public void RefreshLayout( ) { if (this.Surface == null) { return; } ABCHelper.ABCWaitingDialog.Show("", "Refresh . . .!"); this.Surface.OwnerHostControl.Visible = false; this.Surface.OwnerHostControl.SuspendLayout(); if (DataField != null) { if (((HostSurface)HostSurfaceManager.CurrentManager.ActiveDesignSurface).DesignerHost.RootComponent == this) { ((HostSurface)HostSurfaceManager.CurrentManager.ActiveDesignSurface).CleanSurface(); } this.CleanView(); DataField = (STViewsInfo) new STViewsController().GetObjectByID(DataField.STViewID); if (DataField != null) { Load(DataField, Mode); } this.Invalidate(); } else if (String.IsNullOrWhiteSpace(XMLFileName) == false) { if (((HostSurface)HostSurfaceManager.CurrentManager.ActiveDesignSurface).DesignerHost.RootComponent == this) { ((HostSurface)HostSurfaceManager.CurrentManager.ActiveDesignSurface).CleanSurface(); } this.CleanView(); Load(XMLFileName, Mode); this.Invalidate(); } this.Surface.OwnerHostControl.ResumeLayout(false); Application.DoEvents(); this.Surface.OwnerHostControl.Visible = true; ABCHelper.ABCWaitingDialog.Close(); }
public void Load(STViewsInfo viewInfo, ViewMode mode) { DataField = viewInfo; XmlDocument doc = new XmlDocument(); string strDecompress = ABCHelper.StringCompressor.DecompressString(viewInfo.STViewXML); doc.LoadXml(strDecompress); Load(doc, mode); this.Caption = viewInfo.STViewDesc; this.ScreenName = viewInfo.ScreenName; this.DisplayInTree = viewInfo.DisplayInTree; this.MainTableName = viewInfo.MainTableName; this.MainFieldName = viewInfo.MainFieldName; this.MainValue = viewInfo.MainValue; }
public static void Start(STViewsInfo viewInfo) { SystemProvider.Initialize(); if (ABCStudioHelper.Instance == null) { ABCStudioHelper.Instance = new ABCStudioManager(); } CustomizeView = viewInfo; if (CustomizeView != null) { ABCStudioManager.Instance.StartSection(); } else { ABCUserManager.ShowLogIn(LoginType.Studio); } }
public void LoadView(STViewsInfo viewInfo, ViewMode mode) { if (View == null) { View = new ABCView(); View.Load(viewInfo, mode); } else { Control ctrlParent = View.Parent; View.Parent = null; View = new ABCView(); View.Load(viewInfo, mode); View.Parent = ctrlParent; View.Dock = DockStyle.Fill; ctrlParent.ClientSize = View.Size; } InitializeEvents(); }
public HostControl OpenNewForm(STViewsInfo viewInfo) { try { HostControl hc = this.GetNewHost(typeof(ABCControls.ABCView), LoaderType.CodeDomDesignerLoader); DesignerTransaction transaction = hc.HostSurface.DesignerHost.CreateTransaction("Open XML"); ((ABCView)hc.HostSurface.DesignerHost.RootComponent).Load(viewInfo, ViewMode.Design); transaction.Commit(); ((IDisposable)transaction).Dispose(); return(hc); } catch (Exception ex) { } return(null); }
public void OpenScreenForNew(String strTableName, ViewMode mode, bool isShowDialog) { #region Get View STViewsInfo viewResult = null; STViewsController viewCtrl = new STViewsController(); List <BusinessObject> lstViews = viewCtrl.GetListFromDataset(viewCtrl.GetDataSet(String.Format("SELECT * FROM STViews WHERE [MainTableName] = '{0}' ", strTableName))); foreach (STViewsInfo viewIfo in lstViews) { if (String.IsNullOrWhiteSpace(viewIfo.MainFieldName) == false && DataStructureProvider.IsTableColumn(strTableName, viewIfo.MainFieldName)) { viewResult = viewIfo; break; } } if (viewResult == null && lstViews.Count > 0) { viewResult = lstViews[0] as STViewsInfo; } #endregion if (viewResult != null) { ABCHelper.ABCWaitingDialog.Show("", "Đang mở . . .!"); ABCScreen.ABCBaseScreen scr = ABCScreenFactory.GetABCScreen(viewResult, mode); scr.DoAction(ABCScreenAction.New, true); ABCHelper.ABCWaitingDialog.Close(); if (isShowDialog) { scr.ShowDialog(); } else { scr.Show(); } } }
public bool CheckLoopSurface(Guid iSourceViewID) { if (this.ViewID == null || this.ViewID == Guid.Empty) { return(true); } if (this.ViewID == iSourceViewID) { return(false); } STViewsInfo objInfo = (STViewsInfo) new STViewsController().GetObjectByID(iSourceViewID); if (objInfo == null) { return(false); } XmlDocument doc = new XmlDocument(); string strDecompress = ABCHelper.StringCompressor.DecompressString(objInfo.STViewXML); if (String.IsNullOrWhiteSpace(strDecompress)) { return(false); } doc.LoadXml(strDecompress); XmlNodeList node = doc.SelectNodes(String.Format("//C[@ID='{0}']", this.ViewID.ToString())); if (node != null && node.Count > 0) { return(false); } return(true); }
void ViewTree_DoubleClick(object sender, EventArgs e) { if (this.Selection.Count > 0 && this.Selection[0].Level >= 1) { MyData obj = (MyData)this.GetDataRecordByNode(this.Selection[0]); if (obj == null || obj.InnerData == null) { return; } if (obj.InnerData is STViewsInfo) { // Nodes.TreeListNode node = this.FindNodeByID( this.Selection[0].Id); // object strID=this.GetNodeValue(this. this.Selection[0] , this.Columns[1] ); // object strID=this.Selection[0].GetValue(this.Columns[1] ); STViewsController viewCtrl = new STViewsController(); STViewsInfo info = (STViewsInfo)viewCtrl.GetObjectByID((obj.InnerData as STViewsInfo).STViewID); if (info != null) { OwnerStudio.Worker.OpenFromDatabase(info); } } } }
public void InvalidateControl( ) { if (EditControl == null && String.IsNullOrWhiteSpace(UIControlType) == false) { #region Design - FirstTIme EditControl = (IABCBindableControl)ABCBusinessEntities.ABCDynamicInvoker.CreateInstanceObject(Type.GetType(UIControlType)); EditControl.DataSource = this.DataSource; EditControl.DataMember = this.DataMember; EditControl.TableName = this.TableName; if (this.DataMember.Contains(":")) { SetToReadOnly(); } #endregion } if (EditControl != null) { EditControl.DataSource = this.DataSource; EditControl.DataMember = this.DataMember; EditControl.TableName = this.TableName; this.layoutControl1.Controls.Add((this.EditControl as Control)); this.LayoutItem.Control = (this.EditControl as Control); #region DisplayImage if (this.DataMember.Contains(":")) { DataCachingProvider.AccrossStructInfo acrrosInfo = DataCachingProvider.GetAccrossStructInfo(TableName, this.DataMember); if (acrrosInfo != null && (acrrosInfo.FieldName == DataStructureProvider.GetNOColumn(acrrosInfo.TableName) || acrrosInfo.FieldName == DataStructureProvider.GetNAMEColumn(acrrosInfo.TableName))) { STViewsInfo viewIfo = (STViewsInfo) new STViewsController().GetObject(String.Format("SELECT * FROM STViews WHERE [MainTableName] = '{0}' ", acrrosInfo.TableName)); if (viewIfo != null) { this.DisplayImage = true; } } } else if (DataStructureProvider.IsForeignKey(TableName, this.DataMember)) { String strPKTableName = DataStructureProvider.GetTableNameOfForeignKey(TableName, this.DataMember); STViewsInfo viewIfo = (STViewsInfo) new STViewsController().GetObject(String.Format("SELECT * FROM STViews WHERE [MainTableName] = '{0}' ", strPKTableName)); if (viewIfo != null) { this.DisplayImage = true; } } #endregion if (DataStructureProvider.IsNOColumn(this.TableName, this.DataMember)) { ReadOnly = true; } #region Permission DataCachingProvider.AccrossStructInfo accross = DataCachingProvider.GetAccrossStructInfo(this.TableName, this.DataMember); if (ABCScreen.ABCScreenHelper.Instance.CheckFieldPermission(accross.TableName, accross.FieldName, FieldPermission.AllowView) == false) { isAllowView = false; ReadOnly = true; } if (ReadOnly == false) { ReadOnly = !ABCScreen.ABCScreenHelper.Instance.CheckFieldPermission(accross.TableName, accross.FieldName, FieldPermission.AllowEdit); } #endregion if (isAllowView) { (this.EditControl as DevExpress.XtraEditors.BaseEdit).CustomDisplayText += new DevExpress.XtraEditors.Controls.CustomDisplayTextEventHandler(ABCBindingBaseEdit_CustomDisplayText); } if (ReadOnly) { SetToReadOnly(); } else { if (this.EditControl is DevExpress.XtraEditors.BaseEdit && (this.EditControl as DevExpress.XtraEditors.BaseEdit).Properties != null) { (this.EditControl as DevExpress.XtraEditors.BaseEdit).Properties.AppearanceFocused.BackColor = Color.Bisque; } } } UpdateLabelText(); }
public void RefreshViewList( ) { MyData tlDataSource = new MyData(null, null, null); // MyData root=new MyData( tlDataSource , new string[] { "Root" , "" } , null ); STViewGroupsController viewGroupCtrl = new STViewGroupsController(); STViewsController viewCtrl = new STViewsController(); DataSet ds = viewGroupCtrl.GetDataSet("SELECT * FROM STViewGroups ORDER BY SortOrder"); List <BusinessObject> lst = viewGroupCtrl.GetListFromDataset(ds); Dictionary <Guid, MyData> listNodes = new Dictionary <Guid, MyData>(); foreach (STViewGroupsInfo objGroup in lst) { MyData group = new MyData(tlDataSource, new object[] { objGroup.No, objGroup.STViewGroupID }, objGroup); listNodes.Add(objGroup.STViewGroupID, group); } foreach (Guid iID in listNodes.Keys) { if ((listNodes[iID].InnerData as STViewGroupsInfo).FK_STViewGroupID.HasValue && (listNodes[iID].InnerData as STViewGroupsInfo).FK_STViewGroupID.Value != Guid.Empty) { foreach (Guid iID2 in listNodes.Keys) { if (iID2 != iID) { if ((listNodes[iID].InnerData as STViewGroupsInfo).FK_STViewGroupID == (listNodes[iID2].InnerData as STViewGroupsInfo).STViewGroupID) { listNodes[iID].parentCore.childrenCore.Remove(listNodes[iID]); listNodes[iID].parentCore = listNodes[iID2]; listNodes[iID2].childrenCore.Add(listNodes[iID]); } } } } } foreach (Guid iID in listNodes.Keys) { DataSet dsView = viewCtrl.GetDataSet(String.Format("SELECT * FROM STViews WHERE FK_STViewGroupID ='{0}' ORDER BY SortOrder", iID)); if (dsView == null || dsView.Tables.Count <= 0) { continue; } foreach (DataRow dr in dsView.Tables[0].Rows) { STViewsInfo objView = (STViewsInfo)viewCtrl.GetObjectFromDataRow(dr); if (objView != null) { new MyData(listNodes[iID], new object[] { objView.STViewNo, objView.STViewID }, objView); } } } this.DataSource = tlDataSource; this.CollapseAll(); }
void ViewExplorer_CellValueChanged(object sender, DevExpress.XtraTreeList.CellValueChangedEventArgs e) { MyData obj = (MyData)this.GetDataRecordByNode(this.FocusedNode); if (obj == null || obj.InnerData == null) { return; } String strNo = String.Empty; if (obj.InnerData is STViewsInfo) { strNo = (obj.InnerData as STViewsInfo).STViewNo; } if (obj.InnerData is STViewGroupsInfo) { strNo = (obj.InnerData as STViewGroupsInfo).No; } if (strNo == e.Value.ToString()) { this.OptionsBehavior.Editable = false; return; } if (obj.InnerData is STViewsInfo) { STViewsController viewCtrl = new STViewsController(); //if ( viewCtrl.GetObjectByNo( e.Value.ToString() )!=null ) //{ // ABCHelper.ABCMessageBox.Show( String.Format( "View Name : '{0}' is already existed. " , e.Value.ToString() ) , "Message" , MessageBoxButtons.OK , MessageBoxIcon.Error ); // e.Value=strNo; // this.OptionsBehavior.Editable=false; // return; //} STViewsInfo info = (STViewsInfo)obj.InnerData; if (info != null) { info.STViewNo = e.Value.ToString(); info.STViewName = e.Value.ToString(); viewCtrl.UpdateObject(info); } } if (obj.InnerData is STViewGroupsInfo) { STViewGroupsController groupCtrl = new STViewGroupsController(); //if ( groupCtrl.GetObjectByNo( e.Value.ToString() )!=null ) //{ // ABCHelper.ABCMessageBox.Show( String.Format( "Group Name : '{0}' is already existed. " , e.Value.ToString() ) , "Message" , MessageBoxButtons.OK , MessageBoxIcon.Error ); // e.Value=strNo; // this.OptionsBehavior.Editable=false; // return; //} STViewGroupsInfo info = (STViewGroupsInfo)obj.InnerData; if (info != null) { info.No = e.Value.ToString(); info.Name = e.Value.ToString(); groupCtrl.UpdateObject(info); } } this.OptionsBehavior.Editable = false; }
public static void SynchronizeViewPermission( ) { GEPermissionViewsController permissionCtrl = new GEPermissionViewsController(); String strQuery = String.Format(@"DELETE FROM GEPermissionViews WHERE FK_GEPermissionID NOT IN (SELECT GEPermissionID FROM GEPermissions)"); BusinessObjectController.RunQuery(strQuery); #region Init Views STViewsController viewCtrl = new STViewsController(); Dictionary <Guid, STViewsInfo> lstSTViews = new Dictionary <Guid, STViewsInfo>(); DataSet ds = viewCtrl.GetDataSetAllObjects(); if (ds != null && ds.Tables.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { STViewsInfo viewInfo = viewCtrl.GetObjectFromDataRow(dr) as STViewsInfo; if (lstSTViews.ContainsKey(viewInfo.STViewID) == false) { lstSTViews.Add(viewInfo.STViewID, viewInfo); } } } #endregion foreach (GEPermissionsInfo permission in new GEPermissionsController().GetListAllObjects()) { #region View Dictionary <Guid, GEPermissionViewsInfo> lstGroupViews = new Dictionary <Guid, GEPermissionViewsInfo>(); foreach (GEPermissionViewsInfo viewInfo in permissionCtrl.GetListByForeignKey("FK_GEPermissionID", permission.GEPermissionID).Cast <GEPermissionViewsInfo>().ToList()) { if (viewInfo.FK_STViewID.HasValue && lstGroupViews.ContainsKey(viewInfo.FK_STViewID.Value) == false) { if (lstSTViews.ContainsKey(viewInfo.FK_STViewID.Value)) { lstGroupViews.Add(viewInfo.FK_STViewID.Value, viewInfo); } else { permissionCtrl.DeleteObject(viewInfo); } } } foreach (Guid strViewID in lstSTViews.Keys) { if (lstGroupViews.ContainsKey(strViewID) == false) { GEPermissionViewsInfo viewInfo = new GEPermissionViewsInfo(); viewInfo.FK_STViewID = lstSTViews[strViewID].STViewID; if (lstSTViews[strViewID].FK_STViewGroupID.HasValue) { viewInfo.ViewGroup = GetViewGroupCaption(lstSTViews[strViewID].FK_STViewGroupID.Value); } viewInfo.FK_GEPermissionID = permission.GEPermissionID; viewInfo.AllowView = true; viewInfo.IsHomePage = false; permissionCtrl.CreateObject(viewInfo); lstGroupViews.Add(viewInfo.FK_STViewID.Value, viewInfo); } } #endregion } }
public static Component LoadComponent(ABCView ViewOwner, XmlNode node) { String strName = node.Attributes["name"].Value.ToString(); String strType = node.Attributes["type"].Value.ToString(); Type type = TypeResolutionService.CurrentService.GetType(strType); if (type == null) { return(null); } #region Node Component comp = null; #region ABCView if (type == typeof(ABCView)) { if (node.Attributes["isRoot"] != null && node.Attributes["isRoot"].Value.ToString() == "true") { #region root DeSerialization(ViewOwner, node); ViewOwner.IsRoot = true; ViewOwner.Name = node.Attributes["name"].Value.ToString(); if (String.IsNullOrWhiteSpace(ViewOwner.Caption)) { ViewOwner.Caption = ViewOwner.Name; } comp = ViewOwner; LoadChildrenComponent(ViewOwner, node, comp); #endregion } else { #region Included ABCView if (ViewOwner.Mode == ViewMode.Design) { comp = (Component)ViewOwner.Surface.DesignerHost.CreateComponent(type); } else { comp = (Component)ABCDynamicInvoker.CreateInstanceObject(type); } DeSerialization(comp, node); ((ABCView)comp).IsRoot = false; Guid iID = ABCHelper.DataConverter.ConvertToGuid(node.Attributes["ID"].Value); STViewsInfo viewInfo = (STViewsInfo) new STViewsController().GetObjectByID(iID); if (viewInfo != null) { ((ABCView)comp).DataField = viewInfo; ViewOwner.ChildrenView.Add((ABCView)comp); } #endregion } ((IABCControl)comp).OwnerView = ViewOwner; ((IABCControl)comp).InitControl(); return(comp); } #endregion #region ABCDockPanel if (type == typeof(DevExpress.XtraBars.Docking.DockPanel) || type == typeof(ABCControls.ABCDockPanel)) { comp = (Component)ABCDockPanel.AddNewDockPanel(ViewOwner); DeSerialization(comp, node); ((ABCDockPanel)comp).InitLayout(ViewOwner, node); return(comp); } #endregion comp = CreateComponent(ViewOwner, type); if (comp is Control) { (comp as Control).SuspendLayout(); } if (comp is IABCControl) { ((IABCControl)comp).OwnerView = ViewOwner; ((IABCControl)comp).InitControl(); } DeSerialization(comp, node); if (comp is IABCCustomControl) { ((IABCCustomControl)comp).InitLayout(ViewOwner, node); } else { LoadChildrenComponent(ViewOwner, node, comp); } #endregion if (comp is Control) { (comp as Control).ResumeLayout(false); } if (comp is ABCSimpleButton) { ViewOwner.ButtonList.Add(comp as ABCSimpleButton); } if (comp is ABCComment) { ViewOwner.CommentList.Add(comp as ABCComment); } return(comp); }
void Menu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { MyData obj = (MyData)this.GetDataRecordByNode(this.FocusedNode); STViewGroupsController groupCtrl = new STViewGroupsController(); STViewsController viewCtrl = new STViewsController(); if (e.Item.Tag != null && e.Item.Tag.ToString() == "Refresh") { RefreshViewList(); } if (e.Item.Tag != null && e.Item.Tag.ToString() == "NewView" && this.Selection.Count > 0) { if (obj == null || obj.InnerData == null) { return; } STViewGroupsInfo groupInfo = (STViewGroupsInfo)obj.InnerData; if (groupInfo != null) { #region Create ViewInfo STViewsInfo viewInfo = new STViewsInfo(); viewInfo.FK_STViewGroupID = groupInfo.STViewGroupID; viewInfo.STViewNo = "View"; int i = 0; while (viewCtrl.GetObjectByNo(viewInfo.STViewNo) != null) { viewInfo.STViewNo += i; } viewInfo.STViewName = viewInfo.STViewNo; String strXML = ABCControls.ABCView.GetEmptyXMLLayout(viewInfo.STViewName).InnerXml; viewInfo.STViewXML = ABCHelper.StringCompressor.CompressString(strXML); viewCtrl.CreateObject(viewInfo); #endregion new MyData(obj, new object[] { viewInfo.STViewNo, viewInfo.STViewID }, viewInfo); this.RefreshDataSource(); } } if (e.Item.Tag != null && e.Item.Tag.ToString() == "NewGroup" && this.Selection.Count > 0) { #region Create GroupInfo STViewGroupsInfo groupInfo = new STViewGroupsInfo(); groupInfo.No = "Group"; int i = 0; while (groupCtrl.GetObjectByNo(groupInfo.No) != null) { groupInfo.No += i; } groupInfo.Name = groupInfo.No; groupCtrl.CreateObject(groupInfo); #endregion new MyData(this.DataSource as MyData, new object[] { groupInfo.No, groupInfo.STViewGroupID }, groupInfo); this.RefreshDataSource(); } if (e.Item.Tag != null && e.Item.Tag.ToString() == "NewChildGroup" && this.Selection.Count > 0) { if (obj == null || obj.InnerData == null) { return; } STViewGroupsInfo groupInfo = (STViewGroupsInfo)obj.InnerData; if (groupInfo != null) { #region Create GroupInfo STViewGroupsInfo newGroupInfo = new STViewGroupsInfo(); newGroupInfo.No = "Group"; int i = 0; while (groupCtrl.GetObjectByNo(newGroupInfo.No) != null) { newGroupInfo.No += i; } newGroupInfo.Name = newGroupInfo.No; newGroupInfo.FK_STViewGroupID = groupInfo.STViewGroupID; groupCtrl.CreateObject(newGroupInfo); #endregion new MyData(obj, new object[] { newGroupInfo.No, newGroupInfo.STViewGroupID }, newGroupInfo); this.RefreshDataSource(); } } if (e.Item.Tag != null && e.Item.Tag.ToString() == "NewRootGroup") { #region Create GroupInfo STViewGroupsInfo newGroupInfo = new STViewGroupsInfo(); newGroupInfo.No = "Group"; int i = 0; while (groupCtrl.GetObjectByNo(newGroupInfo.No) != null) { newGroupInfo.No += i; } newGroupInfo.Name = newGroupInfo.No; groupCtrl.CreateObject(newGroupInfo); #endregion new MyData(this.DataSource as MyData, new object[] { newGroupInfo.No, newGroupInfo.STViewGroupID }, newGroupInfo); this.RefreshDataSource(); } if (e.Item.Tag != null && (e.Item.Tag.ToString() == "RenameView" || e.Item.Tag.ToString() == "RenameGroup") && this.Selection.Count > 0) { this.OptionsBehavior.Editable = true; this.ShowEditor(); } if (e.Item.Tag != null && e.Item.Tag.ToString() == "OpenView") { if (obj == null || obj.InnerData == null) { return; } STViewsInfo info = (STViewsInfo) new STViewsController().GetObjectByID(((STViewsInfo)obj.InnerData).GetID()); if (info == null) { return; } OwnerStudio.Worker.OpenFromDatabase(info); } if (e.Item.Tag != null && e.Item.Tag.ToString() == "RunView") { if (obj == null || obj.InnerData == null) { return; } STViewsInfo info = (STViewsInfo) new STViewsController().GetObjectByID(((STViewsInfo)obj.InnerData).GetID()); if (info == null) { return; } ABCScreen.ABCScreenFactory.RunScreen(info, ViewMode.Test); } if (e.Item.Tag != null && e.Item.Tag.ToString() == "DeleteView") { if (obj == null || obj.InnerData == null) { return; } DialogResult result = ABCHelper.ABCMessageBox.Show("Do you want to delete selected View ? ", "Delete View", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { STViewsInfo info = (STViewsInfo)obj.InnerData; viewCtrl.DeleteObject(info.STViewID); obj.parentCore.childrenCore.Remove(obj); obj.parentCore = null; this.RefreshDataSource(); } } if (e.Item.Tag != null && e.Item.Tag.ToString() == "DeleteGroup") { if (obj == null || obj.InnerData == null) { return; } DialogResult result = ABCHelper.ABCMessageBox.Show("Do you want to delete selected Group and all children View ? ", "Delete Group", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { STViewGroupsInfo info = (STViewGroupsInfo)obj.InnerData; viewCtrl.DeleteObjectsByFK("FK_STViewGroupID", info.STViewGroupID); groupCtrl.DeleteObject(info.STViewGroupID); obj.parentCore.childrenCore.Remove(obj); obj.parentCore = null; this.RefreshDataSource(); } } if (e.Item.Tag != null && e.Item.Tag.ToString() == "Import" && this.Selection.Count > 0) { if (obj == null || obj.InnerData == null) { return; } STViewsInfo info = (STViewsInfo) new STViewsController().GetObjectByID(((STViewsInfo)obj.InnerData).GetID()); if (info == null) { return; } OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*"; dlg.FilterIndex = 0; dlg.RestoreDirectory = true; dlg.Title = "Import Layout from XML file"; if (dlg.ShowDialog() == DialogResult.OK) { XmlDocument doc = new XmlDocument(); doc.Load(dlg.FileName); info.STViewXML = ABCHelper.StringCompressor.CompressString(doc.InnerXml); new STViewsController().UpdateObject(info); ABCHelper.ABCMessageBox.Show("Saved ...!", "Import From XML", MessageBoxButtons.OK, MessageBoxIcon.Information); } } if (e.Item.Tag != null && e.Item.Tag.ToString() == "Export" && this.Selection.Count > 0) { if (obj == null || obj.InnerData == null) { return; } STViewsInfo info = (STViewsInfo) new STViewsController().GetObjectByID(((STViewsInfo)obj.InnerData).GetID()); if (info == null) { return; } SaveFileDialog dlg = new SaveFileDialog(); dlg.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*"; dlg.FilterIndex = 0; dlg.RestoreDirectory = true; dlg.Title = "Export Layout to XML file"; if (dlg.ShowDialog() == DialogResult.OK && !String.IsNullOrWhiteSpace(dlg.FileName)) { XmlDocument doc = new XmlDocument(); string strDecompress = ABCHelper.StringCompressor.DecompressString(info.STViewXML); doc.LoadXml(strDecompress); doc.Save(dlg.FileName); ABCHelper.ABCMessageBox.Show("Export ...!", "Export To XML", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
public static ABCBaseScreen GetABCScreen(STViewsInfo info, ViewMode mode) { if (info.STViewID == null || info.STViewID == Guid.Empty) { return(null); } info = (STViewsInfo) new STViewsController().GetObjectByID(info.STViewID); if (info == null) { return(null); } if (ABCScreenManager.Instance.CheckViewPermission(info.STViewID, ViewPermission.AllowView) == false) { ABCHelper.ABCMessageBox.Show("Bạn không đủ quyền hạn sử dụng tính năng này!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return(null); } ABCBaseScreen screen = null; #region Get Type Type type = GetABCScreenType(info.STViewID); if (type == null) { if (info.STViewUseCode && String.IsNullOrWhiteSpace(info.STViewCode) == false) { Assembly ass = ABCScreenFactory.CompileScreenSouceCode(info); if (ass != null) { if (!String.IsNullOrWhiteSpace(info.ScreenName)) { type = ass.GetType("ABCApp.Screens." + info.ScreenName + "Screen"); } if (type == null && !String.IsNullOrWhiteSpace(info.STViewNo)) { type = ass.GetType("ABCApp.Screens." + info.STViewNo + "Screen"); } if (type != null) { screen = (ABCBaseScreen)ass.CreateInstance(type.FullName); } // screen=(ABCBaseScreen)AppDomain.CurrentDomain.CreateInstanceAndUnwrap( type.Assembly.FullName ,type.FullName ); if (screen != null) { screen.LoadScreen(info, mode); return(screen); } } } } if (type == null) { type = typeof(ABCBaseScreen); } #endregion if (type != null) { screen = (ABCBaseScreen)ABCDynamicInvoker.CreateInstanceObject(type); } if (screen != null) { screen.LoadScreen(info, mode); } return(screen); }