Ejemplo n.º 1
0
        public void InitializeToolbar( )
        {
            if (this.Screen.DataManager.MainObject == null)
            {
                this.View.ShowRefreshItem   = false;
                this.View.ShowCancelItem    = false;
                this.View.ShowSaveItem      = false;
                this.View.ShowEditItem      = false;
                this.View.ShowDuplicateItem = false;
                this.View.ShowNewItem       = false;
                this.View.ShowDeleteItem    = false;
                this.View.ShowSearchItem    = false;
                this.View.ShowPostItem      = false;
                this.View.ShowApproveItem   = false;
                this.View.ShowLockItem      = false;
                this.View.ShowPrintItem     = false;
                this.View.ShowInfoItem      = false;
            }
            else
            {
                this.View.ShowSaveItem   = false;
                this.View.ShowCancelItem = false;
                this.View.ShowInfoItem   = true;
            }

            BackupToolbarStatus.ShowNewItem       = this.View.ShowNewItem;
            BackupToolbarStatus.ShowEditItem      = this.View.ShowEditItem;
            BackupToolbarStatus.ShowDuplicateItem = this.View.ShowDuplicateItem;
            BackupToolbarStatus.ShowDeleteItem    = this.View.ShowDeleteItem;
            BackupToolbarStatus.ShowSaveItem      = this.View.ShowSaveItem;
            BackupToolbarStatus.ShowCancelItem    = this.View.ShowCancelItem;

            SetToolBarButtonVisibility(ABCView.ScreenBarButton.New, this.View.ShowNewItem);
            SetToolBarButtonVisibility(ABCView.ScreenBarButton.Duplicate, this.View.ShowDuplicateItem);
            SetToolBarButtonVisibility(ABCView.ScreenBarButton.Edit, this.View.ShowEditItem);
            SetToolBarButtonVisibility(ABCView.ScreenBarButton.Delete, this.View.ShowDeleteItem);
            SetToolBarButtonVisibility(ABCView.ScreenBarButton.Approve, this.View.ShowApproveItem);
            SetToolBarButtonVisibility(ABCView.ScreenBarButton.Reject, false);
            SetToolBarButtonVisibility(ABCView.ScreenBarButton.Lock, this.View.ShowLockItem);
            SetToolBarButtonVisibility(ABCView.ScreenBarButton.UnLock, false);
            SetToolBarButtonVisibility(ABCView.ScreenBarButton.Post, this.View.ShowPostItem);
            SetToolBarButtonVisibility(ABCView.ScreenBarButton.UnPost, false);
            SetToolBarButtonVisibility(ABCView.ScreenBarButton.Print, this.View.ShowPrintItem);

            if (this.Screen.DataManager.MainObject != null)
            {
                foreach (GERelationConfigsInfo config in VoucherProvider.GetRelationConfigs(this.Screen.DataManager.MainObject.TableName))
                {
                    AddNewToolbarButton("UtilitiesItem", String.Format("Tạo từ {0}", DataConfigProvider.GetTableCaption(config.SourceTableName)), config.GetID(), "NewFromRelation-" + config.SourceTableName, 46);
                    SetToolBarButtonVisibility(ABCView.ScreenBarButton.Utilities, true);
                }
            }

            this.View.ToolbarClickEvent += new ABCView.ABCToobarClickEventHandler(View_ToolbarClickEvent);
        }
Ejemplo n.º 2
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.º 3
0
        public static bool CheckVoucherPermission(Guid iUserID, String strTableName, Guid ID, VoucherPermission permission)
        {
            BusinessObject obj = VoucherProvider.GetConfig(strTableName, ID);

            if (obj != null)
            {
                return(CheckVoucherPermission(iUserID, obj.GetID(), permission));
            }

            return(true);
        }
