예제 #1
0
 /// <summary>
 /// 把多维AdvBandGridView 转换为一维列表满足快速输入和数据导入导出Excel 的需求。
 /// </summary>
 /// <param name="grdCtlSrc"></param>
 /// <param name="dsSource"></param>
 /// <param name="dynamicCols"></param>
 /// <param name="xmlFileName"></param>
 public FrmQuickCellDataInput(DevExpress.XtraGrid.GridControl grdCtlSrc, DataTable dsSource,
                              List <MB.WinBase.Data.DynamicColumnInfo> dynamicCols, string xmlFileName)
     : this(grdCtlSrc, dsSource, dynamicCols, null, null, null)
 {
     if (!string.IsNullOrEmpty(xmlFileName))
     {
         _ColPropertys  = MB.WinBase.LayoutXmlConfigHelper.Instance.GetColumnPropertys(xmlFileName);
         _EditCols      = MB.WinBase.LayoutXmlConfigHelper.Instance.GetColumnEdits(_ColPropertys, xmlFileName);
         _ImportCfgInfo = MB.WinBase.LayoutXmlConfigHelper.Instance.GetDataImportCfgInfo(xmlFileName, null);
     }
 }
예제 #2
0
        /// <summary>
        /// 把多维AdvBandGridView 转换为一维列表满足快速输入和数据导入导出Excel 的需求。
        /// </summary>
        public FrmQuickCellDataInput(DevExpress.XtraGrid.GridControl grdCtlSrc, DataTable dsSource,
                                     List <MB.WinBase.Data.DynamicColumnInfo> dynamicCols,
                                     Dictionary <string, MB.WinBase.Common.ColumnPropertyInfo> colPropertys,
                                     Dictionary <string, MB.WinBase.Common.ColumnEditCfgInfo> editCols,
                                     MB.WinBase.Common.DataImportCfgInfo importCfgInfo)
        {
            InitializeComponent();

            _GrdCtlSrc    = grdCtlSrc;
            _GridViewSrc  = grdCtlSrc.DefaultView as DevExpress.XtraGrid.Views.Grid.GridView;
            _ColPropertys = colPropertys;
            _EditCols     = editCols;

            _DtSource    = dsSource;
            _DynamicCols = dynamicCols;
            this.Load   += new EventHandler(FrmQuickCellDataInput_Load);
        }
예제 #3
0
        //以覆盖的方式进行数据导入
        private void dataImportByOveride(DataSet dsData)
        {
            DataRow[] drs = dsData.Tables[0].Select();
            MB.WinBase.Common.DataImportCfgInfo importCfgInfo = _ImportCfgInfo;
            string[] keys    = importCfgInfo.OverideKeys.Split(',');
            string[] oFields = importCfgInfo.OverideFields.Split(',');
            if (keys == null || keys.Length == 0)
            {
                throw new MB.Util.APPException("在数据覆盖导入是对DataImportCfgInfo 没有 配置 OverideKeys");
            }
            if (oFields == null || oFields.Length == 0)
            {
                throw new MB.Util.APPException("在数据覆盖导入是对DataImportCfgInfo 没有 配置 OverideFields");
            }
            List <DataRow> notExists = new List <DataRow>();

            DataRow[] editDatas = _DtSource.Select();
            foreach (DataRow dr in drs)
            {
                DataRow  findDataRow = null;
                string[] vals        = MB.Util.DataHelper.Instance.GetMultiFieldValue(dr, keys);

                bool exits = MB.Util.DataValidated.Instance.CheckExistsDataRow(editDatas, keys, vals.ToArray(), out findDataRow);
                if (!exits)
                {
                    continue;
                }

                foreach (string field in oFields)
                {
                    if (!findDataRow.Table.Columns.Contains(field))
                    {
                        throw new MB.Util.APPException(string.Format("导入配置的属性{0}不属于需要导入的表", field));
                    }
                    if (!dr.Table.Columns.Contains(field))
                    {
                        continue;
                    }
                    findDataRow[field] = dr[field];
                }
            }
        }