public async Task Catogery_Data() { List <int> IDlist = new List <int>(); List <Catogery> dataarray = new List <Catogery>(); for (int i = 1; i <= 44; i++) { IDlist.Add(i); } var VideoCatogeryRequest = youtubeService.VideoCategories.List("snippet"); VideoCatogeryRequest.Id = String.Join(',', IDlist.GetRange(0, 44)); var VideoCatogeryReponse = await VideoCatogeryRequest.ExecuteAsync(); dataarray.AddRange(VideoCatogeryReponse.Items.Select(x => { var data = new Catogery(); data.ID = x.Id; data.title = x.Snippet.Title; return(data); })); string OutputPath1 = strWorkPath + "/Catogery.json"; SaveJSON <Catogery>(OutputPath1, dataarray); }
private void btnAddItem_Click_1(object sender, RoutedEventArgs e) { int sellprice, buyprice; // bool xx = int.Parse(txtsellprice.Text) > int.Parse(txtBuyPrice.Text); //*bool tryqty = int.TryParse(txtQty.Text, out qty); bool trysellprice = int.TryParse(txtsellprice.Text, out sellprice); bool trybuyprice = int.TryParse(txtBuyPrice.Text, out buyprice); // bool x = int.Parse(txtsellprice.Text) > int.Parse(txtBuyPrice.Text); if (txtItemName.Text != "" && sellprice > buyprice) { Item new_item = new Item(); new_item.name = txtItemName.Text; new_item.Quantity = 0;//int.Parse( txtQty.Text); new_item.SellPrice = int.Parse(txtsellprice.Text); new_item.BuyPrice = int.Parse(txtBuyPrice.Text); Catogery cat = (Catogery)cmbcats.SelectedItem; new_item.Cat_Id = cat.ID; context.Items.Add(new_item); context.SaveChanges(); MessageBox.Show("item added "); cmbcats.SelectedIndex = -1; cmbitems.Items.Clear(); } else { MessageBox.Show("plz make sure about item name \n and sell price should be bigger than buy price "); } }
private void FillCommonTypes(string name) { using (Entities1 db = new Entities1()) { Catogery cat = db.Catogeries.Where(x => x.Name == name).FirstOrDefault(); drplvl2.DataSource = db.usp_CommonTypesSelectByCatogeryByCatogery(cat.ID).ToList(); drplvl2.ValueField = "ID"; drplvl2.TextField = "Name"; DataBind(); } }
private void Button_Click9(object sender, RoutedEventArgs e) { if (txtCat.Text != "") { Catogery c1 = new Catogery { Name = txtCat.Text }; context.Catogerys.Add(c1); context.SaveChanges(); MessageBox.Show("your object inserted"); } else { MessageBox.Show("plz insert data into textbox"); } }
private void cmbcats_SelectionChanged(object sender, SelectionChangedEventArgs e) { Catogery cat = (Catogery)cmbcats.SelectedItem; txtItemName.IsEnabled = true; //int x = cat.ID; if (cat != null) { cmbitems.Items.Clear(); var items = context.Items.Where(i => i.catogery.ID == cat.ID); foreach (Item x in items) { cmbitems.DisplayMemberPath = "name"; cmbitems.SelectedValuePath = "ID"; cmbitems.Items.Add(x); } } }
public void UpdateCatogery(Catogery catogery) { context.Entry(catogery).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); }
public void CreateCatogery(Catogery catogery) { context.Catogeries.Add(catogery); context.SaveChanges(); }
public ActionResult Delete(Catogery catogery) { var cat = context.GetCatogery(catogery.ID); return(View(cat)); }
public ActionResult Edit(Catogery catogery) { context.UpdateCatogery(catogery); return(RedirectToAction("Index")); }
public ActionResult Create(Catogery catogery) { context.CreateCatogery(catogery); return(RedirectToAction("Index")); }