public IHttpActionResult PutTovar(int id, Tovar tovar) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tovar.Id) { return(BadRequest()); } db.Entry(tovar).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TovarExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
private void button4_Click(object sender, EventArgs e) { openFileDialog1.ShowDialog(); FileStream f = new FileStream(openFileDialog1.FileName, FileMode.Open); StreamReader rd = new StreamReader(f); string[] str; string inpstr; List<Tovar> tov = new List<Tovar>(); for (int i = 0; i < dataGridView1.Rows.Count; i++) { tov.Add(new Tovar(Convert.ToInt32(dataGridView1[0, i].Value), Convert.ToString(dataGridView1[1, i].Value), Convert.ToDateTime(dataGridView1[2, i].Value), Convert.ToInt32(dataGridView1[3, i].Value), 0)); } while ((inpstr = rd.ReadLine()) != null) { str = inpstr.Split(' '); Tovar t = new Tovar(Convert.ToInt32(str[0]), str[1], Convert.ToDateTime(str[2]), Convert.ToInt32(str[3]), Convert.ToDecimal(str[4])); using (SqlCeConnection conn = new SqlCeConnection(@"Data Source=C:\Users\Андрей свали с компа\Desktop\myDB.sdf")) { conn.Open(); using (SqlCeCommand c = new SqlCeCommand(@"insert into tovar(name, srok, kolvo, price) values('" + t.name + "','"+t.srok.Date+"'," + t.kolvo + "," + t.prise.ToString().Replace(',','.')+")")) { c.Connection = conn; c.ExecuteNonQuery(); } } } rd.Close(); this.tovarTableAdapter.Fill(this.allDataSet.Tovar); tovarTableAdapter.Update(this.allDataSet.Tovar); }
public void Add(Tovar tovar) { db.Tovars.Add(tovar); db.SaveChanges(); Response.Redirect("/Home/Index"); }
public void Delete(Tovar tovar) { db.Entry(tovar).State = EntityState.Deleted; db.Tovars.Remove(tovar); db.SaveChanges(); Response.Redirect("/Home/Index"); }
private void button4_Click(object sender, EventArgs e) { openFileDialog1.ShowDialog(); FileStream f = new FileStream(openFileDialog1.FileName, FileMode.Open); StreamReader rd = new StreamReader(f); string[] str; string inpstr; List <Tovar> tov = new List <Tovar>(); for (int i = 0; i < dataGridView1.Rows.Count; i++) { tov.Add(new Tovar(Convert.ToInt32(dataGridView1[0, i].Value), Convert.ToString(dataGridView1[1, i].Value), Convert.ToDateTime(dataGridView1[2, i].Value), Convert.ToInt32(dataGridView1[3, i].Value), 0)); } while ((inpstr = rd.ReadLine()) != null) { str = inpstr.Split(' '); Tovar t = new Tovar(Convert.ToInt32(str[0]), str[1], Convert.ToDateTime(str[2]), Convert.ToInt32(str[3]), Convert.ToDecimal(str[4])); using (SqlCeConnection conn = new SqlCeConnection(@"Data Source=C:\Users\Андрей свали с компа\Desktop\myDB.sdf")) { conn.Open(); using (SqlCeCommand c = new SqlCeCommand(@"insert into tovar(name, srok, kolvo, price) values('" + t.name + "','" + t.srok.Date + "'," + t.kolvo + "," + t.prise.ToString().Replace(',', '.') + ")")) { c.Connection = conn; c.ExecuteNonQuery(); } } } rd.Close(); this.tovarTableAdapter.Fill(this.allDataSet.Tovar); tovarTableAdapter.Update(this.allDataSet.Tovar); }
int IComparer.Compare(object ob1, object ob2) { Tovar ml = (Tovar)ob1; Tovar m2 = (Tovar)ob2; return(String.Compare(ml.nameMagaz, m2.nameMagaz)); }
private void справочникТоваровToolStripMenuItem_Click(object sender, EventArgs e) { Tovar form = new Tovar(); form.MdiParent = this; form.Show(); }
public async Task <IActionResult> TovarEdit(TovarCreateViewModel model) { Tovar tovar = await db.Tovar.FindAsync(model.Id); if (tovar != null) { tovar.TovarName = model.TovarName; tovar.Price = model.Price; tovar.Car = model.Car; tovar.CatalogId = model.CatalogId; tovar.Quantity = model.Quantity; tovar.Category = model.Category; tovar.Visible = model.Visible; if (model.Path != null) { byte[] imageData = null; using (var binatyReader = new BinaryReader(model.Path.OpenReadStream())) { imageData = binatyReader.ReadBytes((int)model.Path.Length); } tovar.Path = imageData; } db.Tovar.Update(tovar); await db.SaveChangesAsync(); return(RedirectToAction("TovarList")); } return(View(model)); }
static void Main(string[] args) { Nomenklatura gitara_nomenklatura = new Nomenklatura("gitara", new DateTime(2018, 02, 05)); Nomenklatura skripka_nomenklatura = new Nomenklatura("skripka", new DateTime(2018, 01, 28)); Nomenklatura mediator_nomenklatura = new Nomenklatura("Mediator", new DateTime(2018, 01, 28)); Nomenklatura baraban_nomenklatura = new Nomenklatura("baraban", new DateTime(2016, 09, 10)); Nomenklatura piano_nomenklatura = new Nomenklatura("piano", new DateTime(2017, 10, 10)); Gitara tovar1 = new Gitara(gitara_nomenklatura, "electric_guitar", "YAMAHA", 15000, new DateTime(2015, 03, 07)); Skripka tovar2 = new Skripka(skripka_nomenklatura, "Crafter", 1, 50000, new DateTime(2017, 05, 08)); Baraban tovar3 = new Baraban(baraban_nomenklatura, "YAMAHA", "wood - leather", 7000, new DateTime(2016, 09, 10)); Piano tovar4 = new Piano(piano_nomenklatura, "C.Bechstein", "wood", 80000, new DateTime(2017, 10, 10)); Accessories tovar5 = new Accessories(mediator_nomenklatura, "Mediator", 100, gitara_nomenklatura); List <Tovar> ListTovar = new List <Tovar>(); ListTovar.Add(tovar1); ListTovar.Add(tovar2); ListTovar.Add(tovar3); ListTovar.Add(tovar4); ListTovar.Add(tovar5); // массив для сериализации: Tovar[] tovar = new Tovar[] { tovar1, tovar2, tovar3, tovar4, tovar5 }; BinaryFormatter formatter = new BinaryFormatter(); using (FileStream fs = new FileStream("tovar.dat", FileMode.OpenOrCreate)) { // сериализуем весь массив tovar formatter.Serialize(fs, tovar); Console.WriteLine("Сериализация в поток байтов прошла успешно"); } // десериализация using (FileStream fs = new FileStream("tovar.dat", FileMode.OpenOrCreate)) { Tovar[] deserilizeTovar = (Tovar[])formatter.Deserialize(fs); foreach (Tovar tv in deserilizeTovar) { Console.WriteLine("Товар: {0} ; Цена: {1}", tv.ID, tv.Price); } /*foreach (Tovar t in ListTovar) * { * Console.WriteLine(t.tv()); * } * Console.WriteLine(" "); * Console.WriteLine("Из них аксессуары:"); * foreach (Tovar t in ListTovar.Where(i1 => i1 is IAccessories)) * { * Console.WriteLine(t.tv()); * }*/ Console.ReadLine(); } }
public ActionResult DeleteConfirmed(int id) { Tovar tovar = db.Tovars.Find(id); db.Tovars.Remove(tovar); db.SaveChanges(); return(RedirectToAction("Index")); }
private Tovar CreateTovar() { var t = new Tovar(true, spisok); panel1.Controls.Add(t); t.Dock = DockStyle.Top; t.Closed += t_Closed; return(t); }
public ActionResult Details(int id = 0) { Tovar tovar = db.Tovars.Find(id); if (tovar == null) { return(HttpNotFound()); } return(View(tovar)); }
public ActionResult Buy(Tovar tovar, int id) { tovar = db.Tovars.Find(id); if (tovar == null) { return(HttpNotFound()); } return(View(tovar)); }
public async Task <IActionResult> TovarEdit(int tovId) { Tovar tovar = await db.Tovar.FindAsync(tovId); TovarCreateViewModel model = new TovarCreateViewModel { Id = tovar.Id, TovarName = tovar.TovarName, Price = tovar.Price, Car = tovar.Car, CatalogId = tovar.CatalogId, Quantity = tovar.Quantity, Category = tovar.Category, CategoryId = tovar.CategoryId, Visible = tovar.Visible }; return(View(model)); }
public ActionResult Edit(Tovar tovar) { if (ModelState.IsValid) { db.Entry(tovar).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tovar)); }
public IHttpActionResult GetTovar(int id) { Tovar tovar = db.Tovars.Find(id); if (tovar == null) { return(NotFound()); } return(Ok(tovar)); }
// // GET: /Tovar/Edit/5 public ActionResult Edit(int id = 0) { Tovar tovar = db.Tovars.Find(id); if (tovar == null) { return(HttpNotFound()); } ViewBag.idTovara = new SelectList(db.Sklads, "idTovara", "nazvanie", tovar.idTovara); return(View(tovar)); }
public ActionResult Edit(Tovar tovar) { if (ModelState.IsValid) { db.Entry(tovar).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.idTovara = new SelectList(db.Sklads, "idTovara", "nazvanie", tovar.idTovara); return(View(tovar)); }
// GET: Tovar public ActionResult Tovar(int id) { ViewBag.ProductId = id; Tovar tovar = context.Tovars.Find(id); if (tovar != null) { return(View(tovar)); } return(View("Tovar")); }
public ActionResult Create(Tovar tovar) { if (ModelState.IsValid) { db.Tovars.Add(tovar); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.idTovara = new SelectList(db.Sklads, "idTovara", "nazvanie", tovar.idTovara); return(View(tovar)); }
public IHttpActionResult PostTovar(Tovar tovar) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Tovars.Add(tovar); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = tovar.Id }, tovar)); }
private void FormMain_Load(object sender, EventArgs e) { Organization org = new Organization(); Type type = new Type(); Tovar tovar = new Tovar(); ImportExport impexp = new ImportExport(); TovarInOrganization tovinorg = new TovarInOrganization(); org.Load(); type.Load(); tovar.Load(); impexp.Load(); tovinorg.Load(); }
private void FormMain_FormClosed(object sender, FormClosedEventArgs e) { Organization org = new Organization(); Type type = new Type(); Tovar tovar = new Tovar(); ImportExport impexp = new ImportExport(); TovarInOrganization tovinorg = new TovarInOrganization(); org.Save(); type.Save(); tovar.Save(); impexp.Save(); tovinorg.Save(); }
public IHttpActionResult DeleteTovar(int id) { Tovar tovar = db.Tovars.Find(id); if (tovar == null) { return(NotFound()); } db.Tovars.Remove(tovar); db.SaveChanges(); return(Ok(tovar)); }
private void delete_Click(object sender, RoutedEventArgs e) { Tovar tovar = TovarTable.SelectedItem as Tovar; if (tovar != null) { using (ModelDB db = new ModelDB()) { db.Entry(tovar).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); } UpdateTovar(); } }
private void Button_Click(object sender, RoutedEventArgs e) { using (ModelDB db = new ModelDB()) { Tovar tovar = new Tovar(); tovar.name = name.Text; tovar.price = decimal.Parse(price.Text); tovar.sort = sort.Text; tovar.description = description.Text; db.Tovar.Add(tovar); db.SaveChanges(); UpdateTovar(); } }
public ActionResult Add(Tovar tovar) { if (tovar.Name == null || tovar.Count == 0 || tovar.Price == 0 || tovar.Vlas == null) { Response.Write("<script>window.alert('Заповніть всі поля!');</script>"); return(View()); } else { Response.Write("<script>window.alert('Препарат успішно додано!');</script>"); db.Tovars.Add(tovar); db.SaveChanges(); return(RedirectToAction("../home/")); } }
int IComparer.Compare(object ob1, object ob2) { Tovar ml = (Tovar)ob1; Tovar m2 = (Tovar)ob2; if (ml.costTovar > m2.costTovar) { return(1); } if (ml.costTovar < m2.costTovar) { return(-1); } return(0); }
private void UpdateTovar_Click(object sender, RoutedEventArgs e) { Tovar tovar = (Tovar)GridTovar.SelectedItem; //tovar.IdTovar; tbName primerRepository.UpdateTovar(tovar.IdTovar, tbName.Text); GridTovar.ItemsSource = null; GridTovar.ItemsSource = primerRepository.GetTovars(); GridTovarType.ItemsSource = null; GridTovarType.ItemsSource = primerRepository.GetViewTovarTypes(); //GridViewTovar.ItemsSource = null; //GridViewTovar.ItemsSource = primerRepository.GetViewTovars(); }
private void TovarTable_SelectionChanged(object sender, SelectionChangedEventArgs e) { edit.Visibility = Visibility.Visible; delete.Visibility = Visibility.Visible; add.Visibility = Visibility.Collapsed; Tovar tovar = TovarTable.SelectedItem as Tovar; if (tovar != null) { name.Text = tovar.name; price.Text = tovar.price.ToString(); sort.Text = tovar.sort; description.Text = tovar.description; } }
public Details GetTovarForId(int id) { Tovar detail = _context.Tovars.FirstOrDefault(x => x.Id.Equals(id)); string catname = _context.Categories.FirstOrDefault(x => x.ID == detail.CategoryId).Name; string username = _context.AdditionalInfos.FirstOrDefault(x => x.Id == detail.UserId).UserName; Details retTov = new Details { Id = detail.Id, Name = detail.Name, Cost = detail.Cost, Images = (ICollection <Tovar_ImageDTO>)detail.Images, Description = detail.Description, CategoryName = catname, UserName = username }; return(retTov); }
private void edit_Click(object sender, RoutedEventArgs e) { Tovar tovar = TovarTable.SelectedItem as Tovar; if (tovar != null) { tovar.name = name.Text; tovar.price = decimal.Parse(price.Text); tovar.sort = sort.Text; tovar.description = description.Text; using (ModelDB db = new ModelDB()) { db.Entry(tovar).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } UpdateTovar(); } }
private void btnAddTovar_Click(object sender, EventArgs e) { //код проверки на правильность ввода if (rdbYesParam.Checked) { tovar = new Tovar(cmbFloor.SelectedItem.ToString(), Convert.ToInt32(spnPlace.Value), scrClock.Value, scrPrice.Value, cmbBonus.SelectedItem.ToString()); } else { tovar = new Tovar(); tovar.setFloor(cmbFloor.SelectedItem.ToString()); tovar.setPlace(Convert.ToInt32(spnPlace.Value)); tovar.setClock(scrClock.Value); tovar.setPrice(scrPrice.Value); tovar.setBonus(cmbBonus.SelectedItem.ToString()); } this.Close(); }
private void btnAdd_Click(object sender, EventArgs e) { try { if (cbType.Text == "" || tbName.Text == "" || tbWeight.Text == "" || tbPrice.Text == "" || cbOrg.Text == "") throw new Exception(); Tovar tov = new Tovar(tbName.Text, tbWeight.Text, tbPrice.Text,tbNumber.Text,(Type)cbType.SelectedItem); TovarInOrganization tovInOrg = new TovarInOrganization((Organization)cbOrg.SelectedItem, tov); tbName.Text = ""; tbNumber.Text = ""; tbPrice.Text = ""; tbWeight.Text = ""; } catch (Exception) { MessageBox.Show("Коректно заповніть поля!Cтворіть організацію(склад) або новий тип товару!"); } }
public void deleteTovar(Tovar tovar, ref List<Tovar> list) { Console.WriteLine("\n����� "+tovar.name+" ����� �� ��������!\n"); list.Remove(tovar); }