コード例 #1
0
        public static int SetWidths(ExportModelConfiguration config, int width)
        {
            switch (config.Field)
            {
            case "Brand":
            case "Class":
            case "ManufacturerName":
            case "Name":
                width = Constants.OPENXML_EXPORT_WIDTH_PIXELS_25;
                break;

            case "Detail":
            case "OrderHistoryString":
                width = Constants.OPENXML_EXPORT_WIDTH_PIXELS_80;
                break;

            case "UPC":
                width = Constants.OPENXML_EXPORT_WIDTH_PIXELS_16;
                break;

            case "AveragePrice":
            case "TotalCost":
                width = Constants.OPENXML_EXPORT_WIDTH_PIXELS_10;
                break;
            }
            return(width);
        }
コード例 #2
0
ファイル: InvoiceModel.cs プロジェクト: tlwilliams88/Entree
        public static int SetWidths(ExportModelConfiguration config, int width)
        {
            switch (config.Field)
            {
            case "InvoiceNumber":
            case "PONumber":
            case "TypeDescription":
                width = Constants.OPENXML_EXPORT_WIDTH_PIXELS_12;
                break;

            case "InvoiceAmount":
            case "Amount":
                width = Constants.OPENXML_EXPORT_WIDTH_PIXELS_16;
                break;

            case "InvoiceDate":
            case "DueDate":
                width = Constants.OPENXML_EXPORT_WIDTH_PIXELS_14;
                break;

            case "CustomerNumber":
                width = Constants.OPENXML_EXPORT_WIDTH_PIXELS_20;
                break;

            case "CustomerName":
                width = Constants.OPENXML_EXPORT_WIDTH_PIXELS_25;
                break;
            }
            return(width);
        }
コード例 #3
0
        public static int SetWidths(ExportModelConfiguration config, int width)
        {
            switch (config.Field)
            {
            case "Name":
            case "BrandExtendedDescription":
                width = Constants.OPENXML_EXPORT_WIDTH_PIXELS_20;
                break;

            case "Detail":
            case "OrderHistoryString":
                width = Constants.OPENXML_EXPORT_WIDTH_PIXELS_80;
                break;

            case "Pack":
                width = Constants.OPENXML_EXPORT_WIDTH_PIXELS_08;
                break;

            case "UnitCost":
                width = Constants.OPENXML_EXPORT_WIDTH_PIXELS_14;
                break;

            case "CasePrice":
            case "PackagePrice":
            case "Size":
                width = Constants.OPENXML_EXPORT_WIDTH_PIXELS_12;
                break;
            }
            return(width);
        }
コード例 #4
0
        public static int SetWidths(ExportModelConfiguration config, int width)
        {
            switch (config.Field)
            {
            case "Name":
            case "Notes":
            case "BrandExtendedDescription":
                width = Constants.OPENXML_EXPORT_WIDTH_PIXELS_25;
                break;

            case "Detail":
            case "OrderHistoryString":
                width = Constants.OPENXML_EXPORT_WIDTH_PIXELS_80;
                break;

            case "Pack":
                width = Constants.OPENXML_EXPORT_WIDTH_PIXELS_08;
                break;

            case "quantityordered":
            case "quantityshipped":
                width = Constants.OPENXML_EXPORT_WIDTH_PIXELS_14;
                break;

            case "ItemPrice":
            case "ExtSalesNet":
            case "PackSize":
                width = 12;
                break;
            }
            return(width);
        }
コード例 #5
0
ファイル: OrderLine.cs プロジェクト: tlwilliams88/Entree
        public static int SetWidths(ExportModelConfiguration config, int width)
        {
            switch (config.Field)
            {
            case "Name":
            case "BrandExtendedDescription":
            case "ItemClass":
            case "Notes":
            case "Status":
                width = 20;
                break;

            case "Detail":
            case "OrderHistoryString":
                width = 80;
                break;

            case "Pack":
                width = 8;
                break;

            case "Size":
            case "QuantityOrdered":
            case "QantityShipped":
                width = 12;
                break;
            }
            return(width);
        }
コード例 #6
0
        public static int SetWidths(ExportModelConfiguration config, int width)
        {
            List <string> fields = new List <string>()
            {
                "Name", "Brand", "ItemClass", "Category", "label", "Notes"
            };

            if (fields.Contains(config.Field))
            {
                width = Constants.OPENXML_EXPORT_WIDTH_PIXELS_16;
            }
            return(width);
        }
