public static void ExportToExcel(DevExpress.XtraGrid.Views.Base.BaseView bv, string fileName) { //this.gridControl1.ExportToXlsx(fileName); try { //去除文件后缀名 string fileNameWithoutSuffix = fileName.Substring(0, fileName.LastIndexOf(".")); //后缀名 string aLastName = fileName.Substring(fileName.LastIndexOf(".") + 1, (fileName.Length - fileName.LastIndexOf(".") - 1)); //扩展名 if ((aLastName == "xls") & (!string.IsNullOrEmpty(fileName))) { bv.ExportToXls(fileName); //ExportTo(bv, new DevExpress.XtraExport.ExportXlsProvider(fileName)); } if ((aLastName == "xlsx") & !string.IsNullOrEmpty(fileName)) { bv.ExportToXlsx(fileName); // ExportTo(bv, new DevExpress.XtraExport.ExportXlsProvider(fileName)); } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
private void SetGridFont(DevExpress.XtraGrid.Views.Base.BaseView baseView, Font sFont) { foreach (AppearanceObject ap in baseView.Appearance) { ap.Font = sFont; } }
public static void CargaRejilla(string origenRejilla, DevExpress.XtraGrid.Views.Base.BaseView rejilla) { try { rejilla.RestoreLayoutFromXml(origenRejilla, null); } catch { } }
public MutilGridExport(DataTable dts, DevExpress.XtraGrid.Views.Base.BaseView[] exportViews, string FileKinds) { InitializeComponent(); dt.Load(dts.CreateDataReader()); exportView = new DevExpress.XtraGrid.Views.Base.BaseView[exportViews.Length]; exportView = exportViews; FileKind = FileKinds; }
private void UpdateTradeSummaryGrid() { string tableName = "SummaryData"; DevExpress.XtraGrid.Views.Base.BaseView activeView = null; DevExpress.XtraGrid.GridControl activeGrid = null; try { foreach (DevExpress.XtraGrid.GridControl grid in managedGridList) { DevExpress.XtraGrid.GridControlViewCollection views = grid.Views; activeGrid = grid; foreach (DevExpress.XtraGrid.Views.Base.BaseView view in views) { DataView dv = (DataView)view.DataSource; if (dv.Table.TableName == tableName) { // view.BeginDataUpdate(); activeView = view; foreach (SummaryData sumData in sumDataCache) { DataRow rowFound = dv.Table.Rows.Find(sumData.Id); if (rowFound != null) { string qryCode = (string)rowFound["QryCode"]; CollectionHelper.UpdateDataRowFromObject <SummaryData>(sumData, ref rowFound); if (!((qryCode == null) || (qryCode == ""))) { rowFound["QryCode"] = qryCode; // so as to not overwrite any "Get All" results. } } else { DataRow newRow = dv.Table.NewRow(); newRow = CollectionHelper.CreateDataRowFromObject <SummaryData>(sumData, newRow); dv.Table.Rows.Add(newRow); } } } } } } catch (Exception ex) { throw new Exception("An error occurred while updating the Trade Summary grid." + Environment.NewLine + "Error CNF-356 in " + PROJ_FILE_NAME + ".UpdateTradeRqmtGrid(): " + ex.Message); } finally { if (activeView != null) { // activeGrid.Invoke(new EndDataGridUpdate(EndDataUpdate), activeView); sumDataCache.Clear(); } } }
public static void ImportTo(DevExpress.XtraGrid.Views.Base.BaseView bv, DevExpress.XtraExport.IExportProvider provider) { Cursor currentCursor = Cursor.Current; Cursor.Current = Cursors.WaitCursor; DevExpress.XtraGrid.Export.BaseExportLink link = bv.CreateExportLink(provider); link.ExportTo(true); Cursor.Current = currentCursor; }
public void Save(FormClosingEventArgs e) { DevExpress.XtraGrid.Views.Base.BaseView view = gridControl1.FocusedView; if (!(view.PostEditor() && view.UpdateCurrentRow())) { if (e != null) { e.Cancel = true; } return; } quickContactTableAdapter.Update(registrationDataSet.QuickContact); }
private void UpdateTradeRqmtGrid() { string tableName = "RqmtData"; DevExpress.XtraGrid.Views.Base.BaseView activeView = null; DevExpress.XtraGrid.GridControl activeGrid = null; try { foreach (DevExpress.XtraGrid.GridControl grid in managedGridList) { DevExpress.XtraGrid.GridControlViewCollection views = grid.Views; activeGrid = grid; foreach (DevExpress.XtraGrid.Views.Base.BaseView view in views) { DataView dv = (DataView)view.DataSource; if (dv.Table.TableName == tableName) { // view.BeginDataUpdate(); activeView = view; foreach (RqmtData rqmtData in rqmtDataCache) { DataRow rowFound = dv.Table.Rows.Find(rqmtData.Id); if (rowFound != null) { CollectionHelper.UpdateDataRowFromObject <RqmtData>(rqmtData, ref rowFound); } else { DataRow newRow = dv.Table.NewRow(); newRow = CollectionHelper.CreateDataRowFromObject <RqmtData>(rqmtData, newRow); dv.Table.Rows.Add(newRow); } } } } } } catch (Exception ex) { throw new Exception("An error occurred while updating the Trade Rqmts grid." + Environment.NewLine + "Error CNF-355 in " + PROJ_FILE_NAME + ".UpdateTradeRqmtGrid(): " + ex.Message); } finally { if (activeView != null) { // activeGrid.Invoke(new EndDataGridUpdate(EndDataUpdate), activeView); rqmtDataCache.Clear(); } } }
private void ExportToEx(DevExpress.XtraExport.IExportProvider provider, DevExpress.XtraGrid.Views.Base.BaseView exportView) { Cursor currentCursor = Cursor.Current; Cursor.Current = Cursors.WaitCursor; DevExpress.XtraGrid.Export.BaseExportLink link = exportView.CreateExportLink(provider); if (link != null) { link.ExportCellsAsDisplayText = exportOption.Checked; link.ExportTo(true); } provider.Dispose(); Cursor.Current = currentCursor; }
/// <summary> /// Exports to ex. /// </summary> /// <param name="filename">The filename.</param> /// <param name="ext">The ext.</param> /// <param name="exportView">The export view.</param> private static void ExportToEx(String filename, string ext, DevExpress.XtraGrid.Views.Base.BaseView exportView) { Application.DoEvents(); try { Cursor currentCursor = Cursor.Current; Cursor.Current = Cursors.WaitCursor; //DevExpress.XtraPrinting.IPrintingSystem ps = DevExpress.XtraPrinting.PrintHelper.GetCurrentPS(); if (ext == "rtf") { exportView.ExportToRtf(filename); } if (ext == "pdf") { exportView.ExportToPdf(filename); } if (ext == "mht") { exportView.ExportToMht(filename); } if (ext == "htm") { exportView.ExportToHtml(filename); } if (ext == "txt") { exportView.ExportToText(filename); } if (ext == "xls") { exportView.ExportToXls(filename); } if (ext == "xlsx") { exportView.ExportToXlsx(filename); } Cursor.Current = currentCursor; } catch (Exception ex) { throw ex; } }
public void SetFocusedView(DevExpress.XtraGrid.Views.Base.BaseView value) { focusedView = value; }
private void EndDataUpdate(DevExpress.XtraGrid.Views.Base.BaseView view) { // view.EndDataUpdate(); }
private void UpdateInboundDocGrid() { string tableName = "InboundDocsView"; DevExpress.XtraGrid.Views.Base.BaseView activeView = null; DevExpress.XtraGrid.GridControl activeGrid = null; try { foreach (DevExpress.XtraGrid.GridControl grid in managedGridList) { DevExpress.XtraGrid.GridControlViewCollection views = grid.Views; activeGrid = grid; foreach (DevExpress.XtraGrid.Views.Base.BaseView view in views) { DataView dv = (DataView)view.DataSource; if (dv.Table.TableName == tableName) { // view.BeginDataUpdate(); activeView = view; foreach (InboundDocsView data in inbDocViewCache) { DataRow rowFound = dv.Table.Rows.Find(data.Id); if (rowFound != null) { // because inbound_doc_user_flag data is not include, we must copy this data to // the "data" object that is being used to update the data row found. if (rowFound["IgnoreFlag"] != System.DBNull.Value) { data.IgnoreFlag = rowFound["IgnoreFlag"].ToString(); } if (rowFound["BookmarkFlag"] != System.DBNull.Value) { data.BookmarkFlag = rowFound["BookmarkFlag"].ToString(); } if (rowFound["CommentFlag"] != System.DBNull.Value) { data.CommentFlag = rowFound["CommentFlag"].ToString(); } if (rowFound["CommentUser"] != System.DBNull.Value) { data.CommentUser = rowFound["CommentUser"].ToString(); } CollectionHelper.UpdateDataRowFromObject <InboundDocsView>(data, ref rowFound); } else { DataRow newRow = dv.Table.NewRow(); newRow = CollectionHelper.CreateDataRowFromObject <InboundDocsView>(data, newRow); dv.Table.Rows.Add(newRow); } } } } } } catch (Exception ex) { throw new Exception("An error occurred while updating the Inbound Documents grid." + Environment.NewLine + "Error CNF-353 in " + PROJ_FILE_NAME + ".UpdateInboundDocGrid(): " + ex.Message); } finally { if (activeView != null) { // activeGrid.Invoke(new EndDataGridUpdate(EndDataUpdate), activeView); inbDocViewCache.Clear(); } } }
public UxRepositoryItemComboBox(DevExpress.XtraGrid.Views.Base.BaseView view) { TextEditStyle = TextEditStyles.DisableTextEditor; EditValueChanged += (o, e) => view.PostEditor(); AllowMouseWheel = false; }
public override DevExpress.XtraGrid.Views.Base.ViewInfo.BaseViewInfo CreateViewInfo(DevExpress.XtraGrid.Views.Base.BaseView view) { return(new CustomGridViewInfo((GridView)view)); }
private void RefreshData() { while (!StaticClass.SystemOut) { try { Basic.Framework.Web.BasicResponse <List <JC_LargedataAnalysisConfigInfo> > response = largeDataAnalysisCacheClientService.GetAllLargeDataAnalysisConfigCache(new Sys.Safety.Request.LargeDataAnalysisCacheClientGetAllRequest()); if (response.Data != null) { //var dataSource = from q in response.Data.AsQueryable() // select new // { // Name = q.Name, // AnalysisTime = q.AnalysisTime.HasValue ? q.AnalysisTime.Value.ToString("yyyy/MM/dd HH:mm:ss") : string.Empty, // AnalysisResultText = q.AnalysisResultText, // ExpressionRealTimeResultList = ( // from rt in q.ExpressionRealTimeResultList // select new { AnalysisModelName = rt.AnalysisModelName, // ExpressionText = rt.ExpressionText, // FirstSuccessfulTime = rt.FirstSuccessfulTime == DateTime.MinValue ? string.Empty : rt.FirstSuccessfulTime.ToString("yyyy/MM/dd HH:mm:ss"), // LastAnalysisTime = rt.LastAnalysisTime == DateTime.MinValue ? string.Empty : rt.LastAnalysisTime.ToString("yyyy/MM/dd HH:mm:ss"), // AnalysisResultText = rt.AnalysisResultText, // ActualContinueTime = string.Format("{0}:{1}:{2}", (rt.ActualContinueTime / 3600).ToString().PadLeft(2, '0'), // (rt.ActualContinueTime % 3600 / 60).ToString().PadLeft(2, '0'), (rt.ActualContinueTime % 3600 % 60).ToString().PadLeft(2, '0')) }).ToList() // }; //gridList.Clear(); foreach (var item in response.Data) { bool isHaveModel = false; foreach (var itemGrid in gridList) { //old列表 if (itemGrid.Id == item.Id) { //分析模型已存在 isHaveModel = true; itemGrid.AnalysisTime = item.AnalysisTime; itemGrid.AnalysisResultText = item.AnalysisResultText; itemGrid.Name = item.Name; #region 分析列表 if (item.ExpressionRealTimeResultList != null) { //old列表 if (itemGrid.ExpressionRealTimeResultList != null && itemGrid.ExpressionRealTimeResultList.Count > 0) { //追加 foreach (var itemExpression in item.ExpressionRealTimeResultList) { //新分析数据 bool isAdd = true; foreach (var itemResult in itemGrid.ExpressionRealTimeResultList) {//old列表 if (itemResult.ExpressionId == itemExpression.ExpressionId) { isAdd = false; itemResult.ShowFirstSuccessfulTime = itemExpression.FirstSuccessfulTime == DateTime.MinValue ? string.Empty : itemExpression.FirstSuccessfulTime.ToString("yyyy/MM/dd HH:mm:ss"); itemResult.ShowLastAnalysisTime = itemExpression.LastAnalysisTime == DateTime.MinValue ? string.Empty : itemExpression.LastAnalysisTime.ToString("yyyy/MM/dd HH:mm:ss"); itemResult.AnalysisResultText = itemExpression.AnalysisResultText; itemResult.ShowActualContinueTime = string.Format("{0}:{1}:{2}", (itemExpression.ActualContinueTime / 3600).ToString().PadLeft(2, '0'), (itemExpression.ActualContinueTime % 3600 / 60).ToString().PadLeft(2, '0'), (itemExpression.ActualContinueTime % 3600 % 60).ToString().PadLeft(2, '0')); break; } } if (isAdd) { ExpressionRealTimeResultInfo modelInfo = new ExpressionRealTimeResultInfo(); modelInfo.ExpressionText = itemExpression.ExpressionText; modelInfo.ExpressionId = itemExpression.ExpressionId; modelInfo.ShowFirstSuccessfulTime = itemExpression.FirstSuccessfulTime == DateTime.MinValue ? string.Empty : itemExpression.FirstSuccessfulTime.ToString("yyyy/MM/dd HH:mm:ss"); modelInfo.ShowLastAnalysisTime = itemExpression.LastAnalysisTime == DateTime.MinValue ? string.Empty : itemExpression.LastAnalysisTime.ToString("yyyy/MM/dd HH:mm:ss"); modelInfo.AnalysisResultText = itemExpression.AnalysisResultText; modelInfo.ShowActualContinueTime = string.Format("{0}:{1}:{2}", (itemExpression.ActualContinueTime / 3600).ToString().PadLeft(2, '0'), (itemExpression.ActualContinueTime % 3600 / 60).ToString().PadLeft(2, '0'), (itemExpression.ActualContinueTime % 3600 % 60).ToString().PadLeft(2, '0')); itemGrid.ExpressionRealTimeResultList.Add(modelInfo); } } } else {//新增 List <ExpressionRealTimeResultInfo> expressionRealTimeResultList = new List <ExpressionRealTimeResultInfo>(); foreach (var itemExpression in item.ExpressionRealTimeResultList) { ExpressionRealTimeResultInfo modelInfo = new ExpressionRealTimeResultInfo(); modelInfo.ExpressionText = itemExpression.ExpressionText; modelInfo.ExpressionId = itemExpression.ExpressionId; modelInfo.ShowFirstSuccessfulTime = itemExpression.FirstSuccessfulTime == DateTime.MinValue ? string.Empty : itemExpression.FirstSuccessfulTime.ToString("yyyy/MM/dd HH:mm:ss"); modelInfo.ShowLastAnalysisTime = itemExpression.LastAnalysisTime == DateTime.MinValue ? string.Empty : itemExpression.LastAnalysisTime.ToString("yyyy/MM/dd HH:mm:ss"); modelInfo.AnalysisResultText = itemExpression.AnalysisResultText; modelInfo.ShowActualContinueTime = string.Format("{0}:{1}:{2}", (itemExpression.ActualContinueTime / 3600).ToString().PadLeft(2, '0'), (itemExpression.ActualContinueTime % 3600 / 60).ToString().PadLeft(2, '0'), (itemExpression.ActualContinueTime % 3600 % 60).ToString().PadLeft(2, '0')); expressionRealTimeResultList.Add(modelInfo); } itemGrid.ExpressionRealTimeResultList = expressionRealTimeResultList; } } #endregion } } if (isHaveModel == false) { JC_LargedataAnalysisConfigInfo model = new JC_LargedataAnalysisConfigInfo(); model.Id = item.Id; model.Name = item.Name; model.AnalysisTime = item.AnalysisTime; model.AnalysisResultText = item.AnalysisResultText; List <ExpressionRealTimeResultInfo> expressionRealTimeResultList = new List <ExpressionRealTimeResultInfo>(); if (item.ExpressionRealTimeResultList != null) { foreach (var itemExpression in item.ExpressionRealTimeResultList) { ExpressionRealTimeResultInfo modelInfo = new ExpressionRealTimeResultInfo(); modelInfo.ExpressionText = itemExpression.ExpressionText; modelInfo.ExpressionId = itemExpression.ExpressionId; modelInfo.ShowFirstSuccessfulTime = itemExpression.FirstSuccessfulTime == DateTime.MinValue ? string.Empty : itemExpression.FirstSuccessfulTime.ToString("yyyy/MM/dd HH:mm:ss"); modelInfo.ShowLastAnalysisTime = itemExpression.LastAnalysisTime == DateTime.MinValue ? string.Empty : itemExpression.LastAnalysisTime.ToString("yyyy/MM/dd HH:mm:ss"); modelInfo.AnalysisResultText = itemExpression.AnalysisResultText; modelInfo.ShowActualContinueTime = string.Format("{0}:{1}:{2}", (itemExpression.ActualContinueTime / 3600).ToString().PadLeft(2, '0'), (itemExpression.ActualContinueTime % 3600 / 60).ToString().PadLeft(2, '0'), (itemExpression.ActualContinueTime % 3600 % 60).ToString().PadLeft(2, '0')); expressionRealTimeResultList.Add(modelInfo); } } model.ExpressionRealTimeResultList = expressionRealTimeResultList; gridList.Add(model); } } MethodInvoker In = new MethodInvoker(() => { if (gridList != null) { int topRowIndex = gridView1.TopRowIndex; gridView1.RefreshData(); for (int i = 0; i < gridView1.RowCount; i++) { //默认展开所有子项 //gridView1.ExpandMasterRow(i); DevExpress.XtraGrid.Views.Base.BaseView childView = gridView1.GetVisibleDetailView(i); if (childView != null) { childView.RefreshData(); } } gridView1.TopRowIndex = topRowIndex; } }); if (gridControlData.InvokeRequired) { gridControlData.Invoke(In); } } } catch (Exception ex) { LogHelper.Error(ex.Message); } Thread.Sleep(4000); } }
/// <summary> /// GridHandler를 생성합니다. /// </summary> /// <param name="view"></param> /// <returns></returns> public override DevExpress.XtraGrid.Views.Base.Handler.BaseViewHandler CreateHandler(DevExpress.XtraGrid.Views.Base.BaseView view) { return(new PBandedGridHandler(view as PBandedGridView)); }
/// <summary> /// BandedGridView를 생성합니다. /// </summary> /// <param name="view"></param> /// <returns></returns> public override DevExpress.XtraGrid.Views.Base.ViewInfo.BaseViewInfo CreateViewInfo(DevExpress.XtraGrid.Views.Base.BaseView view) { return(new PBandedGridViewInfo(view as PBandedGridView)); }
public static void SaveToPAnalize(DevExpress.XtraGrid.Views.Base.BaseView _bv) { DataTable _savedt = null; Dialog_SelectPAnalize _f = new Dialog_SelectPAnalize(); _f.InitData(); if (_f.ShowDialog() == DialogResult.OK) { DataView _dv = _bv.DataSource as DataView; DataTable _dt = _dv.Table; string _tname = _f.TableDisplayName; List <MD_PATable_Column> columnDefine = new List <MD_PATable_Column>(); if (_bv is GridView) { MD_PATable_Column _col = null; GridView _gridview = _bv as GridView; foreach (GridColumn _gc in _gridview.Columns) { MDQuery_TableColumn _cdefine = _gc.Tag as MDQuery_TableColumn; DataColumn _dc = _dt.Columns[_gc.FieldName]; if (_cdefine == null) { _col = new MD_PATable_Column("", "", "", _gc.FieldName, _gc.Caption, CovertColumnType(_dc.DataType), _dc.MaxLength, _gc.VisibleIndex); } else { _col = new MD_PATable_Column("", "", "", _gc.FieldName, _gc.Caption, _cdefine.ColumnDataType, _cdefine.ColumnLength, _gc.VisibleIndex, _cdefine.RefDMB, _cdefine.DisplayFormat, _cdefine.RefWord); } columnDefine.Add(_col); } } //验证有无MAINID字段 //bool _findMainID = false; //foreach (MD_PATable_Column _col in columnDefine) //{ // if (_col.ColumnName == "MAINID") // { // _findMainID = true; // } //} //没有则添加 //if (!_findMainID) //{ // //} //代码表和字符串类型长度验证 foreach (MD_PATable_Column _col in columnDefine) { switch (_col.ColumnType) { case "VARCHAR2": case "NVARCHAR2": case "VARCHAR": case "NVARCHAR": case "CHAR": CheckLength(_col, _dt); break; default: if (_col.RefDMB == null || _col.RefDMB == "") { } else { //转换 CheckLength(_col, _dt); } break; } } #region 判断是否存在计算字段 bool _haveComputData = false; foreach (DataColumn _dc in _dt.Columns) { if (_dc.Expression.Length > 0) { _haveComputData = true; break; } } if (_haveComputData) { _savedt = new DataTable(); foreach (MD_PATable_Column _col in columnDefine) { switch (_col.ColumnType) { case "VARCHAR2": case "NVARCHAR2": case "VARCHAR": case "NVARCHAR": case "CHAR": _savedt.Columns.Add(_col.ColumnName, typeof(string)); break; default: if (_col.RefDMB.Length > 0) { //转换 _savedt.Columns.Add(_col.ColumnName, typeof(string)); } else { _savedt.Columns.Add(_col.ColumnName, _dt.Columns[_col.ColumnName].DataType); } break; } } foreach (DataRow _dr in _dt.Rows) { DataRow _newrow = _savedt.NewRow(); foreach (MD_PATable_Column _col in columnDefine) { _newrow[_col.ColumnName] = _dr[_col.ColumnName]; } _savedt.Rows.Add(_newrow); } } else { _savedt = _dt; } #endregion //所有数据都添加新主建 _savedt = _savedt.Copy(); columnDefine.Add(new MD_PATable_Column("", "", "", "PAMAINID", "主键", "VARCHAR2", 50, 0)); _savedt.Columns.Add("PAMAINID", typeof(string)); foreach (DataRow _dr in _savedt.Rows) { _dr["PAMAINID"] = Guid.NewGuid().ToString(); } _savedt.AcceptChanges(); //存入个人分析空间 //if (SinoSZQueryConfig.MetaDataFactroy.SaveDataToPAnalize(_f.CurrentProject, _f.TableDisplayName, columnDefine, _savedt)) //{ // XtraMessageBox.Show("保存成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // return; //} //else //{ // XtraMessageBox.Show("保存失败!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // return; //} } }
public MyWinExplorerViewHandler(DevExpress.XtraGrid.Views.Base.BaseView view) : base(view) { }
public UxRepositoryItemCheckEdit(DevExpress.XtraGrid.Views.Base.BaseView view) { EditValueChanged += (o, e) => view.PostEditor(); }