public void RemoveSelectedRow(MB.WinBase.Binding.BindingSourceEx bindingSource)
        {
            if (_DataViewType == DataViewType.GridView)
            {
                var rowIndexs = _GridView.GetSelectedRows();

                if (rowIndexs != null && rowIndexs.Count() > 0)
                {
                    List <object> toBeDeletedObjects = new List <object>();

                    foreach (var rowIndex in rowIndexs)
                    {
                        toBeDeletedObjects.Add(bindingSource[rowIndex]);
                    }

                    foreach (var item in toBeDeletedObjects)
                    {
                        bindingSource.Remove(item);
                    }
                }
            }
            else if (_DataViewType == DataViewType.TreeListView)
            {
                foreach (var node in _TreeList.Selection)
                {
                    _TreeList.DeleteNode(node as TreeListNode);
                }
            }
        }
        /// <summary>
        /// 编辑界面的数据绑定分3步来完成
        /// 1,先绑定ComboBox 的数据源
        /// 2,绑定点击选择数据的数据源
        /// 3,控件编辑绑定
        /// </summary>
        /// <param name="colPropertys"></param>
        /// <param name="columnEditInfoList"></param>
        /// <param name="dataSource"></param>
        /// <param name="dataBindingProvider"></param>
        /// <param name="bindingOptions"></param>
        /// <returns></returns>
        public List <ColumnBindingInfo> CreateDataBinding(Dictionary <string, MB.WinBase.Common.ColumnPropertyInfo> colPropertys,
                                                          Dictionary <string, MB.WinBase.Common.ColumnEditCfgInfo> columnEditInfoList,
                                                          BindingSourceEx dataSource,
                                                          MB.WinBase.Binding.IDataBindingProvider dataBindingProvider,
                                                          DataBindingOptions bindingOptions)
        {
            //在数据绑定之前先清空文本框的数据
            ClearBindingEditCtl(dataBindingProvider);

            List <ColumnBindingInfo> bindingDatas = new List <ColumnBindingInfo>();
            Dictionary <string, MB.WinBase.Common.ColumnPropertyInfo> colsCfg = colPropertys;

            string[] fieldPropertys = getDataPropertysNames(dataSource);
            if (fieldPropertys == null || fieldPropertys.Length == 0)
            {
                throw new Exceptions.DataBindingException();
            }


            ctlDataBingByDataBinding(colPropertys, fieldPropertys, dataSource, dataBindingProvider, bindingOptions, bindingDatas, columnEditInfoList);

            //设置绑定Lable 的 描述展示信息
            ResetLableCaption(dataBindingProvider, colsCfg);

            return(bindingDatas);
        }
        /// <summary>
        /// 编辑界面的数据绑定分3步来完成
        /// 1,先绑定ComboBox 的数据源
        /// 2,绑定点击选择数据的数据源
        /// 3,控件编辑绑定
        /// </summary>
        /// <param name="dataSource"></param>
        /// <param name="xmlFileName"></param>
        /// <param name="dataBindingProvider"></param>
        /// <param name="bindingOptions"></param>
        /// <returns></returns>
        public List <ColumnBindingInfo> CreateDataBinding(BindingSourceEx dataSource, string xmlFileName,
                                                          MB.WinBase.Binding.IDataBindingProvider dataBindingProvider,
                                                          DataBindingOptions bindingOptions)
        {
            Dictionary <string, MB.WinBase.Common.ColumnPropertyInfo> colPropertys       = MB.WinBase.LayoutXmlConfigHelper.Instance.GetColumnPropertys(xmlFileName);
            Dictionary <string, MB.WinBase.Common.ColumnEditCfgInfo>  columnEditInfoList = MB.WinBase.LayoutXmlConfigHelper.Instance.GetColumnEdits(colPropertys, xmlFileName);

            return(CreateDataBinding(colPropertys, columnEditInfoList, dataSource, dataBindingProvider, bindingOptions));
        }
 /// <summary>
 /// 删除焦点行。
 /// </summary>
 /// <param name="bindingSource"></param>
 public void RemoveFocusedRow(MB.WinBase.Binding.BindingSourceEx bindingSource)
 {
     if (_DataViewType == DataViewType.GridView)
     {
         bindingSource.RemoveCurrent();
     }
     else
     {
         _TreeList.DeleteNode(_TreeList.FocusedNode);
     }
 }
        //判断两个表结构是否相同
        private bool checkTableStructIsSame(object oldSource, object newSource)
        {
            if (oldSource == null || newSource == null)
            {
                return(false);
            }

            MB.WinBase.Binding.BindingSourceEx oldBinding = grdCtlMain.DataSource as MB.WinBase.Binding.BindingSourceEx;
            MB.WinBase.Binding.BindingSourceEx newBinding = newSource as MB.WinBase.Binding.BindingSourceEx;
            if (oldBinding == null || newBinding == null)
            {
                return(false);
            }

            DataTable oldDt = MB.Util.MyConvert.Instance.ToDataTable(oldBinding.DataSource, string.Empty);
            DataTable newDt = MB.Util.MyConvert.Instance.ToDataTable(newBinding.DataSource, string.Empty);

            if (oldDt == null || newDt == null)
            {
                return(false);
            }
            foreach (DataColumn dc in oldDt.Columns)
            {
                if (!newDt.Columns.Contains(dc.ColumnName))
                {
                    return(false);
                }
            }
            foreach (DataColumn dc in newDt.Columns)
            {
                if (!oldDt.Columns.Contains(dc.ColumnName))
                {
                    return(false);
                }
            }
            return(true);
        }
