Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        public void Add(Tovar tovar)
        {
            db.Tovars.Add(tovar);

            db.SaveChanges();
            Response.Redirect("/Home/Index");
        }
Esempio n. 4
0
 public void Delete(Tovar tovar)
 {
     db.Entry(tovar).State = EntityState.Deleted;
     db.Tovars.Remove(tovar);
     db.SaveChanges();
     Response.Redirect("/Home/Index");
 }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
                int IComparer.Compare(object ob1, object ob2)
                {
                    Tovar ml = (Tovar)ob1;
                    Tovar m2 = (Tovar)ob2;

                    return(String.Compare(ml.nameMagaz, m2.nameMagaz));
                }
Esempio n. 7
0
        private void справочникТоваровToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Tovar form = new Tovar();

            form.MdiParent = this;
            form.Show();
        }
Esempio n. 8
0
        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));
        }
Esempio n. 9
0
        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();
            }
        }
Esempio n. 10
0
        public ActionResult DeleteConfirmed(int id)
        {
            Tovar tovar = db.Tovars.Find(id);

            db.Tovars.Remove(tovar);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 11
0
        private Tovar CreateTovar()
        {
            var t = new Tovar(true, spisok);

            panel1.Controls.Add(t);
            t.Dock    = DockStyle.Top;
            t.Closed += t_Closed;
            return(t);
        }
Esempio n. 12
0
        public ActionResult Details(int id = 0)
        {
            Tovar tovar = db.Tovars.Find(id);

            if (tovar == null)
            {
                return(HttpNotFound());
            }
            return(View(tovar));
        }
Esempio n. 13
0
        public ActionResult Buy(Tovar tovar, int id)
        {
            tovar = db.Tovars.Find(id);
            if (tovar == null)
            {
                return(HttpNotFound());
            }

            return(View(tovar));
        }
Esempio n. 14
0
        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));
        }
Esempio n. 15
0
        public ActionResult Edit(Tovar tovar)
        {
            if (ModelState.IsValid)
            {
                db.Entry(tovar).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tovar));
        }
Esempio n. 16
0
        public IHttpActionResult GetTovar(int id)
        {
            Tovar tovar = db.Tovars.Find(id);

            if (tovar == null)
            {
                return(NotFound());
            }

            return(Ok(tovar));
        }
Esempio n. 17
0
        //
        // 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));
        }
Esempio n. 18
0
 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));
 }
Esempio n. 19
0
        // 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"));
        }
Esempio n. 20
0
        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));
        }
Esempio n. 21
0
        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));
        }
Esempio n. 22
0
 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();
 }
Esempio n. 23
0
 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();
 }
Esempio n. 24
0
        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));
        }
Esempio n. 25
0
        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();
            }
        }
Esempio n. 26
0
 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();
     }
 }
Esempio n. 27
0
 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/"));
     }
 }
Esempio n. 28
0
                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);
                }
Esempio n. 29
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();
        }
Esempio n. 30
0
        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;
            }
        }
Esempio n. 31
0
        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);
        }
Esempio n. 32
0
        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();
            }
        }
Esempio n. 33
0
 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();
 }
Esempio n. 34
0
 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творіть організацію(склад) або новий тип товару!");
     }
 }
Esempio n. 35
0
 public void deleteTovar(Tovar tovar,  ref List<Tovar> list)
 {
     Console.WriteLine("\n����� "+tovar.name+" ����� �� ��������!\n");
     list.Remove(tovar);
 }