//распределение между продавцами private void SellerDistribution() { Dictionary <int, double> sellerDict = new Dictionary <int, double>(); for (int i = 0; i < archiveBid.Count; i++) { if (!sellerDict.ContainsKey(archiveBid[i].Id_seller)) { sellerDict.Add(archiveBid[i].Id_seller, archiveBid[i].Amount); } else { sellerDict[archiveBid[i].Id_seller] += archiveBid[i].Amount; } } if (sellerDict.Count == 0) { return; } ReportRow rowH = new ReportRow(); rowH.Add(new ReportCell("Распределение между продавцами:")); Rows.Add(rowH); ReportRow rowT = new ReportRow(); rowT.Add(new ReportCell("Продавец") { BorderColor = System.Drawing.Color.Black, ColumnSpan = 1 }); rowT.Add(null); rowT.Add(new ReportCell("Сумма") { ColumnSpan = 1, BorderColor = System.Drawing.Color.Black }); Rows.Add(rowT); foreach (KeyValuePair <int, double> kv in sellerDict.OrderByDescending(x => x.Value)) { Seller seller = SellerViewModel.instance().getById(kv.Key); if (seller == null) { continue; } ReportRow row = new ReportRow(); row.Add(new ReportCell(seller.Name) { ColumnSpan = 1, BorderColor = System.Drawing.Color.Black }); row.Add(null); row.Add(new ReportCell(kv.Value.ToString().Replace(',', '.')) { ColumnSpan = 1, BorderColor = System.Drawing.Color.Black }); Rows.Add(row); } }
/// <summary> Gets report rows. </summary> /// <param name="items"> The items. </param> /// <param name="options"> Options for controlling the operation. </param> /// <returns> The report rows. </returns> private List <ReportRow> GetReportRows(IEnumerable <ActivityLogEntry> items, List <ReportOptions <ActivityLogEntry> > options) { var rows = new List <ReportRow>(); foreach (ActivityLogEntry item in items) { ReportRow rRow = GetRow(item); foreach (ReportOptions <ActivityLogEntry> option in options) { object itemColumn = option.Column != null?option.Column(item, rRow) : ""; object itemId = option.ItemID != null?option.ItemID(item) : ""; ReportItem rItem = new ReportItem { Name = ReportHelper.ConvertToString(itemColumn, option.Header.HeaderFieldType), Id = ReportHelper.ConvertToString(itemId, ReportFieldType.Object) }; rRow.Columns.Add(rItem); } rows.Add(rRow); } return(rows); }
public FormReportTest(ReportRow row) { InitializeComponent(); this.FormClosing += FormReportTest_FormClosing; this.row = row; }
public override bool Save() { ColumnCount = 5; columnsWidth.Add(1, 2.57); columnsWidth.Add(2, 8.29); columnsWidth.Add(3, 8.29); columnsWidth.Add(4, 53); columnsWidth.Add(5, 11.57); HeaderRow = new string[] { "№", "Печь", "Артикул", "Наименование", "Количество" }; List <Details> details = DetailsController.instance().getSortedByOrderSetting(); List <ReportRow> reportData = new List <ReportRow>(); for (int i = 0; i < details.Count; i++) { ReportRow reportRow = new ReportRow(); Details detail = details[i]; reportRow.Row.Add(detail.RowIndex.ToString()); reportRow.Row.Add(detail.OvenName); reportRow.Row.Add(detail.VendorCode); reportRow.Row.Add(detail.Name); reportRow.Row.Add(detail.CurrentCount.ToString()); reportData.Add(reportRow); reportRow.Style.Add(ReportRow.RowStyle.Border); } Data = reportData; return(Create()); }
public void TestReportRowUSD() { ReportRow reportRow = new ReportRow(id: 0, brand: "IBM", stockNum: 1000, stockValue: 25, currency: "USD"); var expected = 25000; Assert.AreEqual(reportRow.Sum, expected); }
/// <summary> /// Converts data table output to report collection. /// </summary> /// <param name="output">Data table output.</param> /// <returns>Report row collection.</returns> private Collection <ReportRow> ConvertDataTableToCollection(DataTable output) { Collection <ReportRow> rows = new Collection <ReportRow>(); foreach (DataRow dr in output.Rows) { var row = new ReportRow(); var rowData = new Collection <CommerceProperty>(); for (int i = 0; i < output.Columns.Count; i++) { object val = dr[i]; // If the current value is of type string, then get the localized string if possible if (output.Columns[i].DataType.Name == "String") { val = this.GetLocalizedLabel((string)val); } rowData.Add(new CommerceProperty(output.Columns[i].ColumnName, val)); } row.SetRowData(rowData); rows.Add(row); } return(rows); }
//Статистика по клиентам private void BuyerStatistic() { Dictionary <int, int> buyerDict = new Dictionary <int, int>(); for (int i = 0; i < archiveBid.Count; i++) { if (!buyerDict.ContainsKey(archiveBid[i].Id_buyer)) { buyerDict.Add(archiveBid[i].Id_buyer, 1); } else { buyerDict[archiveBid[i].Id_buyer]++; } } if (buyerDict.Count == 0) { return; } ReportRow rowH = new ReportRow(); rowH.Add(new ReportCell("Статистика по клиентам:")); Rows.Add(rowH); ReportRow rowT = new ReportRow(); rowT.Add(new ReportCell("Покупатель") { BorderColor = System.Drawing.Color.Black, ColumnSpan = 1 }); rowT.Add(null); rowT.Add(new ReportCell("Кол-во заявок") { ColumnSpan = 1, BorderColor = System.Drawing.Color.Black }); Rows.Add(rowT); foreach (KeyValuePair <int, int> kv in buyerDict.OrderByDescending(x => x.Value)) { Buyer buyer = BuyerViewModel.instance().getById(kv.Key); if (buyer == null) { continue; } ReportRow row = new ReportRow(); row.Add(new ReportCell(buyer.Name) { ColumnSpan = 1, BorderColor = System.Drawing.Color.Black }); row.Add(null); row.Add(new ReportCell(kv.Value.ToString()) { ColumnSpan = 1, BorderColor = System.Drawing.Color.Black }); Rows.Add(row); } }
//Пятая строка (дата отгрузки и покупатель) private bool createShipmentDateRow() { Buyer buyer = BuyerViewModel.instance().getById(bid.Id_buyer); if (buyer == null) { return(false); } ReportRow row = new ReportRow(); row.Cells.Add(new ReportCell("Дата отгрузки") { Height = 16.50, TextStyle = new List <TextStyle>() { TextStyle.Bold }, VerticalAlignment = VerticalAlignment.Bottom }); AddEmptyCell(row, 2); string shipmentDate = ""; if (bid.Planned_shipment_date != null) { shipmentDate = ((DateTime)bid.Planned_shipment_date).ToString("dd.MM.yyyy"); } row.Cells.Add(new ReportCell(shipmentDate) { ColumnSpan = 4, BorderColor = System.Drawing.Color.Black }); AddEmptyCell(row, 3); row.Cells.Add(new ReportCell() { VerticalAlignment = VerticalAlignment.Bottom }); row.Cells.Add(new ReportCell("Покупатель") { TextStyle = new List <TextStyle>() { TextStyle.Bold }, VerticalAlignment = VerticalAlignment.Bottom }); AddEmptyCell(row, 2); row.Cells.Add(new ReportCell(buyer.Name) { ColumnSpan = 4, BorderColor = Color.Black }); AddEmptyCell(row, 3); row.Cells.Add(new ReportCell() { VerticalAlignment = VerticalAlignment.Bottom }); Rows.Add(row); return(true); }
private static void ExportToExcelRow(ReportResult reportResult, StringBuilder returnValue, ReportRow row) { returnValue.AppendLine("<tr>"); returnValue.AppendLine(string.Join("", row.Columns.Select(s => string.Format("<td>{0}</td>", s.Name)).ToArray())); returnValue.AppendLine("</tr>"); }
public override bool Save() { ReportRow row = new ReportRow(); string headerText = "Показатели за период " + year.ToString() + " г."; if (month != 0) { headerText += ", " + Classes.Months.getRuMonthNameByNumber(month); } row.Add(new ReportCell(headerText) { ColumnSpan = 3, Height = 18.75, Width = 18.86, TextStyle = new List <TextStyle>() { TextStyle.Bold } }); row.Add(new ReportCell() { Width = 35.43 }); row.Add(new ReportCell() { Width = 15.43 }); row.Add(new ReportCell() { Width = 15, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Bottom }); Rows.Add(row); Rows.Add(new ReportRow()); CreateBidsInfo(); Rows.Add(new ReportRow()); SellerDistribution(); Rows.Add(new ReportRow()); ManagerSales(); Rows.Add(new ReportRow()); TransportCompanyDistribution(); Rows.Add(new ReportRow()); IsShipped(); Rows.Add(new ReportRow()); BuyerStatistic(); Rows.Add(new ReportRow()); MiddlePositionCountInBid(); Rows.Add(new ReportRow()); ComplectationStatistic(); AllDocumentFontSize = 14; return(Create()); }
protected override string GetCellStyle(ReportRow row, RowField field) { string html = base.GetCellStyle(row, field); if (field.DataType == typeof(int)) { html += @"mso-number-format:\@;"; } return(html); }
//Пустая строка private void createEmptyRow(double height) { ReportRow empty_row = new ReportRow(); empty_row.Cells.Add(new ReportCell() { Height = height }); Rows.Add(empty_row); }
/// <summary> Gets a row. </summary> /// <param name="item"> The item. </param> /// <returns> The row. </returns> private ReportRow GetRow(ActivityLogEntry item) { ReportRow rRow = new ReportRow { Id = item.Id.ToString(), UserId = item.UserId }; return(rRow); }
//Третья строка (продавец и номер счета) private bool createSellerRow() { Seller seller = SellerViewModel.instance().getById(bid.Id_seller); if (seller == null) { return(false); } ReportRow row = new ReportRow(); row.Cells.Add(new ReportCell("Продавец") { Height = 16.50, TextStyle = new List <TextStyle>() { TextStyle.Bold }, VerticalAlignment = VerticalAlignment.Bottom }); AddEmptyCell(row, 2); row.Cells.Add(new ReportCell(seller.Name) { ColumnSpan = 4, BorderColor = System.Drawing.Color.Black }); AddEmptyCell(row, 3); row.Cells.Add(new ReportCell() { VerticalAlignment = VerticalAlignment.Bottom }); row.Cells.Add(new ReportCell("Номер счета") { TextStyle = new List <TextStyle>() { TextStyle.Bold }, VerticalAlignment = VerticalAlignment.Bottom }); AddEmptyCell(row, 2); row.Cells.Add(new ReportCell(bid.Account) { ColumnSpan = 4, BorderColor = Color.Black }); AddEmptyCell(row, 3); row.Cells.Add(new ReportCell() { VerticalAlignment = VerticalAlignment.Bottom }); Rows.Add(row); return(true); }
private static string GetRowDataFormatted(ReportRow row, RowField field, RenderHintsCollection hints) { bool encloseInQuotes = hints[EncloseInQuotes] as bool? ?? true; if (encloseInQuotes) { return(string.Format("\"{0}\"", row.GetFormattedValue(field))); } return(row.GetFormattedValue(field)); }
public ReportRow AddReportRow(int PageNo, string Content) { ReportRow rowReportRow = ((ReportRow)(this.NewRow())); object[] columnValuesArray = new object[] { null, PageNo, Content }; rowReportRow.ItemArray = columnValuesArray; this.Rows.Add(rowReportRow); return(rowReportRow); }
public override bool Save(DateTime startDate, DateTime endDate) { ColumnCount = 7; columnsWidth.Add(1, 2.57); columnsWidth.Add(2, 8.14); columnsWidth.Add(3, 8.29); columnsWidth.Add(4, 34.29); columnsWidth.Add(5, 11.71); columnsWidth.Add(6, 9); columnsWidth.Add(7, 7.43); HeaderRow = new string[] { "№", "Печь", "Артикул", "Наименование", "Поступление", "Списание", "Остаток" }; List <Details> details = DetailsController.instance().getSortedByOrderSetting(); if (startDate == null) { int currentDay = DateTime.Now.Day; startDate = DateTime.Now.AddDays(-(currentDay - 1)); } if (endDate == null) { endDate = DateTime.Now; } List <Supply> supplysForPeriod = SupplyController.instance().getByPeriod(startDate, endDate); List <Writeoff> writeoffsForPeriod = WriteoffController.instance().getByPeriod(startDate, endDate); List <ReportRow> reportData = new List <ReportRow>(); for (int i = 0; i < details.Count; i++) { Details detail = details[i]; ReportRow reportRow = new ReportRow(); reportRow.Row.Add(detail.RowIndex.ToString()); reportRow.Row.Add(detail.OvenName); reportRow.Row.Add(detail.VendorCode); reportRow.Row.Add(detail.Name); reportRow.Row.Add(getSupplyForPeriod(detail, supplysForPeriod).ToString()); reportRow.Row.Add(getWriteoffForPeriod(detail, writeoffsForPeriod).ToString()); reportRow.Row.Add(detail.CurrentCount.ToString()); reportRow.Style.Add(ReportRow.RowStyle.Border); reportData.Add(reportRow); } Data = reportData; return(Create()); }
public void TestReportAddReportRow() { CurrencyReport report = new CurrencyReport(); report.AddReportRow(brand: "IBM", stockNum: 1000, stockValue: 25, currency: "USD"); ReportRow reportRow = new ReportRow(id: 0, brand: "IBM", stockNum: 1000, stockValue: 25, currency: "USD"); Assert.AreEqual(reportRow, report.ReportList[0]); report.AddReportRow(brand: "Novartis", stockNum: 400, stockValue: 150, currency: "CHF"); ReportRow reportRow2 = new ReportRow(id: 1, brand: "Novartis", stockNum: 400, stockValue: 150, currency: "CHF"); Assert.AreEqual(reportRow2, report.ReportList[1]); }
protected virtual string GetCellStyle(ReportRow row, RowField field) { switch (row.RowType) { case ReportRowType.HeaderRow: return(field.HeaderStyle.ToCss()); case ReportRowType.DataRow: return(field.DataStyle.ToCss()); default: return(field.FooterStyle.ToCss()); } }
protected virtual string GetCellStyle(ReportRow row, RowField field) { if (row.RowType == ReportRowType.HeaderRow) { return(field.HeaderStyle.GetHtml()); } else if (row.RowType == ReportRowType.DataRow) { return(field.DataStyle.GetHtml()); } else { return(field.FooterStyle.GetHtml()); } }
//Девятая строка (заголовок "Комплектация:") private bool createComplectationTitleRow() { ReportRow row = new ReportRow(); row.Cells.Add(new ReportCell("Комплектация:") { Height = 21.00, TextStyle = new List <TextStyle>() { TextStyle.Bold }, VerticalAlignment = VerticalAlignment.Bottom }); Rows.Add(row); return(true); }
//Четвертая строка (дата создания и дата счета) private bool createBidDateRow() { ReportRow row = new ReportRow(); row.Cells.Add(new ReportCell("Дата заявки") { Height = 16.50, TextStyle = new List <TextStyle>() { TextStyle.Bold }, VerticalAlignment = VerticalAlignment.Bottom }); AddEmptyCell(row, 2); row.Cells.Add(new ReportCell(DateTime.Now.ToString("dd.MM.yyyy")) { ColumnSpan = 4, BorderColor = System.Drawing.Color.Black }); AddEmptyCell(row, 3); row.Cells.Add(new ReportCell() { VerticalAlignment = VerticalAlignment.Bottom }); row.Cells.Add(new ReportCell("Дата счета") { TextStyle = new List <TextStyle>() { TextStyle.Bold }, VerticalAlignment = VerticalAlignment.Bottom }); AddEmptyCell(row, 2); row.Cells.Add(new ReportCell(bid.Date_created.ToString("dd.MM.yyyy")) { ColumnSpan = 4, BorderColor = Color.Black }); AddEmptyCell(row, 3); row.Cells.Add(new ReportCell() { VerticalAlignment = VerticalAlignment.Bottom }); Rows.Add(row); return(true); }
//Среднее количество позиций в заявке private void MiddlePositionCountInBid() { int equipmentBidCount = archiveBid.Sum(x => x.EquipmentBidCollection.Count); //Кол-во переданных в архив заявок ReportRow row = new ReportRow(); row.Add(new ReportCell("Среднее количество позиций в заявке:") { ColumnSpan = 1, BorderColor = System.Drawing.Color.Black }); row.Add(new ReportCell()); row.Add(new ReportCell((equipmentBidCount / archiveBid.Count).ToString()) { ColumnSpan = 1, BorderColor = System.Drawing.Color.Black }); Rows.Add(row); }
protected virtual void RenderRow(ReportRow row, RenderHintsCollection hints) { Html.AppendLine("<tr>"); foreach (var field in row.Fields) { if (row.RowType == ReportRowType.HeaderRow) { Html.AppendFormat("<th class='headerCell' style='{1}'>{0}</th>", field.HeaderText, GetCellStyle(row, field)); } else if (row.RowType == ReportRowType.DataRow) { if (hints.BooleanCheckboxes) { if (field.DataType == typeof(bool) || field.DataType == typeof(bool?)) { string checkbox = "<input type='checkbox' disabled='disabled'"; if (GetBooleanValue(row[field.Name])) { checkbox += " checked='checked'"; } checkbox += " />"; row[field] = checkbox; } } var formattedValue = row.GetFormattedValue(field); var url = row.GetUrlString(field); if (url != null) { formattedValue = string.Format("<a href='{1}'>{0}</a>", formattedValue, url); } Html.AppendFormat("<td style='{1}'>{0}</td>", formattedValue, GetCellStyle(row, field)); } else if (row.RowType == ReportRowType.FooterRow) { Html.AppendFormat("<td class='footerCell' style='{1}'>{0}</td>", row.GetFormattedValue(field), GetCellStyle(row, field)); } } Html.AppendLine("</tr>"); }
//Разделитель private void createDivider() { ReportRow row = new ReportRow(); row.Cells.Add(new ReportCell() { Height = 15.00, ColumnSpan = 15, BorderStyle = BorderStyle.Dot, BorderWeight = BorderWeight.Thick, Border = new List <Border>() { Border.Bottom }, }); Rows.Add(row); }
public ReportViewModel() { Test.Clear(); Random r = new Random(); for (int i = 0; i < 100; i++) { ReportRow row = new ReportRow(r.Next(2, 3000)); row.Columns = new List <ReportColumn>(); for (int x = 0; x < 100; x++) { row.Columns.Add(new ReportColumn(r.Next(2, 2000))); } Test.Add(row); } }
/// <summary> Gets a row. </summary> /// <param name="item"> The item. </param> /// <returns> The row. </returns> private ReportRow GetRow(BaseItem item) { var video = item as Video; ReportRow rRow = new ReportRow { Id = item.Id.ToString("N"), HasLockData = item.IsLocked, HasLocalTrailer = item.GetExtras(new[] { ExtraType.Trailer }).Any(), HasImageTagsPrimary = item.ImageInfos != null && item.ImageInfos.Count(n => n.Type == ImageType.Primary) > 0, HasImageTagsBackdrop = item.ImageInfos != null && item.ImageInfos.Count(n => n.Type == ImageType.Backdrop) > 0, HasImageTagsLogo = item.ImageInfos != null && item.ImageInfos.Count(n => n.Type == ImageType.Logo) > 0, HasSpecials = item.GetDisplayExtras().Any(), HasSubtitles = video != null ? video.HasSubtitles : false, RowType = ReportHelper.GetRowType(item.GetClientTypeName()) }; return(rRow); }
//Данные заявителя private bool createManagerRow() { ReportRow row = new ReportRow(); row.Cells.Add(new ReportCell("Заявитель") { Height = 24.00, TextStyle = new List <TextStyle>() { TextStyle.Bold }, VerticalAlignment = VerticalAlignment.Bottom }); AddEmptyCell(row, 2); row.Cells.Add(new ReportCell(Auth.getInstance().Full_name) { ColumnSpan = 7, BorderColor = System.Drawing.Color.Black, TextStyle = new List <TextStyle>() { TextStyle.Bold } }); AddEmptyCell(row, 6); row.Cells.Add(new ReportCell() { VerticalAlignment = VerticalAlignment.Bottom, HorizontalAlignment = HorizontalAlignment.Center }); row.Cells.Add(new ReportCell() { BorderColor = System.Drawing.Color.Black, ColumnSpan = 4 }); AddEmptyCell(row, 4); Rows.Add(row); return(true); }
//Восьмая строка (модификации) private bool createModificationRow() { string modificationName = ""; if (equipmentBid.Id_modification != null) { Modification modification = ModificationViewModel.instance().getById((int)equipmentBid.Id_modification); if (modification != null) { modificationName = modification.Name; } } ReportRow row = new ReportRow(); row.Cells.Add(new ReportCell("Модификация") { Height = 16.50, TextStyle = new List <TextStyle>() { TextStyle.Bold }, VerticalAlignment = VerticalAlignment.Bottom }); AddEmptyCell(row, 2); row.Cells.Add(new ReportCell(modificationName) { ColumnSpan = 12, BorderColor = System.Drawing.Color.Black }); AddEmptyCell(row, 11); row.Cells.Add(new ReportCell() { VerticalAlignment = VerticalAlignment.Bottom, }); Rows.Add(row); return(true); }
private void dg1_MouseRightButtonUp(object sender, MouseButtonEventArgs e) { if (sender is DataGrid g) { var hit = VisualTreeHelper.HitTest((Visual)sender, e.GetPosition((IInputElement)sender)); DependencyObject cell = VisualTreeHelper.GetParent(hit.VisualHit); while (cell != null && !(cell is System.Windows.Controls.DataGridCell)) { cell = VisualTreeHelper.GetParent(cell); } System.Windows.Controls.DataGridCell targetCell = cell as System.Windows.Controls.DataGridCell; if (targetCell is null) { return; } ReportRow row = targetCell.DataContext as ReportRow; ReportColumn entry = row.Columns[targetCell.Column.DisplayIndex] as ReportColumn; MessageBox.Show($"Creating for: {row.RowHeader} & {entry.ColumnHeader} at {entry.Entry}"); } }
private ICollection<int> GenerateRow(ExcelWriter xlWriter, ReportRow reportRow) { xlWriter.PutResultsRow(reportRow.Name, reportRow.MaxValue, reportRow.Results); return reportRow.Results; }
public SmoData(Worksheet worksheet, int rowIndex, string smoCode) : base(worksheet) { Plan = new ReportRow(worksheet, rowIndex++, FomsReportRowType.Plan); Fact = new ReportRow(worksheet, rowIndex++, FomsReportRowType.Fact); SmoCode = smoCode; }