Exemple #1
0
        protected virtual void setIsRowChecked(TableSetting <P> tableSetting, bool?isChecked, string viewFilter)
        {
            if (null == tableSetting || !tableSetting.Table.Columns.Contains(tableSetting.IsCheckedColumnName) || tableSetting.Table.Columns[tableSetting.IsCheckedColumnName].DataType != typeof(bool))
            {
                return;
            }

            foreach (DataRowView rowView in this.getView(tableSetting, viewFilter, false))
            {
                try
                {
                    if (isChecked.HasValue)
                    {
                        rowView[tableSetting.IsCheckedColumnName] = isChecked;
                    }
                    else if (rowView.Row.IsNull(tableSetting.IsCheckedColumnName))
                    {
                        rowView[tableSetting.IsCheckedColumnName] = true;
                    }
                    else
                    {
                        rowView[tableSetting.IsCheckedColumnName] = !Convert.ToBoolean(rowView[tableSetting.IsCheckedColumnName]);
                    }
                }
                catch
                { }
            }
        }
Exemple #2
0
        protected DataView getView(TableSetting <P> tableSetting, string viewFilter, bool isUseChecked)
        {
            if (null == tableSetting)
            {
                return(new DataView( ));
            }

            DataView view = new DataView(tableSetting.Table);

            viewFilter = string.IsNullOrEmpty(viewFilter) ? this.window.GetViewFilter(tableSetting) : viewFilter;

            if (isUseChecked)
            {
                if (tableSetting.Table.Columns.Contains(tableSetting.IsCheckedColumnName) && tableSetting.Table.Columns[tableSetting.IsCheckedColumnName].DataType == typeof(bool))
                {
                    if (string.IsNullOrEmpty(viewFilter))
                    {
                        viewFilter = string.Format("{0} = true", tableSetting.IsCheckedColumnName);
                    }
                    else
                    {
                        viewFilter = string.Format("({0}) and {1} = true", viewFilter, tableSetting.IsCheckedColumnName);
                    }
                }
            }

            view.RowFilter = viewFilter;
            view.Sort      = this.window.GetViewSort(tableSetting);

            return(view);
        }
Exemple #3
0
        /// <summary>
        /// 得到名称对应的 DataTable.
        /// </summary>
        /// <param name="tableSettings">DataTable 设置数组.</param>
        /// <param name="name">设置的名称.</param>
        /// <returns>对应的 DataTable.</returns>
        public static DataTable GetTable(TableSetting <P>[] tableSettings, string name)
        {
            TableSetting <P> tableSetting = GetTableSetting(tableSettings, name);

            if (null == tableSetting)
            {
                return(null);
            }

            return(tableSetting.Table);
        }
Exemple #4
0
        protected void checkDataActionEnabled(TableSetting <P> tableSetting, DataActionType actionType)
        {
            bool isHasRow = this.getView(tableSetting, null, false).Count != 0;

            switch (actionType)
            {
            case DataActionType.Add:
                this.window.SetIsDataActionEnabled(tableSetting, DataActionType.Update, true);
                this.window.SetIsDataActionEnabled(tableSetting, DataActionType.Modify, true);
                this.window.SetIsDataActionEnabled(tableSetting, DataActionType.Delete, true);
                this.window.SetIsDataActionEnabled(tableSetting, DataActionType.Add, true);
                this.window.SetIsDataActionEnabled(tableSetting, DataActionType.Fill, true);
                break;

            case DataActionType.Delete:
                this.window.SetIsDataActionEnabled(tableSetting, DataActionType.Update, true);
                this.window.SetIsDataActionEnabled(tableSetting, DataActionType.Modify, true);
                this.window.SetIsDataActionEnabled(tableSetting, DataActionType.Delete, isHasRow);
                this.window.SetIsDataActionEnabled(tableSetting, DataActionType.Add, true);
                this.window.SetIsDataActionEnabled(tableSetting, DataActionType.Fill, true);
                break;

            case DataActionType.Fill:
                this.window.SetIsDataActionEnabled(tableSetting, DataActionType.Update, true);
                this.window.SetIsDataActionEnabled(tableSetting, DataActionType.Modify, true);
                this.window.SetIsDataActionEnabled(tableSetting, DataActionType.Delete, isHasRow);
                this.window.SetIsDataActionEnabled(tableSetting, DataActionType.Add, true);
                this.window.SetIsDataActionEnabled(tableSetting, DataActionType.Fill, true);
                break;

            case DataActionType.Modify:
                this.window.SetIsDataActionEnabled(tableSetting, DataActionType.Update, true);
                this.window.SetIsDataActionEnabled(tableSetting, DataActionType.Modify, true);
                this.window.SetIsDataActionEnabled(tableSetting, DataActionType.Delete, isHasRow);
                this.window.SetIsDataActionEnabled(tableSetting, DataActionType.Add, true);
                this.window.SetIsDataActionEnabled(tableSetting, DataActionType.Fill, true);
                break;

            case DataActionType.Update:
                this.window.SetIsDataActionEnabled(tableSetting, DataActionType.Update, true);
                this.window.SetIsDataActionEnabled(tableSetting, DataActionType.Modify, true);
                this.window.SetIsDataActionEnabled(tableSetting, DataActionType.Delete, isHasRow);
                this.window.SetIsDataActionEnabled(tableSetting, DataActionType.Add, true);
                this.window.SetIsDataActionEnabled(tableSetting, DataActionType.Fill, true);
                break;
            }
        }
