public void ReloadDatas( )
        {
            if (!String.IsNullOrWhiteSpace(TableName) && GridCtrl != null && DataStructureProvider.IsExistedTable(TableName))
            {
                BusinessObjectController ctrl = BusinessControllerFactory.GetBusinessController(TableName);

                String strQuery = QueryGenerator.GenSelect(TableName, "*", true);
                strQuery = QueryGenerator.AddCondition(strQuery, ConditionString);

                if (DataStructureProvider.IsTableColumn(TableName, ABCCommon.ABCConstString.colDocumentDate))
                {
                    strQuery = strQuery + String.Format(@" ORDER BY {0} DESC", ABCCommon.ABCConstString.colDocumentDate);
                }

                GridCtrl.GridDataSource = ctrl.GetListByQuery(strQuery);
                GridCtrl.RefreshDataSource();
                this.GridCtrl.GridDefaultView.BestFitColumns();
            }
        }
Exemple #2
0
        public void ReloadDatas( )
        {
            foreach (Guid iD in lstGridControls.Keys)
            {
                List <BusinessObject> lstObjs = AlertProvider.GetAlertData(iD);

                ABCGridControl GridCtrl = lstGridControls[iD];

                #region datasource
                BindingSource binding = new BindingSource();
                GridCtrl.GridDataSource = binding;
                GridCtrl.RefreshDataSource();

                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[] { lstObjs });
                    }
                }

                binding.DataSource = datasource;
                binding.ResetBindings(false);

                #endregion
                if (lstObjs.Count <= 0)
                {
                    GridCtrl.Parent.Visible = false;
                }
                GridCtrl.GridDefaultView.BestFitColumns();
            }
        }
        public void InitializeControls( )
        {
            //SearchPanel=new ABCAutoSearchPanel();
            //SearchPanel.PopulateControls( BindingObject.TableName );
            //SearchPanel.Dock=System.Windows.Forms.DockStyle.Top;
            //this.Width=SearchPanel.Width+30;

            //SearchPanel.Parent=this;
            //SearchPanel.Search+=new ABCSearchPanel.ABCSearchEventHandler( SearchPanel_Search );

            GridCtrl = new ABCGridControl();
            GridCtrl.Initialize(BindingObject.TableName);

            binding = new BindingSource();
            GridCtrl.GridDataSource = binding;
            GridCtrl.RefreshDataSource();

            if (DataStructureProvider.IsTableColumn(BindingObject.TableName, ABCCommon.ABCConstString.colEditCount))
            {
                if (GridCtrl.GridDefaultView.Columns.ColumnByFieldName(ABCCommon.ABCConstString.colEditCount) == null)
                {
                    ABCGridColumn col = new ABCGridColumn();
                    col.FieldName                     = ABCCommon.ABCConstString.colEditCount;
                    col.Caption                       = "Hiệu chỉnh";
                    col.TableName                     = BindingObject.TableName;
                    col.VisibleIndex                  = GridCtrl.GridDefaultView.Columns.Count - 1;
                    col.Visible                       = true;
                    col.Width                         = 20;
                    col.OptionsColumn.AllowEdit       = false;
                    col.FilterMode                    = DevExpress.XtraGrid.ColumnFilterMode.DisplayText;
                    col.OptionsFilter.AllowAutoFilter = true;
                    GridCtrl.GridDefaultView.Columns.Insert(GridCtrl.GridDefaultView.Columns.Count - 1, col);
                }
                //if ( GridCtrl.GridDefaultView.Columns.ColumnByFieldName( ABCCommon.ABCConstString.colSelected )==null )
                //{
                //    ABCGridColumn col=new ABCGridColumn();
                //    col.FieldName=ABCCommon.ABCConstString.colSelected;
                //    col.Caption="Chọn";
                //    col.TableName=BindingObject.TableName;
                //    col.VisibleIndex=0;
                //    col.Visible=true;
                //    col.Width=20;
                //    col.OptionsColumn.AllowEdit=true;
                //    col.FilterMode=DevExpress.XtraGrid.ColumnFilterMode.DisplayText;
                //    col.OptionsFilter.AllowAutoFilter=true;
                //    col.ColumnEdit=new DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit();
                //    GridCtrl.GridDefaultView.Columns.Add( col );
                //}
            }


            GridCtrl.Dock                         = System.Windows.Forms.DockStyle.Fill;
            GridCtrl.Parent                       = this;
            GridCtrl.ShowSaveButton               = false;
            GridCtrl.ShowDeleteButton             = false;
            GridCtrl.ShowRefreshButton            = false;
            GridCtrl.EnableFocusedCell            = false;
            GridCtrl.FocusRectStyle               = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus;
            GridCtrl.GridDefaultView.DoubleClick += new EventHandler(GridDefaultView_DoubleClick);
            GridCtrl.GridDefaultView.MouseUp     += new System.Windows.Forms.MouseEventHandler(GridDefaultView_MouseUp);
            GridCtrl.BringToFront();

            this.Height = 400;
            this.Width  = 700;
            if (BindingObject.DataManager.Screen.ViewForm != null)
            {
                this.Location = new Point(BindingObject.DataManager.Screen.ViewForm.Left - this.Width, BindingObject.DataManager.Screen.ViewForm.Top);
                this.Height   = BindingObject.DataManager.Screen.ViewForm.Height;
                BindingObject.DataManager.Screen.ViewForm.LocationChanged += new EventHandler(ABCSearchView_LocationChanged);
                BindingObject.DataManager.Screen.ViewForm.SizeChanged     += new EventHandler(ABCSearchView_SizeChanged);
                this.Width = 300;
            }
            this.Shown       += new EventHandler(ABCSearchView_Shown);
            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(ABCSearchView_FormClosing);

            this.ShowInTaskbar = false;

            this.Text = "Danh sách " + DataConfigProvider.GetTableCaption(BindingObject.TableName);

            chkNotYetApproved.Visible         = DataStructureProvider.IsTableColumn(BindingObject.TableName, ABCCommon.ABCConstString.colApprovalStatus);
            chkLocked.Visible                 = DataStructureProvider.IsTableColumn(BindingObject.TableName, ABCCommon.ABCConstString.colLockStatus);
            chkNotYetPosted.Visible           = DataStructureProvider.IsTableColumn(BindingObject.TableName, ABCCommon.ABCConstString.colJournalStatus);
            chkNotYetApproved.Checked         = false;
            chkLocked.Checked                 = false;
            chkNotYetPosted.Checked           = false;
            chkNotYetApproved.CheckedChanged += new EventHandler(chk_CheckedChanged);
            chkLocked.CheckedChanged         += new EventHandler(chk_CheckedChanged);
            chkNotYetPosted.CheckedChanged   += new EventHandler(chk_CheckedChanged);
            this.StartPosition                = FormStartPosition.CenterParent;

            //   SearchPanel_Search( null );
        }
