private static Product LoadProduct(DataRow dataRow, ProductTypeList productTypeList, BrandList brandList) { int id = Convert.ToInt32(dataRow["PID"]); int typeID = Convert.ToInt32(dataRow["ProductType"]); int brandID = Convert.ToInt32(dataRow["Brand"]); string name = dataRow["ProductName"].ToString(); string remark = dataRow["Remark"].ToString(); ProductType type = productTypeList.GetType(typeID); if (type == null) { Log.Write("LoadProduct failed. Can't find type:" + typeID.ToString()); return(null); } Brand brand = brandList.GetBrand(brandID); if (brand == null) { Log.Write("LoadProduct failed. Can't find brand:" + brandID.ToString()); return(null); } Product result = new Product(id, type, name, brand, remark); return(result); }
private void ProductEditor_Load(object sender, EventArgs e) { brandsBindingSource.DataSource = BrandList.GetBrandList(); productTypesBindingSource.DataSource = ProductTypeList.GetProductTypeList(); BindProductType(); modelsBindingSource.DataSource = ModelList.GetModelList(); }
public ProductTypeList GetProductTypes() { if (productTypeList == null) { productTypeList = ProductTypeLoader.LoadProductTypeList(); } return(productTypeList); }
public static ProductList LoadProducts(ProductTypeList productTypeList, BrandList brandList) { if (productTypeList == null || brandList == null) { return(null); } ProductList productList = LoadProductList(productTypeList, brandList); return(productList); }
/** * Purpose: Creates a sorted product type list view * Return: * Product type list view */ public async Task <IActionResult> Buy() { List <ProductType> ProductTypeList = await context.ProductType.OrderBy(s => s.Label).ToListAsync(); ProductTypeList.ForEach(CalculateTypeQuantities); var model = new ProductTypeList(context); model.ProductTypes = ProductTypeList; return(View(model)); }
private void BindProductType() { productTypesTreeView.Nodes.Clear(); foreach (var productType in ProductTypeList.GetProductTypeList()) { var treeNode = new TreeNode(); treeNode.Text = productType.ProductTypeName; treeNode.Name = productType.ProductTypeId.ToString(); productTypesTreeView.Nodes.Add(treeNode); } }
public MainWindow() { InitializeComponent(); DataContext = this; Globals.DataProvider = new MySQLDataProvider(); Globals.ProductTypeList = Globals.DataProvider.GetProductTypes(); ProductList = Globals.DataProvider.GetProducts(); ProductTypeList = Globals.DataProvider.GetProductTypes().ToList(); ProductTypeList.Insert(0, new ProductType { Title = "Все типы" }); }
public static ProductTypeList LoadProductTypeList() { DataTable dataTable = DBAccessor.QueryProductTypes(); if (dataTable == null) { return(null); } ProductTypeList productTypeList = new ProductTypeList(); foreach (DataRow dataRow in dataTable.Rows) { ProductType productType = LoadProductType(dataRow); productTypeList.AddType(productType); } return(productTypeList); }
private void removeButton_Click(object sender, EventArgs e) { if (tabControl.SelectedTab.Name == "brands") { ((Brand)brandsBindingSource.Current).Delete(); } else if (tabControl.SelectedTab.Name == "productTypes") { var selectedNode = productTypesTreeView.SelectedNode; var localProductTypeId = int.Parse(selectedNode.Name); var productType = ProductTypeList.GetProductType(localProductTypeId); productType.Delete(); BindProductType(); } }
/// <summary> /// 初始化产品类型 /// </summary> internal void InitialProductType() { ProductTypeList.Clear(); Xamarin.Forms.Device.BeginInvokeOnMainThread(new Action(() => { this._spProductTypeList.Children.Clear(); })); IEnumerable <ProductType> models = null; if (!IsImport) { models = Resources.Instance.ProductTypes.Where(x => x.HideType == 0 || x.HideType == 2).OrderByDescending(x => x.Order).ThenByDescending(x => x.ProductTypeId); } else { models = Resources.Instance.ProductTypes.Where(x => x.HideType == 0 || x.HideType == 3).OrderByDescending(x => x.Order).ThenByDescending(x => x.ProductTypeId); } ProductTypeList.Add(new ProductTypeStateModel() { ProductType = new ProductType() { ProductTypeId = -1, ProductTypeName0 = Res.Instance.GetString("All", Res.Instance.GetMainLangByMainLangIndex(0).Culture), ProductTypeName1 = Res.Instance.GetString("All", Res.Instance.GetMainLangByMainLangIndex(1).Culture), ProductTypeName2 = Res.Instance.GetString("All", Res.Instance.GetMainLangByMainLangIndex(2).Culture), }, IsSelected = false }); foreach (var item in models) { ProductTypeList.Add(new ProductTypeStateModel() { ProductType = item }); } Xamarin.Forms.Device.BeginInvokeOnMainThread(new Action(() => { foreach (var item in ProductTypeList) { AddProductTypeItem(item); } })); }
private static ProductList LoadProductList(ProductTypeList productTypeList, BrandList brandList) { DataTable dataTable = DBAccessor.QueryProducts(); if (dataTable == null) { return(null); } ProductList productList = new ProductList(); foreach (DataRow dataRow in dataTable.Rows) { Product product = LoadProduct(dataRow, productTypeList, brandList); if (product == null) { continue; } productList.AddProduct(product); } return(productList); }
public ProductTypeEditor(int productTypeId) : this() { _productType = ProductTypeList.GetProductType(productTypeId); }
private void InitTypeList() { typeList = (ProductTypeList)controller.GetProductTypes().Clone(); typeList.AddType(new ProductType(0, "All Product Types", -1)); }
private void InitData() { brandList = controller.GetBrands(); productTypeList = controller.GetProductTypes(); productList = controller.GetProducts(); }