Exemple #5
0
        protected void bindDataEvent <A> (object target, Type type, string eventName, EventHandlerType eventType, DataActionType actionType, params string[] tableNames) where A : EventArgs
        {
#if V3_5 || V4
            this.BindEvent <A> (target, type, eventName, eventType,
                                delegate(object sender, A e)
            {
                if (null == tableNames)
                {
                    return;
                }

                List <TableSetting <P> > tableSettings = new List <TableSetting <P> > ( );

                foreach (string tableName in tableNames)
                {
                    if (!string.IsNullOrEmpty(tableName) && this.tableSettings.ContainsKey(tableName))
                    {
                        TableSetting <P> tableSetting = this.tableSettings[tableName];
                        tableSetting.FilterRows.Clear( );
                        tableSetting.FilterAddedRows.Clear( );
                        tableSetting.FilterDeletedRows.Clear( );
                        tableSetting.FilterModifiedRows.Clear( );
                        tableSetting.AddedRows.Clear( );
                        tableSetting.DeletedRows.Clear( );
                        tableSetting.ModifiedRows.Clear( );

                        foreach (DataRowView rowView in this.getView(tableSetting, null, true))
                        {
                            tableSetting.FilterRows.Add(rowView.Row);

                            switch (rowView.Row.RowState)
                            {
                            case DataRowState.Added:
                                tableSetting.FilterAddedRows.Add(rowView.Row);
                                break;

                            case DataRowState.Deleted:
                                tableSetting.FilterDeletedRows.Add(rowView.Row);
                                break;

                            case DataRowState.Modified:
                                tableSetting.FilterModifiedRows.Add(rowView.Row);
                                break;
                            }
                        }

                        foreach (DataRow row in tableSetting.Table.Rows)
                        {
                            switch (row.RowState)
                            {
                            case DataRowState.Added:
                                tableSetting.AddedRows.Add(row);
                                break;

                            case DataRowState.Deleted:
                                tableSetting.DeletedRows.Add(row);
                                break;

                            case DataRowState.Modified:
                                tableSetting.ModifiedRows.Add(row);
                                break;
                            }
                        }

                        tableSettings.Add(tableSetting);
                    }
                }

                switch (actionType)
                {
                case DataActionType.Fill:
                    this.fillData(tableSettings.ToArray( ));
                    break;

                case DataActionType.Add:
                    this.addData(tableSettings.ToArray( ));
                    break;

                case DataActionType.Delete:
                    this.deleteData(tableSettings.ToArray( ));
                    break;

                case DataActionType.Modify:
                    this.modifyData(tableSettings.ToArray( ));
                    break;

                case DataActionType.Update:
                    this.updateData(tableSettings.ToArray( ));
                    break;
                }

                foreach (TableSetting <P> tableSetting in tableSettings)
                {
                    this.dataCompleted(tableSetting, actionType);
                }
            }
                                );
#else
            this.BindEvent <A> (target, type, eventName, eventType, null);
#endif
        }
Exemple #6
0
        protected virtual void setPager(TableSetting <P> tableSetting, PagerActionType actionType, int pagerIndex)
        {
            if (null == tableSetting || null == tableSetting.PagerSetting)
            {
                return;
            }

            P pagerSetting = tableSetting.PagerSetting;

            switch (actionType)
            {
            case PagerActionType.First:
                pagerSetting.Index = 1;
                break;

            case PagerActionType.Next:

                if (!pagerSetting.IsLast)
                {
                    pagerSetting.Index += 1;
                }

                break;

            case PagerActionType.Prev:

                if (!pagerSetting.IsFirst)
                {
                    pagerSetting.Index -= 1;
                }

                break;

            case PagerActionType.Last:

                if (pagerSetting.Count > 0)
                {
                    pagerSetting.Index = pagerSetting.Count;
                }

                break;

            case PagerActionType.GoTo:

                if (pagerIndex <= 0 || (pagerSetting.Count > 0 && pagerIndex > pagerSetting.Count))
                {
                    return;
                }

                pagerSetting.Index = pagerIndex;
                break;
            }

            this.window.SetIsPagerControlEnabled(tableSetting, PagerActionType.First, !pagerSetting.IsEmpty && !pagerSetting.IsFirst);
            this.window.SetIsPagerControlEnabled(tableSetting, PagerActionType.Last, !pagerSetting.IsEmpty && !pagerSetting.IsLast);
            this.window.SetIsPagerControlEnabled(tableSetting, PagerActionType.Next, !pagerSetting.IsEmpty && !pagerSetting.IsLast);
            this.window.SetIsPagerControlEnabled(tableSetting, PagerActionType.Prev, !pagerSetting.IsEmpty && !pagerSetting.IsFirst);
            this.window.SetIsPagerControlEnabled(tableSetting, PagerActionType.GoTo, !pagerSetting.IsEmpty && !(pagerSetting.IsFirst && pagerSetting.IsLast));

            this.window.SetPager(tableSetting);
        }
Exemple #7
0
        protected virtual void dataCompleted(TableSetting <P> tableSetting, DataActionType actionType)
        {
            this.setPager(tableSetting, PagerActionType.None, 0);

            this.checkDataActionEnabled(tableSetting, actionType);
        }