public static Type GetABCScreenType(Guid iViewID) { STViewsInfo info = new STViewsController().GetObjectByID(iViewID) as STViewsInfo; if (info == null) { return(null); } Type type = null; String strScreenName = String.Empty; if (String.IsNullOrEmpty(info.ScreenName) == false) { strScreenName = info.ScreenName + "Screen"; type = GetABCScreenType(strScreenName); } if (type == null) { strScreenName = info.STViewNo + "Screen"; type = GetABCScreenType(strScreenName); } return(type); }
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); } }
public static ABCBaseScreen GetABCScreen(String strScreenName, ViewMode mode) { STViewsInfo info = new STViewsController().GetObjectByNo(strScreenName) as STViewsInfo; if (info != null) { return(GetABCScreen(info, mode)); } return(null); }
public static ABCBaseScreen GetABCScreen(Guid iViewID, ViewMode mode) { STViewsInfo info = new STViewsController().GetObjectByID(iViewID) as STViewsInfo; if (info != null) { return(GetABCScreen(info, mode)); } return(null); }
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 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(); } } }
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 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 } }
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 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 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 void RefreshViewList( ) { List <Guid> lstViewIDs = ABCUserProvider.GetViews(ABCUserProvider.CurrentUser.ADUserID); STViewGroupsController viewGroupCtrl = new STViewGroupsController(); STViewsController viewCtrl = new STViewsController(); ViewNode rootNode = new ViewNode(null, null, null); Dictionary <Guid, ViewNode> lstGroupNodes = new Dictionary <Guid, ViewNode>(); List <BusinessObject> lstViews = viewCtrl.GetList("SELECT * FROM STViews WHERE (DisplayInTree IS NULL OR DisplayInTree ='TRUE') ORDER BY SortOrder"); List <BusinessObject> lstGroups = viewGroupCtrl.GetList("SELECT * FROM STViewGroups ORDER BY SortOrder"); foreach (STViewGroupsInfo group in lstGroups) { ViewNode groupNode = null; foreach (STViewsInfo view in lstViews) { if (view.FK_STViewGroupID.HasValue && view.FK_STViewGroupID.Value == group.STViewGroupID && lstViewIDs.Contains(view.STViewID)) { if (groupNode == null) { groupNode = new ViewNode(rootNode, new object[] { group.Name, group.STViewGroupID }, group); lstGroupNodes.Add(group.STViewGroupID, groupNode); } String strCaption = view.STViewName; if (String.IsNullOrWhiteSpace(strCaption)) { strCaption = view.STViewNo; } ViewNode viewNode = new ViewNode(groupNode, new object[] { strCaption, view.STViewID }, view); viewNode.ViewCount = 1; groupNode.ViewCount++; } } } foreach (Guid iID in lstGroupNodes.Keys) { if ((lstGroupNodes[iID].InnerData as STViewGroupsInfo).FK_STViewGroupID.HasValue && (lstGroupNodes[iID].InnerData as STViewGroupsInfo).FK_STViewGroupID.Value != Guid.Empty) { foreach (Guid iID2 in lstGroupNodes.Keys) { if (iID2 != iID) { if ((lstGroupNodes[iID].InnerData as STViewGroupsInfo).FK_STViewGroupID.Value == (lstGroupNodes[iID2].InnerData as STViewGroupsInfo).STViewGroupID) { lstGroupNodes[iID].parentCore.childrenCore.Remove(lstGroupNodes[iID]); lstGroupNodes[iID].parentCore = lstGroupNodes[iID2]; lstGroupNodes[iID2].childrenCore.Add(lstGroupNodes[iID]); lstGroupNodes[iID2].ViewCount += lstGroupNodes[iID].ViewCount; } } } } } if (ABCUserProvider.CurrentUser != null && !ABCUserProvider.CurrentUser.No.Contains("admin")) { foreach (Guid iID in lstGroupNodes.Keys) { if (lstGroupNodes[iID].ViewCount <= 0) { lstGroupNodes[iID].parentCore.childrenCore.Remove(lstGroupNodes[iID]); } } } this.DataSource = rootNode; this.CollapseAll(); }