Exemple #6
0
        /// <summary>
        /// 创建基于Xtra工具栏的默认标准编辑窗口.
        /// </summary>
        /// <param name="clientRuleObject"></param>
        /// <param name="editType"></param>
        /// <param name="mainViewGrid"></param>
        public XtraEfficientBaseEditForm(IClientRule clientRuleObject, ObjectEditType editType, MB.WinBase.Binding.BindingSourceEx bindingSource)
        {
            InitializeComponent();

            if (!MB.Util.General.IsInDesignMode() && editType != ObjectEditType.DesignDemo)
            {
                _DataValidated = new MB.WinBase.UIDataInputValidated(this);

                _MainGridBindingSource = bindingSource;
                _EditBindingSource     = new BindingSourceEx();
                _ClientRuleObject      = clientRuleObject;

                _BusinessOperateTrace = new BusinessOperateTrace(_ClientRuleObject);
                _BusinessOperateTrace.CommandItemClick += new EventHandler <MB.WinClientDefault.Common.EditDocStateTraceEventArgs>(_BusinessOperateTrace_CommandItemClick);

                _ExtendToolStripButtonMenu = _BusinessOperateTrace.CommandMenus;

                _CurrentEditType = editType;

                this.Load += new EventHandler(AbstractEditBaseForm_Load);


                _BeforeSaveDetailEntityCache              = new MB.WinBase.UIEditEntityList();
                _BeforeSaveDetailEntityCache.ListChanged += new ListChangedEventHandler(_DetailEditEntitys_ListChanged);

                _MainGridBindingSource.ListChanged     += new ListChangedEventHandler(_BindingSource_ListChanged);
                _MainGridBindingSource.PositionChanged += new EventHandler(_BindingSource_PositionChanged);

                _HasAddMainEntityEvent = new List <INotifyPropertyChanged>();
            }
            _GeneralCommands = new Dictionary <string, DevExpress.XtraBars.BarButtonItem>();
            _GeneralCommands.Add(MB.BaseFrame.SOD.MODULE_COMMAND_ADD, bntAddNewItem);
            _GeneralCommands.Add(MB.BaseFrame.SOD.MODULE_COMMAND_DELETE, bntDeleteItem);
            _GeneralCommands.Add(MB.BaseFrame.SOD.MODULE_COMMAND_SAVE, bntSaveItem);
            _GeneralCommands.Add(MB.BaseFrame.SOD.MODULE_COMMAND_SUBMIT, bntSubmitItem);
            _GeneralCommands.Add(MB.BaseFrame.SOD.MODULE_COMMAND_CANCEL_SUBMIT, bntCancelSubmitItem);
        }
        /// <summary>
        /// 编辑界面的数据绑定分3步来完成
        /// 1,先绑定ComboBox 的数据源
        /// 2,绑定点击选择数据的数据源
        /// 3,控件编辑绑定
        /// </summary>
        /// <param name="clientBaseRule"></param>
        /// <param name="dataSource"></param>
        /// <param name="ctls"></param>
        /// <returns></returns>
        public List <ColumnBindingInfo> CreateDataBinding(IFace.IClientRule clientBaseRule, BindingSourceEx dataSource,
                                                          MB.WinBase.Binding.IDataBindingProvider dataBindingProvider, DataBindingOptions bindingOptions)
        {
            ////在数据绑定之前先清空文本框的数据
            //ClearBindingEditCtl(dataBindingProvider);

            //List<ColumnBindingInfo> bindingDatas = new List<ColumnBindingInfo>();
            //Dictionary<string, MB.WinBase.Common.ColumnPropertyInfo> colsCfg = clientBaseRule.UIRuleXmlConfigInfo.GetDefaultColumns();
            //string[] propertys = getDataPropertysNames(dataSource);
            //if (propertys == null || propertys.Length == 0)
            //    throw new Exceptions.DataBindingException();


            //ctlDataBingByDataBinding(colsCfg, propertys, dataSource, dataBindingProvider, bindingOptions, bindingDatas, clientBaseRule.UIRuleXmlConfigInfo.ColumnsCfgEdit);

            ////设置绑定Lable 的 描述展示信息
            //ResetLableCaption(dataBindingProvider, colsCfg);

            //return bindingDatas;
            return(CreateDataBinding(clientBaseRule.UIRuleXmlConfigInfo.GetDefaultColumns(), clientBaseRule.UIRuleXmlConfigInfo.ColumnsCfgEdit, dataSource, dataBindingProvider, bindingOptions));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="clientRuleObject"></param>
        /// <param name="editType"></param>
        /// <param name="mainViewGrid"></param>
        public AbstractEditBaseForm(IClientRule clientRuleObject, ObjectEditType editType, MB.WinBase.Binding.BindingSourceEx bindingSource)
        {
            InitializeComponent();

            if (!MB.Util.General.IsInDesignMode() && editType != ObjectEditType.DesignDemo)
            {
                _DataValidated = new MB.WinBase.UIDataInputValidated(this);

                _BindingSource = bindingSource;

                _ClientRuleObject = clientRuleObject;
                //根据业务类上的配置项来进行约束操作菜单项。
                var rejectCfg = MB.WinBase.Atts.AttributeConfigHelper.Instance.GetModuleRejectCommands(_ClientRuleObject.GetType());
                if (rejectCfg != null)
                {
                    _RejectCommands = rejectCfg.RejectCommands;
                }
                //_RejectCommands
                _CurrentEditType = editType;

                // _MainViewGridControl = mainViewGrid;

                this.Load += new EventHandler(AbstractEditBaseForm_Load);

                _BeforeSaveDetailEntityCache              = new MB.WinBase.UIEditEntityList();
                _BeforeSaveDetailEntityCache.ListChanged += new ListChangedEventHandler(_DetailEditEntitys_ListChanged);

                bindingNavMain.ItemClicked += new ToolStripItemClickedEventHandler(bindingNavMain_ItemClicked);

                _BindingSource.ListChanged     += new ListChangedEventHandler(_BindingSource_ListChanged);
                _BindingSource.PositionChanged += new EventHandler(_BindingSource_PositionChanged);
                _BindingSource.AddingNew       += new AddingNewEventHandler(_BindingSource_AddingNew);
                //  bntPositionItem.KeyDown += new KeyEventHandler(bntPositionItem_KeyDown);

                //_HasLoadDetailData = new Dictionary<KeyValuePair<object, int>, object>();
                // _ExtendUICommands = new Dictionary<ToolStripButton, CommandID>();

                _HasAddMainEntityEvent = new List <INotifyPropertyChanged>();
            }
        }