/// <summary> /// Funkcja do wczytywania kategorii i ich linków. Zmienia kodowanie. /// </summary> private void GetCategories() { var listTitles = new List <string>(); var listUrls = new List <string>(); WebClient webClient = new WebClient(); Encoding enc = Encoding.GetEncoding("ISO-8859-2"); webClient.Encoding = enc; string page = webClient.DownloadString(ResourceRss.UrlWebsite); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(page); var titles = from node in doc.DocumentNode.SelectNodes("//td[@class = 'tdPolecane01']") select node.InnerText.ToString(); listTitles = titles.AsQueryable().ToList(); var urls = from node in doc.DocumentNode.SelectNodes("//td[@class = 'tdPolecane02']") select node.InnerText.ToString(); listUrls = urls.AsQueryable().ToList(); for (int i = 0; i < listTitles.Count(); i++) { ListCategories.Add(new Category { Name = listTitles[i], Url = listUrls[i] }); } }
private void btedit_Click(object sender, EventArgs e) { if (gvcategories.SelectedRows.Count == 0) { MessageBox.Show("Tidak ada kategori yang akan diubah"); } else { var selectedRowId = (int)gvcategories.SelectedRows[0].Cells["id"].Value; var cats = ListCategories.FirstOrDefault(x => x.catid == selectedRowId); if (selectedRowId == 1) { MessageBox.Show("Anda tidak dibenarkan mengubah kategori Lain-Lain"); } else if (cats != null) { var form = new ManageCategories(); form.userdata = userdata; form.Editmode = true; form.CategoryData = cats; form.ShowDialog(); LoadData(); foreach (DataGridViewRow row in gvcategories.Rows) { if (((int)row.Cells["id"].Value) == selectedRowId) { gvcategories.Rows[row.Index].Selected = true; break; } } } } }
/// <return>---</return> // GET: Category/List public ActionResult List(string FaqSearchKey = null) { ListCategories ViewModel = new ListCategories(); ViewModel.isadmin = User.IsInRole("Admin"); string url = "CategoryData/GetCategories" + FaqSearchKey; HttpResponseMessage response = client.GetAsync(url).Result; if (response.IsSuccessStatusCode) { IEnumerable <CategoryDto> SelectedCategories = response.Content.ReadAsAsync <IEnumerable <CategoryDto> >().Result; ViewModel.categories = SelectedCategories; //Get All Faqs for specific Category url = "CategoryData/GetAllFaqForCategory"; response = client.GetAsync(url).Result; //Debug.WriteLine(response.StatusCode); IEnumerable <FaqDto> SelectedFaqs = response.Content.ReadAsAsync <IEnumerable <FaqDto> >().Result; ViewModel.CategoryFaqs = SelectedFaqs;//Seen in the ViewModel Folder return(View(ViewModel)); } else { return(RedirectToAction("Error")); } }
/// <summary> /// Recharge les Categories de prix depuis la DB /// </summary> public void LoadCategories() { List <CategoryPrice> categoryPrices = CategoryPriceServices.GetAllPrice(); ListCategories.Clear(); foreach (CategoryPrice categoryPrice in categoryPrices) { ListCategories.Add(categoryPrice); } }
private void EditCategory() { var element = ListCategories.SelectedItems[0]; if (element == null) { return; } Presenter.Editcategory(int.Parse(element.Tag.ToString())); ListCategories.Select(); }
private void btnDell_Click(object sender, EventArgs e) { var element = ListCategories.SelectedItems[0]; if (element == null) { return; } Presenter.Deletecategory(int.Parse(element.Tag.ToString())); ListCategories.Select(); }
private async void _getCategoriesCallback(IAsyncResult asynchronousResult) { HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState; try { HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult); string resultContent = string.Empty; using (var reader = new StreamReader(response.GetResponseStream())) { resultContent = reader.ReadToEnd(); }; if (!string.IsNullOrEmpty(resultContent)) { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { StaticResources.ListCategories = Newtonsoft.Json.JsonConvert.DeserializeObject <ObservableCollection <Categories> >(resultContent); this.ListCategories = StaticResources.ListCategories; if (StaticResources.ShopeePreConfig != null) { this.TbHeight = StaticResources.ShopeePreConfig.height; this.TbLength = StaticResources.ShopeePreConfig.length; this.TbWeight = StaticResources.ShopeePreConfig.weight; this.TbWidth = StaticResources.ShopeePreConfig.width; this.isPreorder = StaticResources.ShopeePreConfig.isPreOrder; this.TbShippingFee = StaticResources.ShopeePreConfig.shippingfee; this.isCoverShippingFee = StaticResources.ShopeePreConfig.isCoverFee; this.TbEstimatedDate = StaticResources.ShopeePreConfig.estDate.ToString(); this.SelectedMainCategory = ListCategories.Single(p => p.main.catid == StaticResources.ShopeePreConfig.parCatID); this.SelectedSubCategory = ListSubCategories.Single(p => p.catid == StaticResources.ShopeePreConfig.subCatID); if (StaticResources.LogisticsChannel != null) { this.ListLogisticsChannelClone = StaticResources.LogisticsChannel; Utility.getLogisticChannel(StaticResources.SelectedShopLogin, new AsyncCallback(_getLogisticChannelCallback)); } else { Utility.getLogisticChannel(StaticResources.SelectedShopLogin, new AsyncCallback(_getLogisticChannelCallback)); } } else { Utility.getLogisticChannel(StaticResources.SelectedShopLogin, new AsyncCallback(_getLogisticChannelCallback)); } }); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
private void LoadData() { ListCategories = categoryRepository.GetAll(); gvcategories.Rows.Clear(); foreach (var item in ListCategories.OrderBy(x => x.name)) { gvcategories.Rows.Add(item.catid, item.name, item.remark); } }
private void LoadData() { //if (userdata.user_role == "kasir") //{ // btadditem.Visible = false; // btedititem.Visible = false; // btdeleteitem.Visible = false; // btunitmanage.Visible = false; // btmanagebrand.Visible = false; //} try { ListBrands = brandRepository.GetAll().ToList(); ListProducts = productRepository.GetAll().ToList(); ListCategories = categoryRepository.GetAll().ToList(); ListUnits = unitRepository.GetAll().ToList(); var tempproductlist = new List <TempProdColumns>(); if (ListProducts != null) { foreach (var item in ListProducts) { var prodbrand = ListBrands.FirstOrDefault(x => x.brandid == item.brandid); var prodcat = ListCategories.FirstOrDefault(x => x.catid == item.prodcat); var produnit = ListUnits.FirstOrDefault(x => x.unitid == item.produnit); var itemDetail = new TempProdColumns(); itemDetail.prodid = item.prodid; itemDetail.brandid = item.brandid; itemDetail.brand_name = prodbrand != null ? prodbrand.name : " - "; itemDetail.name = item.name; itemDetail.prodcat = item.prodcat; itemDetail.prodcat_name = prodcat != null ? prodcat.name : " - "; itemDetail.prodcode = item.prodcode; itemDetail.produnit = item.produnit; itemDetail.produnit_code = produnit != null ? produnit.unitcode : " - "; itemDetail.purchaseprice = item.purchaseprice; itemDetail.stocks = item.stocks; itemDetail.barcodeno = item.barcodeno; tempproductlist.Add(itemDetail); } gvproducts.Rows.Clear(); foreach (var item in tempproductlist.OrderBy(x => x.prodcat_name).ThenBy(x => x.brand_name).ThenBy(x => x.name)) { gvproducts.Rows.Add( item.prodid, item.prodcat_name, item.brand_name, item.prodcode, item.name, item.produnit_code, Utils.ToRupiah(item.purchaseprice), item.barcodeno, item.stocks ); } } var cbData = ListBrands; cbData.Insert(0, new BrandColumns { brandid = -1, name = "--- Pilih Merek ---" }); cbbrand.DataSource = new BindingSource(ListBrands, null); cbbrand.DisplayMember = "name"; cbbrand.ValueMember = "brandid"; var cbcatdata = ListCategories; cbcatdata.Insert(0, new CategoryColumns { catid = -1, name = "--- Pilih Kategori ---" }); cbcategory.DataSource = new BindingSource(ListCategories, null); cbcategory.DisplayMember = "name"; cbcategory.ValueMember = "catid"; } catch (Exception ex) { var errMsg = "Details : " + ex.Message + Environment.NewLine + "Stacktrace : " + ex.StackTrace; MessageBox.Show(errMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } tbprodname.Focus(); }