Ejemplo n.º 4
0
        public void ReloadDatas( )
        {
            if (RelationConfig == null)
            {
                return;
            }

            VoucherProvider.ReCalculateRelation(RelationConfig.GERelationConfigID);

            if (MainGridCtrl != null && RelationConfig.IsFromSource)
            {
                object datasource = null;
                Type   objType    = BusinessObjectFactory.GetBusinessObjectType(RelationConfig.SourceTableName);
                if (objType != null)
                {
                    Type       typeABCList = typeof(ABCList <>).MakeGenericType(objType);
                    MethodInfo method;
                    if (typeABCList != null)
                    {
                        datasource = ABCBusinessEntities.ABCDynamicInvoker.CreateInstanceObject(typeABCList);
                        method     = typeABCList.GetMethod("LoadData", new Type[] { typeof(List <BusinessObject>) });
                        method.Invoke(datasource, new object[] { VoucherProvider.GetOpenningRelationObjects(RelationConfig.GERelationConfigID, false) });
                    }
                }
                bindingMain.DataSource = datasource;
                bindingMain.ResetBindings(false);

                this.MainGridCtrl.GridDefaultView.BestFitColumns();
            }

            if (ItemGridCtrl != null && RelationConfig.IsFromSourceItem)
            {
                object datasource = null;
                Type   objType    = BusinessObjectFactory.GetBusinessObjectType(RelationConfig.SourceItemTableName);
                if (objType != null)
                {
                    Type       typeABCList = typeof(ABCList <>).MakeGenericType(objType);
                    MethodInfo method;
                    if (typeABCList != null)
                    {
                        datasource = ABCBusinessEntities.ABCDynamicInvoker.CreateInstanceObject(typeABCList);
                        method     = typeABCList.GetMethod("LoadData", new Type[] { typeof(List <BusinessObject>) });
                        method.Invoke(datasource, new object[] { VoucherProvider.GetOpenningRelationObjects(RelationConfig.GERelationConfigID, true) });
                    }
                }
                bindingItem.DataSource = datasource;
                bindingItem.ResetBindings(false);

                this.ItemGridCtrl.GridDefaultView.BestFitColumns();
            }
        }
Ejemplo n.º 5
0
        public static void CalculateCredit(String strTableName, Guid ID)
        {
            List <Guid> lstPartnerIDs     = new List <Guid>();
            BusinessObjectController ctrl = BusinessControllerFactory.GetBusinessController(strTableName);

            if (ctrl != null)
            {
                BusinessObject obj = ctrl.GetObjectByID(ID);
                if (obj != null)
                {
                    String strPartnerFKCol = DataStructureProvider.GetForeignKeyOfTableName(strTableName, "MAPartners");
                    if (String.IsNullOrWhiteSpace(strPartnerFKCol) == false)
                    {
                        Guid partnerID = ABCHelper.DataConverter.ConvertToGuid(ABCDynamicInvoker.GetValue(obj, strPartnerFKCol));
                        if (partnerID != Guid.Empty && !lstPartnerIDs.Contains(partnerID))
                        {
                            lstPartnerIDs.Add(partnerID);
                        }
                    }

                    foreach (GEVoucherItemsInfo voucherItem in VoucherProvider.GetConfigItems(strTableName, ""))
                    {
                        strPartnerFKCol = DataStructureProvider.GetForeignKeyOfTableName(voucherItem.ItemTableName, "MAPartners");
                        if (String.IsNullOrWhiteSpace(strPartnerFKCol) == false)
                        {
                            Guid partnerID = ABCHelper.DataConverter.ConvertToGuid(ABCDynamicInvoker.GetValue(obj, strPartnerFKCol));
                            if (partnerID != Guid.Empty && !lstPartnerIDs.Contains(partnerID))
                            {
                                lstPartnerIDs.Add(partnerID);
                            }
                        }
                    }
                }
            }
            foreach (Guid partnerID in lstPartnerIDs)
            {
                CreditProvider.CalculateCredit(partnerID);
            }
        }
