Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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();
                }
            }
        }