Example #1
0
        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);
            }
        }
Example #2
0
        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();
                }
            }
        }
Example #3
0
        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();
        }