public CategoriesRow AddCategoriesRow(string CategoryName, string Description, byte[] Picture) { CategoriesRow rowCategoriesRow = ((CategoriesRow)(this.NewRow())); rowCategoriesRow.ItemArray = new object[] { null, CategoryName, Description, Picture}; this.Rows.Add(rowCategoriesRow); return rowCategoriesRow; }
public CategoriesRow AddCategoriesRow(string CategoryName) { CategoriesRow rowCategoriesRow = ((CategoriesRow)(this.NewRow())); object[] columnValuesArray = new object[] { CategoryName }; rowCategoriesRow.ItemArray = columnValuesArray; this.Rows.Add(rowCategoriesRow); return(rowCategoriesRow); }
public CategoriesRow AddCategoriesRow(string CategoryName, int CategoryID) { CategoriesRow rowCategoriesRow = ((CategoriesRow)(this.NewRow())); rowCategoriesRow.ItemArray = new object[] { CategoryName, CategoryID }; this.Rows.Add(rowCategoriesRow); return(rowCategoriesRow); }
public ProductsRow AddProductsRow(string ProductName, int SupplierID, CategoriesRow parentCategoriesRowByCategoriesProducts, string QuantityPerUnit, System.Decimal UnitPrice, short UnitsInStock, short UnitsOnOrder, short ReorderLevel, bool Discontinued) { ProductsRow rowProductsRow = ((ProductsRow)(this.NewRow())); rowProductsRow.ItemArray = new object[] { null, ProductName, SupplierID, parentCategoriesRowByCategoriesProducts[0], QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued }; this.Rows.Add(rowProductsRow); return(rowProductsRow); }
public CategoriesRowChangeEvent(CategoriesRow row, DataRowAction action) { this.eventRow = row; this.eventAction = action; }
public void RemoveCategoriesRow(CategoriesRow row) { this.Rows.Remove(row); }
public void AddCategoriesRow(CategoriesRow row) { this.Rows.Add(row); }
public CategoriesRowChangeEvent(CategoriesRow row, global::System.Data.DataRowAction action) { this.eventRow = row; this.eventAction = action; }
public ProductsRow AddProductsRow(string ProductName, SuppliersRow parentSuppliersRowByFK_Products_Suppliers, CategoriesRow parentCategoriesRowByFK_Products_Categories, string QuantityPerUnit, decimal UnitPrice, short UnitsInStock, short UnitsOnOrder, short ReorderLevel, bool Discontinued) { ProductsRow rowProductsRow = ((ProductsRow)(this.NewRow())); object[] columnValuesArray = new object[] { null, ProductName, null, null, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued}; if ((parentSuppliersRowByFK_Products_Suppliers != null)) { columnValuesArray[2] = parentSuppliersRowByFK_Products_Suppliers[0]; } if ((parentCategoriesRowByFK_Products_Categories != null)) { columnValuesArray[3] = parentCategoriesRowByFK_Products_Categories[0]; } rowProductsRow.ItemArray = columnValuesArray; this.Rows.Add(rowProductsRow); return rowProductsRow; }
public ProductsRow AddProductsRow(string ProductName, SuppliersRow parentSuppliersRowBySuppliersProducts, CategoriesRow parentCategoriesRowByCategoriesProducts, string QuantityPerUnit, decimal UnitPrice, short UnitsInStock, short UnitsOnOrder, short ReorderLevel, bool Discontinued) { ProductsRow rowProductsRow = ((ProductsRow)(this.NewRow())); rowProductsRow.ItemArray = new object[] { null, ProductName, parentSuppliersRowBySuppliersProducts[0], parentCategoriesRowByCategoriesProducts[0], QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued}; this.Rows.Add(rowProductsRow); return rowProductsRow; }
public ExcelImportResponse ExcelImport(IUnitOfWork uow, ExcelImportRequest request) { request.CheckNotNull(); Check.NotNullOrWhiteSpace(request.FileName, "Filename"); UploadHelper.CheckFileNameSecurity(request.FileName); if (!request.FileName.StartsWith("temporary/")) { throw new ArgumentOutOfRangeException("filename"); } ExcelPackage ep = new ExcelPackage(); using (var fs = new FileStream(UploadHelper.DbFilePath(request.FileName), FileMode.Open, FileAccess.Read)) ep.Load(fs); var c = CategoriesRow.Fields; var t = CategoriesTypeRow.Fields; var response = new ExcelImportResponse(); response.ErrorList = new List <string>(); var worksheet = ep.Workbook.Worksheets[1]; for (var row = 2; row <= worksheet.Dimension.End.Row; row++) { try { var categoryName = Convert.ToString(worksheet.Cells[row, 3].Value ?? ""); if (categoryName.IsTrimmedEmpty()) { continue; } var category = uow.Connection.TryFirst <CategoriesRow>(q => q .Select(c.CategoryId) .Where(c.CategoryName == categoryName)); if (category == null) { category = new CategoriesRow { CategoryName = categoryName } } ; else { category.TrackWithChecks = false; } #region Type var typeName = Convert.ToString(worksheet.Cells[row, 1].Value ?? ""); if (!string.IsNullOrWhiteSpace(typeName)) { var type = uow.Connection.TryFirst <CategoriesTypeRow>(q => q .Select(t.CategoryTypeId) .Where(t.CategoryType == typeName)); if (type == null) { response.ErrorList.Add("Error On Row" + row + ": Category with name '" + typeName + "' is not found!"); continue; } category.CategoryTypeId = Convert.ToInt16(type.CategoryTypeId.Value); } else { category.CategoryTypeId = null; } #endregion Type category.CategoryCode = Convert.ToString(worksheet.Cells[row, 2].Value ?? ""); category.Description = Convert.ToString(worksheet.Cells[row, 4].Value ?? ""); if (category.CategoryId == null) { new CategoriesRepository().Create(uow, new SaveWithLocalizationRequest <MyRow> { Entity = category }); response.Inserted = response.Inserted + 1; } else { new CategoriesRepository().Update(uow, new SaveWithLocalizationRequest <MyRow> { Entity = category, EntityId = category.CategoryId.Value }); response.Updated = response.Updated + 1; } } catch (Exception ex) { response.ErrorList.Add("Exception on Row " + row + ": " + ex.Message); } } return(response); }
public CategoriesRowChangedEventArgs(CategoriesRow r, System.Data.DataRowAction a) { this.eventRow = r; this.eventAction = a; }