private void InitializeComponent() { WebDataGrid gridWebGridTemp = null; this.listGrid = this.GetWebGrid(); for (int i = 0; i < listGrid.Count; i++) { gridWebGridTemp = listGrid[i]; if (listGrid[i].ID == gridWebGridId) { this.gridWebGrid = listGrid[i]; } if (listGrid[i].ID == gridWebGrid2Id) { this.gridWebGrid2 = listGrid[i]; } if (listGrid[i].ID == gridWebGrid3Id) { this.gridWebGrid3 = listGrid[i]; } //this.gridWebGrid.ItemCommand += new ItemCommandEventHandler(gridWebGrid_ItemCommand); gridWebGridTemp.EnableDataViewState = true; gridWebGridTemp.EnableViewState = true; gridWebGridTemp.EnableAjax = false; gridWebGridTemp.StyleSetName = "Office2007Blue"; //this.gridWebGrid.BorderStyle = BorderStyle.Solid; gridWebGridTemp.AutoGenerateColumns = false; gridWebGridTemp.ClientEvents.Click = "Gird_ClientClick"; gridWebGridTemp.ClientEvents.Initialize = "Grid_Initialize"; gridWebGridTemp.Height = new Unit(300); } this.components = new System.ComponentModel.Container(); this.languageComponent1 = this.GetLanguageComponent(); if (this.languageComponent1 == null) { this.languageComponent1 = new ControlLibrary.Web.Language.LanguageComponent(this.components); this.languageComponent1.Language = "CHS"; //this.languageComponent1.LanguagePackageDir = "D:\\SQC2.0\\eMES\\Source\\bin"; //this.languageComponent1.RuntimePage = null; //this.languageComponent1.RuntimeUserControl = null; this.languageComponent1.UserControlName = ""; } this.Load += new System.EventHandler(this.Page_Load); }
protected override void OnInit(EventArgs e) { this.gridWebGridId = "gridUnSelected"; this.gridWebGrid2Id = "gridSelected"; base.OnInit(e); this.Load += new System.EventHandler(this.Page_Load); this.gridUnSelected = this.gridWebGrid; this.gridSelected = this.gridWebGrid2; if (this.gridSelected != null) { this.gridUnSelected.Behaviors.CreateBehavior <EditingCore>().EditingClientEvents.CellValueChanged = "CellValueChanged"; this.gridSelected.Behaviors.CreateBehavior <EditingCore>().EditingClientEvents.CellValueChanged = "CellValueChanged"; } }
protected void cmdGridExport_ServerClick(object sender, System.EventArgs e) { WebDataGrid grid = null; grid = this.gridHelper.Grid; for (int i = grid.Rows.Count - 1; i >= 0; i--) { GridRecord row = grid.Rows[i]; if (bool.Parse(row.Items.FindItemByKey(gridHelper.CheckColumnKey).ToString()) && string.Compare(row.Items.FindItemByKey("ImportResult").Value.ToString(), "导入成功", true) == 0) { grid.Rows.Remove(grid.Rows[i]); } } grid.Columns.Remove(grid.Columns[0]); }
public bool IsInExport = false; // Added by Icyer 2006/12/26 @ YHI 标识是否导出操作,如果是导出则不用计算总数 public WebQueryHelperNew( HtmlInputButton queryButton, HtmlInputButton exportButton, WebDataGrid grid, PagerSizeSelector selector, PagerToolBar toolBar, ControlLibrary.Web.Language.LanguageComponent languageComponent, DataTable source) { dtSource = source; //variable this.cmdQuery = queryButton; this.cmdGridExport = exportButton; this.gridWebGrid = grid; this.pagerSizeSelector = selector; this.pagerToolBar = toolBar; this.languageComponent1 = languageComponent; //export this.excelExporter = new BenQGuru.eMES.Web.Helper.ExcelExporter(); this.excelExporter.Page = this.gridWebGrid.Page; this.excelExporter.FormatExportRecordHandle = new FormatExportRecordDelegate(this.FormatExportRecord); this.excelExporter.LoadExportDataHandle = new LoadExportDataDelegate(this.LoadDataSource); this.excelExporter.LanguageComponent = this.languageComponent1; this.excelExporter.GetColumnHeaderTextHandle = new GetColumnHeaderTextDelegate(GetColumnHeaderText); //register event if (this.cmdQuery != null) { this.cmdQuery.ServerClick += new EventHandler(cmdQuery_ServerClick); } if (this.cmdGridExport != null) { this.cmdGridExport.ServerClick += new EventHandler(cmdGridExport_ServerClick); } //if (this.gridWebGrid != null) //{ // this.gridWebGrid.ClickCellButton += new ClickCellButtonEventHandler(gridWebGrid_ClickCellButton); //} if (this.pagerToolBar != null) { this.pagerToolBar.OnPagerToolBarClick += new EventHandler(this.PagerToolBar_OnPagerToolBarClick); } if (this.pagerSizeSelector != null) { this.pagerSizeSelector.OnPagerSizeChanged += new BenQGuru.eMES.Web.Helper.PagerSizeSelector.PagerSizeChangedHandle(pagerSizeSelector_OnPagerSizeChanged); } }
protected void cmdGridExport_ServerClick(object sender, System.EventArgs e) { WebDataGrid Grid2 = null; Grid2 = this.gridHelper.Grid; for (int i = Grid2.Rows.Count - 1; i >= 0; i--) { GridRecord row = Grid2.Rows[i]; if (bool.Parse(row.Items[0].ToString()) && row.Items.FindItemByKey("ImportResult").Value.ToString() == "导入成功") { Grid2.Rows.Remove(Grid2.Rows[i]); } } Grid2.Columns.Remove(Grid2.Columns[0]); }
private void InitializeComponent() { WebDataGrid gridWebGridTemp = null; this.listGrid = this.GetWebGrid(); for (int i = 0; i < listGrid.Count; i++) { gridWebGridTemp = listGrid[i]; if (listGrid[i].ID == "gridWebGrid") { this.gridWebGrid = listGrid[i]; } if (listGrid[i].ID == "gridWebGrid2") { this.gridWebGrid2 = listGrid[i]; } if (listGrid[i].ID == "gridWebGrid3") { this.gridWebGrid3 = listGrid[i]; } //this.gridWebGrid.ItemCommand += new ItemCommandEventHandler(gridWebGrid_ItemCommand); gridWebGridTemp.EnableDataViewState = true; gridWebGridTemp.EnableViewState = true; gridWebGridTemp.EnableAjax = false; //this.gridWebGrid.ClientEvents.Initialize = "grid_Initialize"; gridWebGridTemp.StyleSetName = "Office2007Blue"; //this.gridWebGrid.BorderStyle = BorderStyle.Solid; gridWebGridTemp.AutoGenerateColumns = false; gridWebGridTemp.ClientEvents.Click = "Gird_ClientClick"; //if (this.DtSource == null) // this.DtSource = new DataTable(); this.languageComponent = this.GetLanguageComponent(); this.components = new System.ComponentModel.Container(); this.excelExporter = new BenQGuru.eMES.Web.Helper.ExcelExporter(this.components); this.excelExporter.Page = this; this.excelExporter.LanguageComponent = this.languageComponent; } this.Load += new System.EventHandler(this.Page_Load); }
protected void cmdGridExport_ServerClick(object sender, System.EventArgs e) { WebDataGrid Grid2 = null; this.gridHelper = new GridHelperNew(this.gridWebGrid, this.DtSource); Grid2 = this.gridHelper.Grid; for (int i = Grid2.Rows.Count - 1; i >= 0; i--) { GridRecord row = Grid2.Rows[i]; if (bool.Parse(row.Items.FindItemByKey(this.gridHelper.CheckColumnKey).Value.ToString()) && row.Items.FindItemByKey("ImportResult").Value.ToString() == "导入成功") { Grid2.Rows.Remove(Grid2.Rows[i]); } } //Grid2.Columns.Remove(Grid2.Columns[0]); //this.WebGridExcelExporter1.Export(Grid2); //this.excelExporter.ExportNew(Grid2); this.GridExportExcColFir(Grid2); }
private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.languageComponent = new ControlLibrary.Web.Language.LanguageComponent(this.components); // // languageComponent // this.languageComponent.Language = "CHS"; this.languageComponent.LanguagePackageDir = "D:\\SQC2.0\\eMES\\Source\\bin"; this.languageComponent.RuntimePage = null; this.languageComponent.RuntimeUserControl = null; this.languageComponent.UserControlName = ""; this.Load += new System.EventHandler(this.Page_Load); WebDataGrid gridWebGridTemp = null; this.listGrid = this.GetWebGrid(); for (int i = 0; i < listGrid.Count; i++) { gridWebGridTemp = listGrid[i]; if (listGrid[i].ID == "gridUnSelected") { this.gridUnSelected = listGrid[i]; } if (listGrid[i].ID == "gridSelected") { this.gridSelected = listGrid[i]; } gridWebGridTemp.EnableDataViewState = true; gridWebGridTemp.EnableViewState = true; gridWebGridTemp.EnableAjax = false; gridWebGridTemp.StyleSetName = "Office2007Blue"; gridWebGridTemp.AutoGenerateColumns = false; this.languageComponent = this.GetLanguageComponent(); this.components = new System.ComponentModel.Container(); } this.Load += new System.EventHandler(this.Page_Load); }
/// <summary> /// Exports grid SummaryRow to the specified worksheet. /// /// </summary> protected virtual void ExportSummaries(WebDataGrid grid, Worksheet worksheet, ref int rowIndex, int columnOffset, int outlineLevel, bool hidden, string gridCssClass, int firstDataRowIndex) { SummaryRow behavior = grid.Behaviors.GetBehavior<SummaryRow>(); int index1 = rowIndex - (grid.ShowFooter ? 2 : 1); bool renderingResolved = behavior.EnableCompactRenderingResolved; int summaryNumberVisible = behavior.ColumnSummaries.GetMaxSummaryNumberVisible(); int maxSummaryRows = behavior.ColumnSummaries.GetMaxSummaryRows(); string str1 = string.Empty; if (this.EnableStylesExport) str1 = behavior.ResolveCssClass(behavior.SummariesCssClass, 0); for (int index2 = 0; index2 < maxSummaryRows; ++index2) { if ((index2 < summaryNumberVisible || !renderingResolved) && (renderingResolved || behavior.ColumnSummaries.IsVisibleRow(index2))) { WorksheetRow worksheetRow = worksheet.Rows[rowIndex]; worksheetRow.OutlineLevel = outlineLevel; worksheetRow.Hidden = hidden; int rowIndex1 = rowIndex; ExcelRowExportingEventArgs e1 = new ExcelRowExportingEventArgs(worksheet, worksheetRow, rowIndex1, columnOffset, outlineLevel, false, false, true); this.OnRowExporting(e1); if (!e1.Cancel) { int columnIndex = columnOffset; foreach (ControlDataField summaryCell in (IVisibleItemsEnumerable)grid.Fields) { if (!summaryCell.Hidden && !summaryCell.HiddenByParent) { WorksheetCell worksheetCell = worksheetRow.Cells[columnIndex]; Summary summaryByOrder = behavior.ColumnSummaries.GetSummaryByOrder(summaryCell.Key, index2); SummarySetting summarySetting = (SummarySetting)null; ExcelCellExportingEventArgs e2 = new ExcelCellExportingEventArgs(worksheet, worksheetCell, rowIndex, columnIndex, outlineLevel, false, false, true); e2.Summary = summaryByOrder; this.OnCellExporting(e2); if (e2.Cancel) { ++columnIndex; } else { SummaryCellExportingEventArgs e3 = new SummaryCellExportingEventArgs(summaryCell, worksheet, worksheetCell, rowIndex, columnIndex, outlineLevel, false, false, true); e3.Summary = summaryByOrder; this.OnSummaryCellExporting(e3); if (e3.Cancel) { ++columnIndex; } else { if (summaryByOrder == null) { worksheetCell.Value = (object)behavior.EmptyFooterText; } else { SummaryRowSetting sumRowSetting = behavior.ColumnSettings[summaryCell.Key]; summarySetting = sumRowSetting != null ? (summaryByOrder.SummaryType == SummaryType.Custom ? sumRowSetting.SummarySettings.CustomSummaryByName(summaryByOrder.CustomSummaryName) : sumRowSetting.SummarySettings[summaryByOrder.SummaryType]) : (SummarySetting)null; string format1 = summarySetting == null ? (sumRowSetting == null ? behavior.FormatString : sumRowSetting.FormatString) : summarySetting.FormatString; if (summaryByOrder.SummaryType == SummaryType.Custom) worksheetCell.Value = (object)string.Format(format1, (object)summaryByOrder.CustomSummaryName, summaryByOrder.Value); else if (summaryByOrder.SummaryType == SummaryType.Custom) { worksheetCell.Value = (object)string.Format(format1, (object)summaryByOrder.CustomSummaryName, summaryByOrder.Value); } else { List<string> list = (List<string>)null; string str2 = string.Empty; string str3; if (grid is ContainerGrid && ((ContainerGrid)grid).HasChildGrids()) { list = new List<string>(); for (int index3 = firstDataRowIndex; index3 <= index1; ++index3) { if (worksheet.Rows[index3].OutlineLevel == outlineLevel) list.Add(worksheet.Rows[index3].Cells[columnIndex].ToString(CellReferenceMode.A1, false, true, true)); } str3 = string.Join(",", list.ToArray()); } else str3 = string.Format("{0}:{1}", (object)worksheet.Rows[firstDataRowIndex].Cells[columnIndex].ToString(CellReferenceMode.A1, false, true, true), (object)worksheet.Rows[index1].Cells[columnIndex].ToString(CellReferenceMode.A1, false, true, true)); int num1 = format1.IndexOf("{1"); string format2; if (num1 > -1) { string str4 = "\"" + format1.Substring(0, num1) + "\" & "; string str5 = format1.Substring(num1); int num2 = str5.IndexOf("}"); string str6 = str5.Insert(num2 + 1, " & \"") + "\""; format2 = "=" + str4 + str6; } else format2 = "=\"" + format1 + "\""; string format3 = string.Format(format2, (object)"{0}", (object)"{1}({3})").Replace("\"\" &", "").Replace("& \"\"", ""); if (summaryByOrder.SummaryType == SummaryType.Count && format3.Contains("{1")) format3 = format3.Replace("{1}({3})", "{1}({3}) + {2}({3})"); string[] strArray = this.GetExcelFunctionName(summaryByOrder.SummaryType).Split(new char[1] { '|' }, StringSplitOptions.RemoveEmptyEntries); string str7 = strArray.Length > 1 ? strArray[1] : ""; string str8 = string.Format(format3, (object)behavior.GetCultureInvariantSummaryString(summaryByOrder.SummaryType, summaryByOrder.CustomSummaryName), (object)strArray[0], (object)str7, (object)str3); if (list != null && (list.Count > 30 || summaryByOrder.SummaryType == SummaryType.Count)) worksheetCell.Value = (object)behavior.GetSummaryValue((GridField)summaryCell, summaryByOrder, behavior.ColumnSummaries[summaryCell.Key], sumRowSetting, false); else worksheetCell.ApplyFormula(str8); } } if (this.EnableStylesExport) { string classes = str1; if (summarySetting != null && !string.IsNullOrEmpty(summarySetting.CssClass)) classes = classes + " " + summarySetting.CssClass; if (summaryByOrder != null && !string.IsNullOrEmpty(summaryByOrder.CssClass)) classes = classes + " " + summaryByOrder.CssClass; CssSelector selector1 = new CssSelector(); selector1.AddClasses(string.Format("{0} {1}", (object)gridCssClass, (object)classes)); CssStyle styleObject1 = this._currentStyleSheet.GetStyleObject(selector1); this.ApplyCellFormatFromStyle(worksheetCell.Worksheet.Workbook, worksheetCell.CellFormat, styleObject1, grid); CssSelector selector2 = new CssSelector(); selector2.AddClasses(classes); CssStyle styleObject2 = this._currentStyleSheet.GetStyleObject(selector2); this.ApplyCellBorderFromStyle(worksheetCell.CellFormat, styleObject2); } SummaryCellExportedEventArgs e4 = new SummaryCellExportedEventArgs(summaryCell, worksheet, worksheetCell, rowIndex1, columnIndex, outlineLevel, false, false, true); e4.Summary = summaryByOrder; this.OnSummaryCellExported(e4); ExcelCellExportedEventArgs e5 = new ExcelCellExportedEventArgs(worksheet, worksheetCell, rowIndex1, columnIndex, outlineLevel, false, false, true); e5.Summary = summaryByOrder; this.OnCellExported(e5); ++columnIndex; } } } } ++rowIndex; this.OnRowExported(new ExcelRowExportedEventArgs(worksheet, worksheetRow, rowIndex1, columnOffset, outlineLevel, false, false, true)); } } } }
private void Display() { lblRetrievalNo.Text = manageStationeryRetrievalListControl.RetrievalId; retrievalList = manageStationeryRetrievalListControl.RetrievalList; int index = 0; int group = 0; int fulfillPage = SystemStoreInventorySystemUtil.Converter.objToInt(StationeryStoreInventorySystemController.Util.GetSession(fulfillPageSessionKey)); int startingShowIndex = fulfillPage > 1 ? fulfillPage * ManageStationeryRetrievalListControl.totalRetrievalToSet : 0; foreach (string key in retrievalList.Keys) { if (index++ >= startingShowIndex && group < ManageStationeryRetrievalListControl.totalRetrievalToSet) { WebGroupBox webGroupBox = (WebGroupBox)this.FindControl("ctl00$MainContent$FulfillWebGroupBox" + (++group)); if (webGroupBox != null) { Label lblBin = (Label)this.FindControl("ctl00$MainContent$FulfillWebGroupBox" + group + "$lblFulfillBin" + group); Label lblNeededQty = (Label)this.FindControl("ctl00$MainContent$FulfillWebGroupBox" + group + "$lblFulfillNeededQty" + group); Label lblActualQty = (Label)this.FindControl("ctl00$MainContent$FulfillWebGroupBox" + group + "$lblFulfillActualQty" + group); WebDataGrid webDataGrid = (WebDataGrid)this.FindControl("ctl00$MainContent$FulfillWebGroupBox" + group + "$FulfillWebDataGrid" + group); if (lblBin != null && lblNeededQty != null && lblActualQty != null && webDataGrid != null) { webGroupBox.Visible = true; webDataGrid.Visible = true; DataTable dt = (DataTable)retrievalList[key][COLUMN_TABLE]; webGroupBox.Text = retrievalList[key][COLUMN_DESCRIPTION].ToString(); lblBin.Text = retrievalList[key][COLUMN_BIN].ToString(); lblNeededQty.Text = retrievalList[key][COLUMN_NEEDED_QTY].ToString(); lblActualQty.Text = retrievalList[key][COLUMN_ACTUAL_QTY].ToString(); webDataGrid.DataSource = dt; webDataGrid.DataBind(); } } } } if (retrievalList.Count() > ManageStationeryRetrievalListControl.totalRetrievalToSet) { HyperLink fulfilledLink; for (int i = 0; i < SystemStoreInventorySystemUtil.Converter.objToInt(Math.Ceiling((double)(retrievalList.Count() / ManageStationeryRetrievalListControl.totalRetrievalToSet))); i++) { fulfilledLink = new HyperLink(); fulfilledLink.Attributes["style"] = "padding-left: 5px;"; if (i != fulfillPage - 1) { fulfilledLink.NavigateUrl = "~/storeUI/Clerk/ManageStationeryRetrievalList.aspx?fulfilledpage=" + (i + 1); } fulfilledLink.Text = (i + 1).ToString(); FulfilledPaginating.Controls.Add(fulfilledLink); } } if (retrievalList.Count() == 0) { fulfilledPanel.Visible = false; } index = 0; group = 0; int unfulfillPage = SystemStoreInventorySystemUtil.Converter.objToInt(StationeryStoreInventorySystemController.Util.GetSession(unfulfillPageSessionKey)); startingShowIndex = unfulfillPage > 1 ? unfulfillPage * ManageStationeryRetrievalListControl.totalRetrievalToSet : 0; unfulfilledRetrievalList = manageStationeryRetrievalListControl.UnfulfilledRetrievalList; foreach (string key in unfulfilledRetrievalList.Keys) { if (index++ >= startingShowIndex && group < ManageStationeryRetrievalListControl.totalRetrievalToSet) { WebGroupBox webGroupBox = (WebGroupBox)this.FindControl("ctl00$MainContent$WebGroupBox" + (++group)); if (webGroupBox != null) { Label lblBin = (Label)this.FindControl("ctl00$MainContent$WebGroupBox" + group + "$lblBin" + group); Label lblNeededQty = (Label)this.FindControl("ctl00$MainContent$WebGroupBox" + group + "$lblNeededQty" + group); Label lblActualQty = (Label)this.FindControl("ctl00$MainContent$WebGroupBox" + group + "$lblActualQty" + group); WebDataGrid webDataGrid = (WebDataGrid)this.FindControl("ctl00$MainContent$WebGroupBox" + group + "$DgvManageStationeryRetrievalList" + group); if (lblBin != null && lblNeededQty != null && lblActualQty != null && webDataGrid != null) { webGroupBox.Visible = true; webDataGrid.Visible = true; DataTable dt = (DataTable)unfulfilledRetrievalList[key][COLUMN_TABLE]; webGroupBox.Text = unfulfilledRetrievalList[key][COLUMN_DESCRIPTION].ToString(); lblBin.Text = unfulfilledRetrievalList[key][COLUMN_BIN].ToString(); lblNeededQty.Text = unfulfilledRetrievalList[key][COLUMN_NEEDED_QTY].ToString(); lblActualQty.Text = unfulfilledRetrievalList[key][COLUMN_ACTUAL_QTY].ToString(); webDataGrid.DataSource = dt; webDataGrid.DataBind(); } } } } if (unfulfilledRetrievalList.Count() > ManageStationeryRetrievalListControl.totalRetrievalToSet) { HyperLink unfulfilledLink; for (int i = 0; i < SystemStoreInventorySystemUtil.Converter.objToInt(Math.Ceiling((double)(unfulfilledRetrievalList.Count() / ManageStationeryRetrievalListControl.totalRetrievalToSet))); i++) { unfulfilledLink = new HyperLink(); unfulfilledLink.Attributes["style"] = "padding-left: 5px;"; if (i != unfulfillPage - 1) { unfulfilledLink.NavigateUrl = "~/storeUI/Clerk/ManageStationeryRetrievalList.aspx?unfulfilledpage=" + (i + 1); } unfulfilledLink.Text = (i + 1).ToString(); UnfulfilledPaginating.Controls.Add(unfulfilledLink); } } if (unfulfilledRetrievalList.Count() == 0) { unfulfilledPanel.Visible = false; } }
protected void btnSubmit_Click(object sender, EventArgs e) { retrievalList = manageStationeryRetrievalListControl.RetrievalList; unfulfilledRetrievalList = manageStationeryRetrievalListControl.UnfulfilledRetrievalList; int index = 0; int group = 0; int fulfillPage = SystemStoreInventorySystemUtil.Converter.objToInt(StationeryStoreInventorySystemController.Util.GetSession(fulfillPageSessionKey)); int startingShowIndex = fulfillPage > 1 ? fulfillPage * ManageStationeryRetrievalListControl.totalRetrievalToSet : 0; foreach (string key in retrievalList.Keys) { if (index++ >= startingShowIndex && group < ManageStationeryRetrievalListControl.totalRetrievalToSet) { WebGroupBox webGroupBox = (WebGroupBox)this.FindControl("ctl00$MainContent$FulfillWebGroupBox" + (++group)); if (webGroupBox != null) { WebDataGrid webDataGrid = (WebDataGrid)this.FindControl("ctl00$MainContent$FulfillWebGroupBox" + group + "$FulfillWebDataGrid" + group); DataTable dt = (DataTable)retrievalList[key][COLUMN_TABLE]; for (int i = 0; i < webDataGrid.Rows.Count; i++) { if (SystemStoreInventorySystemUtil.Converter.objToInt(((Infragistics.Web.UI.EditorControls.WebTextEditor)webDataGrid.Rows[i].Items.FindItemByKey("ActualQty").FindControl("ActualQty")).Text) <= SystemStoreInventorySystemUtil.Converter.objToInt(dt.Rows[i][1])) { dt.Rows[i][2] = ((Infragistics.Web.UI.EditorControls.WebTextEditor)webDataGrid.Rows[i].Items.FindItemByKey("ActualQty").FindControl("ActualQty")).Text; } else { dt.Rows[i][2] = dt.Rows[i][1]; } } } } } index = 0; group = 0; int unfulfillPage = SystemStoreInventorySystemUtil.Converter.objToInt(StationeryStoreInventorySystemController.Util.GetSession(unfulfillPageSessionKey)); startingShowIndex = unfulfillPage > 1 ? unfulfillPage * ManageStationeryRetrievalListControl.totalRetrievalToSet : 0; foreach (string key in unfulfilledRetrievalList.Keys) { if (index++ >= startingShowIndex && group < ManageStationeryRetrievalListControl.totalRetrievalToSet) { WebGroupBox webGroupBox = (WebGroupBox)this.FindControl("ctl00$MainContent$WebGroupBox" + (++group)); if (webGroupBox != null) { WebDataGrid webDataGrid = (WebDataGrid)this.FindControl("ctl00$MainContent$WebGroupBox" + group + "$DgvManageStationeryRetrievalList" + group); //manageStationeryRetrievalListControl.SelectSave(((WebGroupBox)this.FindControl("ctl00$MainContent$WebGroupBox" + group)).Text, (DataTable)webDataGrid.DataSource); DataTable dt = (DataTable)unfulfilledRetrievalList[key][COLUMN_TABLE]; for (int i = 0; i < webDataGrid.Rows.Count; i++) { dt.Rows[i][2] = ((Infragistics.Web.UI.EditorControls.WebTextEditor)webDataGrid.Rows[i].Items.FindItemByKey("ActualQty").FindControl("ActualQty")).Text; } } } } manageStationeryRetrievalListControl.SelectSave(); }
/// <summary> /// Exports a single flat grid. /// /// </summary> public override void Export(WebDataGrid grid) { Workbook workbook = new Workbook(this.WorkbookFormat); this.Export(grid, workbook); }
/// <summary> /// Exports a single flat grid to the specified workbook. /// /// </summary> public virtual void Export(WebDataGrid grid, Workbook workbook) { Worksheet worksheet = workbook.Worksheets.Add("WorkSheet1"); this.Export(grid, worksheet); }
public async Task Export(CalculateRequest calculateRequest) { this.calculateRequest = calculateRequest; //InitOldData(); var grid1 = new WebDataGrid { //DataSource = this.chartService.GetJahresbetrachtungProzentual(IntervalType.M36) DataSource = (await meteoGtzService.GetYearsDataRelativeToCurrentYear(calculateRequest, true)).ToDataTable(p => p.Period1) }; grid1.DataBind(); var grid2 = new WebDataGrid { //DataSource = ChartService.CalculateSum(this.chartService.GetMonatsRelativeVerteilungJahr(false)) DataSource = (await meteoGtzService.GetRelativeVerteilung(calculateRequest, false)).ToDataTable().CalculateSum() }; grid2.DataBind(); var grid3 = new WebDataGrid { //DataSource = ChartService.CalculateSum(this.chartService.MonatsSummenGtzJahr) DataSource = (await meteoGtzService.GetGtzByPeriods(calculateRequest)).ToDataTable().CalculateSum() }; grid3.DataBind(); var wb = new Workbook(); var font = wb.Styles.NormalStyle.StyleFormat.Font; font.Name = "Microsoft Sans Serif"; font.Height = 9 * 20; var ws = wb.Worksheets.Add("Daten"); ws.Rows[3].Cells[0].Value = Title1; ws.Rows[3].Cells[0].CellFormat.Font.Bold = ExcelDefaultableBoolean.True; ws.Rows[12].Cells[0].Value = Title2; ws.Rows[12].Cells[0].CellFormat.Font.Bold = ExcelDefaultableBoolean.True; ws.Rows[29].Cells[0].Value = "Monatssummen der GTZ im Vergleich"; ws.Rows[29].Cells[0].CellFormat.Font.Bold = ExcelDefaultableBoolean.True; ws.Rows[8].Cells[0].Value = "Heizbedarf für das Abrechnungsjahr"; ws.Rows[8].Cells[0].CellFormat.Font.Bold = ExcelDefaultableBoolean.True; //ws.Rows[9].Cells[0].Value = this.chartService.GetJahrBedarfWithPromille(); ws.Rows[9].Cells[0].Value = await meteoGtzService.GetJahrBedarfWithPromille(calculateRequest, true); var wdge1 = new WebDataGridExport { Grid = grid1, RowOffset = 4 }; var wdge2 = new WebDataGridExport { Grid = grid2, RowOffset = 13 }; var wdge3 = new WebDataGridExport { Grid = grid3, RowOffset = 30 }; RegionFormat(ws.GetRegion("A5:C5"), true); RegionFormat(ws.GetRegion("A14:F14"), true); RegionFormat(ws.GetRegion("A27:F27")); RegionFormat(ws.GetRegion("A28:F28")); RegionFormatBold(ws.GetRegion("A27:A28")); RegionFormat(ws.GetRegion("A31:F31"), true); RegionFormat(ws.GetRegion("A44:F44")); RegionFormat(ws.GetRegion("A45:F45")); RegionFormatBold(ws.GetRegion("A44:A45")); RegionFormatBold(ws.GetRegion("A27:A28")); webExcelExporter.Export(ws, wdge1, wdge2, wdge3); }
/// <summary> /// Exports a single flat grid to the specified worksheet. /// Exporting starts from the defined row and column offsets. /// /// </summary> public virtual void Export(WebDataGrid grid, Worksheet worksheet, int rowOffset, int columnOffset) { this._currentWorkbookFormat = worksheet.Workbook.CurrentFormat; ExcelExportingEventArgs e = new ExcelExportingEventArgs(worksheet, rowOffset, columnOffset, 0); this.OnExporting(e); if (e.Cancel) return; rowOffset = e.CurrentRowIndex; this.InitStyleSheet(grid.RunBot); this.ExportGrid(grid, worksheet, ref rowOffset, columnOffset, 0); this._currentStyleSheet = (StyleSheet)null; this.OnExported(new ExcelExportedEventArgs(worksheet, rowOffset, columnOffset, 0)); this.DownloadWorkbook(worksheet.Workbook); }
/// <summary> /// Exports a single flat grid to the specified worksheet. /// /// </summary> public virtual void Export(WebDataGrid grid, Worksheet worksheet) { this.Export(grid, worksheet, 0, 0); }
private IWorksheetCellFormat ApplyCellFormatFromStyle(Workbook workbook, IWorksheetCellFormat cellFormat, CssStyle cssStyle, WebDataGrid grid) { if (Color.Empty != cssStyle.Background.Color && cssStyle.Background.Color.ToArgb() != Color.White.ToArgb()) { cellFormat.FillPatternForegroundColor = cssStyle.Background.Color; cellFormat.FillPattern = FillPatternStyle.Solid; } IWorkbookFont newWorkbookFont = workbook.CreateNewWorkbookFont(); newWorkbookFont.Color = grid.ForeColor.IsEmpty ? cssStyle.Color : grid.ForeColor; newWorkbookFont.Name = string.IsNullOrEmpty(grid.Font.Name) ? cssStyle.Font.FamilyName : grid.Font.Name; switch (cssStyle.Font.SizeEnum) { case Infragistics.Documents.Reports.FontSize.NotSet: newWorkbookFont.Height = cssStyle.Font.SizeUnit.Type != UnitType.Point || cssStyle.Font.SizeUnit.Value < 1.0 ? (cssStyle.Font.SizeUnit.Type != UnitType.Pixel || cssStyle.Font.SizeUnit.Value < 1.0 ? 240 : (int)(cssStyle.Font.SizeUnit.Value * 20.0)) : (int)(cssStyle.Font.SizeUnit.Value * 20.0); break; case Infragistics.Documents.Reports.FontSize.Large: case Infragistics.Documents.Reports.FontSize.Larger: newWorkbookFont.Height = 280; break; case Infragistics.Documents.Reports.FontSize.Small: case Infragistics.Documents.Reports.FontSize.Smaller: newWorkbookFont.Height = 200; break; case Infragistics.Documents.Reports.FontSize.X_Large: newWorkbookFont.Height = 360; break; case Infragistics.Documents.Reports.FontSize.X_Small: newWorkbookFont.Height = 180; break; case Infragistics.Documents.Reports.FontSize.XX_Large: newWorkbookFont.Height = 480; break; case Infragistics.Documents.Reports.FontSize.XX_Small: newWorkbookFont.Height = 160; break; default: newWorkbookFont.Height = 240; break; } if (cssStyle.Font.IsBold || cssStyle.Font.Style == Infragistics.Documents.Reports.FontStyle.Oblique || grid.Font.Bold) newWorkbookFont.Bold = ExcelDefaultableBoolean.True; if (cssStyle.Font.IsItalic || cssStyle.Font.Style == Infragistics.Documents.Reports.FontStyle.Italic || grid.Font.Italic) newWorkbookFont.Italic = ExcelDefaultableBoolean.True; if (cssStyle.TextDecoration == TextDecoration.Line_Through || grid.Font.Strikeout) newWorkbookFont.Strikeout = ExcelDefaultableBoolean.True; if (cssStyle.TextDecoration == TextDecoration.Underline || grid.Font.Underline) newWorkbookFont.UnderlineStyle = FontUnderlineStyle.Single; cellFormat.Font.SetFontFormatting(newWorkbookFont); switch (cssStyle.TextAlign) { case Infragistics.Documents.Reports.TextAlign.Center: cellFormat.Alignment = HorizontalCellAlignment.Center; break; case Infragistics.Documents.Reports.TextAlign.Justify: cellFormat.Alignment = HorizontalCellAlignment.Justify; break; case Infragistics.Documents.Reports.TextAlign.Left: cellFormat.Alignment = HorizontalCellAlignment.Left; break; case Infragistics.Documents.Reports.TextAlign.Right: cellFormat.Alignment = HorizontalCellAlignment.Right; break; default: cellFormat.Alignment = HorizontalCellAlignment.General; break; } switch (cssStyle.VerticalAlign) { case Infragistics.Documents.Reports.VerticalAlign.Bottom: cellFormat.VerticalAlignment = VerticalCellAlignment.Bottom; break; case Infragistics.Documents.Reports.VerticalAlign.Middle: cellFormat.VerticalAlignment = VerticalCellAlignment.Center; break; case Infragistics.Documents.Reports.VerticalAlign.Top: cellFormat.VerticalAlignment = VerticalCellAlignment.Top; break; default: cellFormat.VerticalAlignment = VerticalCellAlignment.Default; break; } return cellFormat; }
public GridHelperNew(WebDataGrid grid, DataTable dt) { this._grid = grid; this.dtSource = dt; this.InitGridHelper(); }
//GridHelperNew构造函数 add by jinger 20160224 /// <summary> /// ** 名称:GridHelperNew构造函数 /// ** 作用:解决一个页面出现多个grid和分页状态栏后的关联问题 /// </summary> /// <param name="grid">页面Grid</param> /// <param name="dt">table</param> /// <param name="pagerToolBarID">分页控件ID</param> /// <param name="pagerSizeSelectorID">页数控件ID</param> public GridHelperNew(WebDataGrid grid, DataTable dt, string pagerToolBarID, string pagerSizeSelectorID) { this._grid = grid; this.dtSource = dt; this.InitPager(pagerToolBarID, pagerSizeSelectorID); }
/// <summary> /// Exports a grid field caption (header or footer) to the specified worksheet cell. /// /// </summary> protected virtual void ExportGridFieldCaption(WebDataGrid grid, GridFieldCaption caption, WorksheetRow wsRow, WorksheetCell wsCell, int rowIndex, int columnIndex, string gridCssClass, string captionRowCssClass, bool isHeader, int rowSpan, int colSpan, int colOffset) { WorksheetMergedCellsRegion mergedCellsRegion = rowSpan > 1 || colSpan > 1 ? wsRow.Worksheet.MergedCellsRegions.Add(rowIndex, columnIndex + colOffset, rowIndex + rowSpan - 1, columnIndex + colOffset + colSpan - 1) : (WorksheetMergedCellsRegion)null; ExcelCellExportingEventArgs e1 = new ExcelCellExportingEventArgs(wsRow.Worksheet, wsCell, rowIndex, columnIndex, wsRow.OutlineLevel, isHeader, !isHeader, false); this.OnCellExporting(e1); if (e1.Cancel) return; GridFieldCaptionExportingEventArgs e2 = new GridFieldCaptionExportingEventArgs(caption, wsRow.Worksheet, wsCell, rowIndex, columnIndex, wsRow.OutlineLevel, isHeader, !isHeader, false); this.OnGridFieldCaptionExporting(e2); if (e2.Cancel) return; if (mergedCellsRegion != null) mergedCellsRegion.Value = (object)caption.Text; else wsCell.Value = (object)caption.Text; if (this.EnableStylesExport) { string styleClassString = grid.RunBot.StyleBot.GetStyleClassString((int)caption.Role, caption.CssClassResolved); if (caption.OwnerField is GroupField && caption.Role == WebDataGridRoles.HeaderCaption) styleClassString = grid.RunBot.StyleBot.GetStyleClassString(10, styleClassString); CssSelector selector1 = new CssSelector(); selector1.AddClasses(string.Format("{0} {1} {2}", (object)gridCssClass, (object)captionRowCssClass, (object)styleClassString)); CssStyle styleObject1 = this._currentStyleSheet.GetStyleObject(selector1); this.ApplyCellFormatFromStyle(wsCell.Worksheet.Workbook, wsCell.CellFormat, styleObject1, grid); if (mergedCellsRegion != null) this.ApplyCellFormatFromStyle(mergedCellsRegion.Worksheet.Workbook, mergedCellsRegion.CellFormat, styleObject1, grid); CssSelector selector2 = new CssSelector(); selector2.AddClasses(styleClassString); CssStyle styleObject2 = this._currentStyleSheet.GetStyleObject(selector2); this.ApplyCellBorderFromStyle(wsCell.CellFormat, styleObject2); if (mergedCellsRegion != null) this.ApplyCellBorderFromStyle(mergedCellsRegion.CellFormat, styleObject2); } if (wsCell.Value != null) { this.SetColumnWidth(wsCell.Worksheet.Columns[wsCell.ColumnIndex], wsCell); if (wsCell.Value.ToString().Contains(Environment.NewLine)) wsCell.CellFormat.WrapText = ExcelDefaultableBoolean.True; } if (mergedCellsRegion != null && mergedCellsRegion.Value != null && mergedCellsRegion.Value.ToString().Contains(Environment.NewLine)) mergedCellsRegion.CellFormat.WrapText = ExcelDefaultableBoolean.True; this.OnGridFieldCaptionExported(new GridFieldCaptionExportedEventArgs(caption, wsRow.Worksheet, wsCell, rowIndex, columnIndex, wsRow.OutlineLevel, isHeader, !isHeader, false)); this.OnCellExported(new ExcelCellExportedEventArgs(wsRow.Worksheet, wsCell, rowIndex, columnIndex, wsRow.OutlineLevel, isHeader, !isHeader, false)); }
/// <summary> /// Exports a single flat grid to the specified worksheet. /// Exporting starts from the defined rowIndex and columnOffset. /// The rowIndex is updated to point after the last exported row. /// /// </summary> protected virtual void ExportGrid(WebDataGrid grid, Worksheet worksheet, ref int rowIndex, int columnOffset, int outlineLevel) { bool hidden = grid is ContainerGrid && !this.IsGridVisible((ContainerGrid)grid); bool hasHiddenCols = false; foreach (GridField gridField in (CollectionBase)grid.Fields) { if (gridField.Hidden || gridField.HiddenByParent) { hasHiddenCols = true; break; } } string styleClassString1 = grid.RunBot.StyleBot.GetStyleClassString(0, grid.ControlStyle.CssClass); string styleClassString2 = grid.RunBot.StyleBot.GetStyleClassString(5, grid.ItemCssClass); string styleClassString3 = grid.RunBot.StyleBot.GetStyleClassString(6, grid.AltItemCssClass); if (grid.ShowHeader) { WorksheetRow worksheetRow1 = worksheet.Rows[rowIndex]; worksheetRow1.OutlineLevel = outlineLevel; worksheetRow1.Hidden = hidden; ExcelRowExportingEventArgs exportingEventArgs = new ExcelRowExportingEventArgs(worksheet, worksheetRow1, rowIndex, columnOffset, outlineLevel, true, false, false); string styleClassString4 = grid.RunBot.StyleBot.GetStyleClassString(1); if (grid.Fields.Count == 0) grid.EnsureDataBoundInternal(); int columnIndex1 = 0; if (grid.HasHeaderLayout) { for (int index = 0; index < grid.HeaderLayout.Count; ++index) { int columnIndex2 = 0; WorksheetRow worksheetRow2 = worksheet.Rows[rowIndex]; worksheetRow2.OutlineLevel = outlineLevel; worksheetRow2.Hidden = hidden; ExcelRowExportingEventArgs e = new ExcelRowExportingEventArgs(worksheet, worksheetRow2, rowIndex, columnOffset, outlineLevel, true, false, false); this.OnRowExporting(e); if (!e.Cancel) { foreach (ControlDataField controlDataField in (IVisibleItemsEnumerable)grid.HeaderLayout[index]) { if (!controlDataField.Hidden && !controlDataField.HiddenByParent && (!(controlDataField is GroupField) || !((GroupField)controlDataField).HiddenByChildren)) { GridFieldCaption caption = controlDataField.HeaderCaption as GridFieldCaption; WorksheetCell wsCell = worksheetRow2.Cells[columnOffset + columnIndex2]; int rowSpan = controlDataField.RowSpanInternal == 0 ? 1 : controlDataField.RowSpanInternal; int colSpan = controlDataField is GroupField ? (controlDataField as GroupField).ColSapn : 1; for (; wsCell.AssociatedMergedCellsRegion != null; wsCell = worksheetRow2.Cells[wsCell.AssociatedMergedCellsRegion.LastColumn + 1]) columnIndex2 = wsCell.AssociatedMergedCellsRegion.LastColumn + 1 - columnOffset; this.ExportGridFieldCaption(grid, caption, worksheetRow2, wsCell, rowIndex, columnIndex2, styleClassString1, styleClassString4, true, rowSpan, colSpan, columnOffset); columnIndex2 += colSpan; } } this.OnRowExported(new ExcelRowExportedEventArgs(worksheet, worksheetRow2, rowIndex, columnOffset, outlineLevel, true, false, false)); ++rowIndex; } } } else { ExcelRowExportingEventArgs e = new ExcelRowExportingEventArgs(worksheet, worksheetRow1, rowIndex, columnOffset, outlineLevel, true, false, false); this.OnRowExporting(e); if (e.Cancel) return; foreach (ControlDataField controlDataField in (IVisibleItemsEnumerable)grid.Fields) { if (!controlDataField.Hidden) { GridFieldCaption caption = controlDataField.HeaderCaption as GridFieldCaption; WorksheetCell wsCell = worksheetRow1.Cells[columnOffset + columnIndex1]; this.ExportGridFieldCaption(grid, caption, worksheetRow1, wsCell, rowIndex, columnIndex1, styleClassString1, styleClassString4, true, 0, 0, columnOffset); ++columnIndex1; } } this.OnRowExported(new ExcelRowExportedEventArgs(worksheet, worksheetRow1, rowIndex, columnOffset, outlineLevel, true, false, false)); ++rowIndex; } } bool flag1 = false; bool flag2 = false; VirtualScrolling behavior1 = grid.Behaviors.GetBehavior<VirtualScrolling>(); Paging behavior2 = grid.Behaviors.GetBehavior<Paging>(); if (this.DataExportMode == DataExportMode.AllDataInDataSource) { if (behavior1 != null && behavior1.Enabled) { behavior1.Enabled = false; flag1 = true; } if (behavior2 != null && behavior2.Enabled) { behavior2.Enabled = false; flag2 = true; } } int firstDataRowIndex = rowIndex; if (grid is ContainerGrid && ((ContainerGrid)grid).HasGroupedRows && ((ContainerGrid)grid).GroupedRows.Count > 0) { this.ExportGroupedRows(((ContainerGrid)grid).GroupedRows, worksheet, ref rowIndex, columnOffset, hasHiddenCols, outlineLevel, hidden); } else { foreach (GridRecord gridRecord in (ControlDataRecordCollection)grid.Rows) { string itemCssClass = styleClassString2; if (gridRecord.Index % 2 == 1) itemCssClass = itemCssClass + " " + styleClassString3; if (!string.IsNullOrEmpty(gridRecord.CssClass)) itemCssClass = itemCssClass + " " + gridRecord.CssClass; this.ExportRow(gridRecord, worksheet, ref rowIndex, columnOffset, hasHiddenCols, outlineLevel, hidden, styleClassString1, itemCssClass); } } if (flag1) behavior1.Enabled = true; if (flag2) behavior2.Enabled = true; if (grid.ShowFooter) { WorksheetRow worksheetRow = worksheet.Rows[rowIndex]; worksheetRow.OutlineLevel = outlineLevel; worksheetRow.Hidden = hidden; ExcelRowExportingEventArgs e = new ExcelRowExportingEventArgs(worksheet, worksheetRow, rowIndex, columnOffset, outlineLevel, false, true, false); this.OnRowExporting(e); if (e.Cancel) return; string styleClassString4 = grid.RunBot.StyleBot.GetStyleClassString(3); int columnIndex = 0; foreach (ControlDataField controlDataField in (IVisibleItemsEnumerable)grid.Fields) { if (!controlDataField.Hidden && !controlDataField.HiddenByParent && (!(controlDataField is GroupField) || !((GroupField)controlDataField).HiddenByChildren)) { GridFieldFooterCaption fieldFooterCaption = controlDataField.FooterCaption as GridFieldFooterCaption; WorksheetCell wsCell = worksheetRow.Cells[columnOffset + columnIndex]; int colSpanResolved = fieldFooterCaption.ColSpanResolved; if (wsCell.AssociatedMergedCellsRegion == null) this.ExportGridFieldCaption(grid, (GridFieldCaption)fieldFooterCaption, worksheetRow, wsCell, rowIndex, columnIndex, styleClassString1, styleClassString4, false, 1, colSpanResolved, columnOffset); ++columnIndex; } } this.OnRowExported(new ExcelRowExportedEventArgs(worksheet, worksheetRow, rowIndex, columnOffset, outlineLevel, false, true, false)); ++rowIndex; } SummaryRow behavior3 = grid.Behaviors.GetBehavior<SummaryRow>(); if (behavior3 == null || !behavior3.Enabled) return; this.ExportSummaries(grid, worksheet, ref rowIndex, columnOffset, outlineLevel, hidden, styleClassString1, firstDataRowIndex); }