Ejemplo n.º 6
0
        public void Search( )
        {
            if (BindingObject != null && GridCtrl != null)
            {
                if (BindingObject.DataManager.MainObject == null)
                {
                    return;
                }

                BusinessObject           mainObj = BindingObject.DataManager.MainObject.DataObject as BusinessObject;
                BusinessObjectController ctrl    = BusinessControllerFactory.GetBusinessController(mainObj.AATableName);

                ConditionBuilder strBuilder = BindingObject.GenerateQuery(true);

                if (strBuilder == null || String.IsNullOrWhiteSpace(strBuilder.ToString()))
                {
                    return;
                }

                if (SearchPanel != null)
                {
                    SearchPanel.GetSearchQuery(strBuilder, SearchPanel);
                }

                if (BindingObject.DataManager.Screen.UIManager.View.DataField != null)
                {
                    GEVouchersInfo config = VoucherProvider.GetConfig(BindingObject.TableName, BindingObject.DataManager.Screen.UIManager.View.DataField.STViewNo);
                    if (config != null && !String.IsNullOrWhiteSpace(config.ConditionString))
                    {
                        strBuilder.AddCondition(config.ConditionString);
                    }
                }

                if (DataStructureProvider.IsTableColumn(BindingObject.TableName, ABCCommon.ABCConstString.colApprovalStatus))
                {
                    if (chkNotYetApproved.Checked)
                    {
                        strBuilder.AddCondition(String.Format("{0}<>'{1}'", ABCCommon.ABCConstString.colApprovalStatus, ABCCommon.ABCConstString.ApprovalTypeApproved));
                    }
                }

                if (DataStructureProvider.IsTableColumn(BindingObject.TableName, ABCCommon.ABCConstString.colLockStatus))
                {
                    if (chkLocked.Checked)
                    {
                        strBuilder.AddCondition(String.Format("{0}='{1}'", ABCCommon.ABCConstString.colLockStatus, ABCCommon.ABCConstString.LockStatusLocked));
                    }
                }

                if (DataStructureProvider.IsTableColumn(BindingObject.TableName, ABCCommon.ABCConstString.colJournalStatus))
                {
                    if (chkNotYetPosted.Checked)
                    {
                        strBuilder.AddCondition(String.Format("{0}<>'{1}'", ABCCommon.ABCConstString.colJournalStatus, ABCCommon.ABCConstString.PostStatusPosted));
                    }
                }

                object datasource = null;
                Type   objType    = BusinessObjectFactory.GetBusinessObjectType(GridCtrl.TableName);
                if (objType != null)
                {
                    Type       typeABCList = typeof(ABCList <>).MakeGenericType(objType);
                    MethodInfo method;
                    if (typeABCList != null)
                    {
                        datasource = ABCBusinessEntities.ABCDynamicInvoker.CreateInstanceObject(typeABCList);
                        method     = typeABCList.GetMethod("LoadData", new Type[] { typeof(List <BusinessObject>) });
                        method.Invoke(datasource, new object[] { ctrl.GetListByQuery(strBuilder.ToString()) });
                    }
                }
                binding.DataSource = datasource;
                binding.ResetBindings(false);

                this.GridCtrl.GridDefaultView.BestFitColumns();

                for (int i = 0; i < this.GridCtrl.GridDefaultView.DataRowCount; i++)
                {
                    BusinessObject obj = this.GridCtrl.GridDefaultView.GetRow(i) as BusinessObject;
                    if (obj != null && obj.GetID() == mainObj.GetID())
                    {
                        this.GridCtrl.GridDefaultView.FocusedRowHandle = i;
                        return;
                    }
                }
            }
        }
Ejemplo n.º 7
0
        private void btnSelect_Click(object sender, EventArgs e)
        {
            SelectedObjects.Clear();

            if (RelationConfig == null)
            {
                this.Close();
                return;
            }

            DestinyResult = null;
            if (RelationConfig.IsFromSource && tabControl.SelectedTabPage == mainTab)
            {
                #region From Main
                foreach (BusinessObject obj in ((BindingSource)MainGridCtrl.GridDataSource).DataSource as System.Collections.IList)
                {
                    if (obj.Selected)
                    {
                        SelectedObjects.Add(obj);
                    }
                }
                if (SelectedObjects.Count <= 0)
                {
                    ABCMessageBox.Show("Vui lòng chọn dữ liệu trước khi tạo phiếu !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    this.Close();
                    return;
                }
                if (!RelationConfig.IsMultiSource && SelectedObjects.Count > 1)
                {
                    ABCMessageBox.Show("Chỉ được chọn 1 dòng !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    this.Close();
                    return;
                }
                #endregion

                DestinyResult = VoucherProvider.CreateVoucherFromRelation(RelationConfig.GERelationConfigID, false, SelectedObjects);
            }
            else if (RelationConfig.IsFromSourceItem && tabControl.SelectedTabPage == itemTab)
            {
                #region From Item
                foreach (BusinessObject obj in ((BindingSource)ItemGridCtrl.GridDataSource).DataSource as System.Collections.IList)
                {
                    if (obj.Selected)
                    {
                        SelectedObjects.Add(obj);
                    }
                }
                if (SelectedObjects.Count <= 0)
                {
                    ABCMessageBox.Show("Vui lòng chọn dữ liệu trước khi tạo phiếu !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    this.Close();
                    return;
                }
                if (!RelationConfig.IsMultiSource && SelectedObjects.Count > 1)
                {
                    ABCMessageBox.Show("Chỉ được chọn 1 dòng !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    this.Close();
                    return;
                }
                #endregion

                DestinyResult = VoucherProvider.CreateVoucherFromRelation(RelationConfig.GERelationConfigID, true, SelectedObjects);
            }
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            if (DestinyResult != null && DestinyResult.GetID() != Guid.Empty)
            {
                ABCScreenManager.Instance.RunLink(RelationConfig.DestinyTableName, ABCCommon.ViewMode.Runtime, false, DestinyResult.GetID(), ABCCommon.ABCScreenAction.None);
            }
            this.Close();
        }