Ejemplo n.º 1
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;
            }
        }
Ejemplo n.º 2
0
        // 在 SetIsDataActionEnabled 中设置各个按钮是否可用
        void IDataWindow <PagerSetting> .SetIsDataActionEnabled(TableSetting <PagerSetting> tableSetting, DataActionType actionType, bool isEnabled)
        {
            switch (tableSetting.Name)
            {
            case "Student":

                switch (actionType)
                {
                case DataActionType.Fill:
                    this.cmdFill.Enabled = isEnabled;
                    break;

                case DataActionType.Update:
                    this.cmdSave.Enabled = isEnabled;
                    break;
                }

                break;
            }
        }
Ejemplo n.º 3
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
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 绑定可以触发 DataTable 数据事件, 比如: Button 的 Click 事件, 当按钮被点击时, 填充 DataTable.
 /// </summary>
 /// <typeparam name="A">事件的参数类型, 必须从 EventArgs 派生.</typeparam>
 /// <param name="target">目标实例, 比如: 窗口上的 Button.</param>
 /// <param name="eventName">事件名称, 比如: "Click".</param>
 /// <param name="eventType">事件的类型, 比如: EventHandler.</param>
 /// <param name="actionType">行为的类型.</param>
 /// <param name="tableNames">表格的名称, 与 TableSetting 的 Name 一致.</param>
 public void BindDataEvent <A> (object target, string eventName, EventHandlerType eventType, DataActionType actionType, params string[] tableNames) where A : EventArgs
 {
     this.bindDataEvent <A> (target, null, eventName, eventType, actionType, tableNames);
 }
Ejemplo n.º 5
0
        protected virtual void dataCompleted(TableSetting <P> tableSetting, DataActionType actionType)
        {
            this.setPager(tableSetting, PagerActionType.None, 0);

            this.checkDataActionEnabled(tableSetting, actionType);
        }
Ejemplo n.º 6
0
        protected override void dataCompleted(TableSetting <P> tableSetting, DataActionType actionType)
        {
            base.dataCompleted(tableSetting, actionType);

            this.window.DataBind(tableSetting, actionType);
        }
Ejemplo n.º 7
0
 void IDataWindow <PagerSetting> .SetIsDataActionEnabled(TableSetting <PagerSetting> tableSetting, DataActionType actionType, bool isEnabled)
 {
 }