コード例 #7
0
 private void SetPriceConfig(PropertyInfo[] properties, T item, ExportModelConfiguration thisConfig)
 {
     if (thisConfig.Label != null &&
         thisConfig.Label.Equals("Price") &&
         properties.Select(p => p.Name).Contains("Each", StringComparer.CurrentCultureIgnoreCase))
     {
         PropertyInfo eachProperty = properties.Where(p => p.Name.Equals("Each", StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();
         if (eachProperty != null)
         {
             string each = GetFieldValue(item, eachProperty).Trim();
             if (each.Equals("Y"))
             {
                 thisConfig.Field = "PackagePrice";
             }
         }
     }
 }
コード例 #8
0
        private void WriteItemRecord(StringBuilder sb, T item, string exportType)
        {
            List <string> itemRecord = new List <string>();

            var properties = item.GetType().GetProperties(BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Instance);

            foreach (var config in exportConfig.OrderBy(e => e.Order))
            {
                //Base or Sub property?
                var propertyName = config.Field.Split('.');

                if (propertyName.Length == 1)
                {     // fix in general for exports; this adds correction in pricing to both text-based and excel-based exports
                    ExportModelConfiguration thisConfig = new ExportModelConfiguration()
                    { // just a shallow copy
                        Field    = config.Field,
                        Label    = config.Label,
                        Order    = config.Order,
                        Selected = config.Selected
                    };
                    SetPriceConfig(properties, item, thisConfig);
                    var property = properties.Where(p => p.Name.Equals(thisConfig.Field, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();
                    if (property != null)
                    {
                        itemRecord.Add(string.Format("\"{0}\"", this.GetFieldValue(item, property).Trim()));
                    }
                }
                else
                {
                    var childProp       = properties.Where(p => p.Name.Equals(propertyName[0])).FirstOrDefault();
                    var childProperties = childProp.PropertyType.GetProperties();
                    var subProperty     = childProperties.Where(p => p.Name.Equals(propertyName[1])).FirstOrDefault();
                    if (subProperty != null)
                    {
                        itemRecord.Add(string.Format("\"{0}\"", this.GetFieldValue(childProp.GetValue(item), subProperty).Trim()));
                    }
                }
            }

            if (itemRecord.Count > 0)
            {
                sb.AppendLine(string.Join(exportType.Equals("csv", StringComparison.CurrentCultureIgnoreCase) ? "," : "\t", itemRecord));
            }
        }
コード例 #9
0
ファイル: Order.cs プロジェクト: tlwilliams88/Entree
        public static int SetWidths(ExportModelConfiguration config, int width)
        {
            switch (config.Field)
            {
            case "Status":
            case "InvoiceStatus":
            case "PONumber":
            case "OrderSystem":
            case "DeliveryDate":
                width = 20;
                break;

            case "InvoiceNumber":
            case "CreatedDate":
            case "ItemCount":
            case "OrderTotal":
                width = 12;
                break;
            }
            return(width);
        }
コード例 #10
0
        private uint WriteDataFieldsDataRowsToExcelWorksheet(uint rowIndex, SheetData sheetData, PropertyInfo[] properties, string[] excelColumnNames)
        {
            int columnIndex;

            foreach (var item in this.Model)
            {
                rowIndex++;
                var newExcelRow = new Row {
                    RowIndex = rowIndex
                };                                                 // add a row at the top of spreadsheet
                sheetData.Append(newExcelRow);
                if (item != null)
                {
                    columnIndex = 0;
                    foreach (var config in exportConfig.OrderBy(e => e.Order))
                    {
                        var propertyName = config.Field.Split('.');
                        if (propertyName.Length == 1)
                        {
                            ExportModelConfiguration thisConfig = new ExportModelConfiguration()
                            {
                                // just a shallow copy
                                Field    = config.Field,
                                Label    = config.Label,
                                Order    = config.Order,
                                Selected = config.Selected
                            };
                            SetPriceConfig(properties, item, thisConfig);
                            var property = properties.Where(p => p.Name.Equals(thisConfig.Field, StringComparison.CurrentCultureIgnoreCase))
                                           .FirstOrDefault();
                            uint       styleInd = SetStyleForCell(typeof(T).Name, thisConfig.Field);
                            CellValues celltype = SetCellValueTypesForCell(typeof(T).Name, thisConfig.Field);
                            if (property != null)
                            {
                                OpenXmlSpreadsheetUtilities.AppendTextCell
                                    (excelColumnNames[columnIndex] + rowIndex.ToString(),
                                    this.GetFieldValue(item, property)
                                    .Trim(), newExcelRow,
                                    celltype,
                                    styleInd);
                            }
                        }
                        else
                        {
                            var childProp = properties.Where(p => p.Name.Equals(propertyName[0]))
                                            .FirstOrDefault();
                            var childProperties = childProp.PropertyType.GetProperties();
                            var subProperty     = childProperties.Where(p => p.Name.Equals(propertyName[1]))
                                                  .FirstOrDefault();
                            if (subProperty != null)
                            {
                                OpenXmlSpreadsheetUtilities.AppendTextCell
                                    (excelColumnNames[columnIndex] + rowIndex.ToString(), this.GetFieldValue(childProp.GetValue(item), subProperty)
                                    .Trim(), newExcelRow);
                            }
                        }

                        columnIndex++;
                    }
                }
            }
            return(rowIndex);
        }