Exemple #4
0
        public void InitializeControls( )
        {
            if (RelationConfig == null)
            {
                return;
            }

            if (RelationConfig.IsFromSource)
            {
                #region MainObject
                MainGridCtrl = new ABCGridControl();
                MainGridCtrl.Initialize(RelationConfig.SourceTableName);
                bindingMain = new BindingSource();
                MainGridCtrl.GridDataSource = bindingMain;
                MainGridCtrl.RefreshDataSource();

                ABCGridColumn col = new ABCGridColumn();
                col.FieldName                     = ABCCommon.ABCConstString.colSelected;
                col.Caption                       = "Chọn";
                col.TableName                     = RelationConfig.SourceTableName;
                col.VisibleIndex                  = 0;
                col.Visible                       = true;
                col.Width                         = 20;
                col.OptionsColumn.AllowEdit       = true;
                col.FilterMode                    = DevExpress.XtraGrid.ColumnFilterMode.DisplayText;
                col.OptionsFilter.AllowAutoFilter = true;
                col.ColumnEdit                    = new DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit();
                MainGridCtrl.GridDefaultView.Columns.Insert(0, col);

                MainGridCtrl.Dock              = System.Windows.Forms.DockStyle.Fill;
                MainGridCtrl.Parent            = mainTab;
                MainGridCtrl.ShowSaveButton    = false;
                MainGridCtrl.ShowDeleteButton  = false;
                MainGridCtrl.ShowRefreshButton = false;
                MainGridCtrl.EnableFocusedCell = false;
                MainGridCtrl.FocusRectStyle    = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus;
                MainGridCtrl.BringToFront();

                mainTab.Text = " Chọn " + DataConfigProvider.GetTableCaption(RelationConfig.SourceTableName);

                #endregion
            }
            if (RelationConfig.IsFromSourceItem)
            {
                #region ItemObject
                ItemGridCtrl = new ABCGridControl();
                ItemGridCtrl.Initialize(RelationConfig.SourceItemTableName);
                bindingItem = new BindingSource();
                ItemGridCtrl.GridDataSource = bindingItem;
                ItemGridCtrl.RefreshDataSource();

                ABCGridColumn col = new ABCGridColumn();
                col.FieldName                     = ABCCommon.ABCConstString.colSelected;
                col.Caption                       = "Chọn";
                col.TableName                     = RelationConfig.SourceItemTableName;
                col.VisibleIndex                  = 0;
                col.Visible                       = true;
                col.Width                         = 20;
                col.OptionsColumn.AllowEdit       = true;
                col.FilterMode                    = DevExpress.XtraGrid.ColumnFilterMode.DisplayText;
                col.OptionsFilter.AllowAutoFilter = true;
                col.ColumnEdit                    = new DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit();
                ItemGridCtrl.GridDefaultView.Columns.Insert(0, col);

                ItemGridCtrl.Dock              = System.Windows.Forms.DockStyle.Fill;
                ItemGridCtrl.Parent            = itemTab;
                ItemGridCtrl.ShowSaveButton    = false;
                ItemGridCtrl.ShowDeleteButton  = false;
                ItemGridCtrl.ShowRefreshButton = false;
                ItemGridCtrl.EnableFocusedCell = false;
                ItemGridCtrl.FocusRectStyle    = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus;
                ItemGridCtrl.BringToFront();

                itemTab.Text = " Chọn " + DataConfigProvider.GetTableCaption(RelationConfig.SourceItemTableName);


                #endregion
            }

            this.Shown        += new EventHandler(ABCRelationChooser_Shown);
            this.ShowInTaskbar = false;
            this.StartPosition = FormStartPosition.CenterParent;

            this.Text = String.Format("Tạo {0} từ {1}", DataConfigProvider.GetTableCaption(RelationConfig.DestinyTableName), DataConfigProvider.GetTableCaption(RelationConfig.SourceTableName));
        }