/// <summary> /// Add new producer /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1Add_Click(object sender, EventArgs e) { try { if (textBox1Name.Text == "" || textBox1Country.Text == "") { MessageBox.Show("Поля не заповненні"); return; } else { db.Producer.Add(new Producer { Name = "\"" + textBox1Name.Text + "\"", Country = textBox1Country.Text }); db.SaveChanges(); listView1.Items.Clear(); comboBox1.Items.Clear(); FillDb(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } textBox1Name.Text = null; textBox1Country.Text = null; }
private void button1Add_Click(object sender, EventArgs e) { try { if (textBox1Add.Text == "") { MessageBox.Show("Полe не заповненнe"); return; } else { db.Category.Add(new Category { Name = textBox1Add.Text }); db.SaveChanges(); listView2.Items.Clear(); FillDb(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } textBox1Add.Text = null; }
private void button_ok_Click(object sender, EventArgs e) { try { db = new SilpoDBEntities(); string role = comboBox_role.SelectedItem.ToString(); string city = textBox_city.Text; string name = textBox_name.Text; string login = textBox_login.Text; string pass = textBox_pass.Text; Users newUser = new Users(); newUser.Role = role; newUser.City = city; newUser.Full_name = textBox_name.Text; newUser.Login = login; newUser.Password = pass; db.Users.Add(newUser); db.SaveChanges(); MessageBox.Show("зареестровані"); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button1_Click(object sender, EventArgs e) { //add try { var com = comboBox1.SelectedItem.ToString(); // назвы продуктів із комбобокса var nuber = db.Product.Where(x => x.Name == com).Select(n => n.ID_product).First(); // MessageBox.Show(nuber.ToString()); textBox_id_prod.Text = nuber.ToString(); var sd = new Discount(); sd.Id_product = Int32.Parse(textBox_id_prod.Text); sd.Percent = Convert.ToInt32(numericUpDown1.Value); // відсоток //DateTime date = new DateTime(2016, 11, 01); //DateTime date2 = new DateTime(2016, 11, 07); var date = Convert.ToDateTime(textBox_start.Text); var date2 = Convert.ToDateTime(textBox_end.Text); sd.Start = date; // дата початку знижки sd.End = date2; // дата закінчення знижки db.Discount.Add(sd); db.SaveChanges(); MessageBox.Show("Додано"); textBox_id_prod.Clear(); textBox_start.Clear(); textBox_end.Clear(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void materialFlatButton_ok_Click(object sender, EventArgs e) // ПіДТВЕРДЖЕНННЯ кнопка { var itemss = listView_queue.Items; // колекція IdOrder foreach (var it in itemss) // заповнення поля "complited" { var li = (ListViewItem)it; int idorder = Convert.ToInt32(li.Text); var orderOrder = db.Orders.Where(x => x.ID_order == idorder).First(); orderOrder.Complited = "yes"; var sell = new Sell(); sell.idSeller = Convert.ToInt32(label_userid.Text); sell.idOrder = idorder; //MessageBox.Show(sell.idSeller.ToString()); //MessageBox.Show(sell.idOrder.ToString()); db.Sell.Add(sell); } var balance = db.ShopBank.Where(name => name.AccountName == "Silpo").First(); // заповнення таблиці Shopbank decimal sum = Convert.ToDecimal(mylt); //MessageBox.Show(balance.ToString()); //MessageBox.Show(sum.ToString()); balance.Balance += sum; //MessageBox.Show(balance.ToString()); db.SaveChanges(); listBox_queue.Items.Remove(listBox_queue.SelectedItem); }
private void materialFlatButtonAdd_Click(object sender, EventArgs e) { try { var selectItemProducer = comboBoxProducer.SelectedItem.ToString(); var selectItemCategory = comboBoxCategory.SelectedItem.ToString(); Producer idProducer = db.Producer.Where(x => x.Name == selectItemProducer).SingleOrDefault <Producer>(); Category idCategory = db.Category.Where(x => x.Name == selectItemCategory).SingleOrDefault <Category>(); MessageBox.Show(idProducer.ID_producer.ToString() + " " + idCategory.ID_category.ToString()); ProducerCats validate = db.ProducerCats.Where(x => x.Id_producer == idProducer.ID_producer).Where(x => x.Id_category == idCategory.ID_category).SingleOrDefault <ProducerCats>(); if (validate != null) { MessageBox.Show("Уже існує"); return; } db.ProducerCats.Add(new ProducerCats { Id_producer = idProducer.ID_producer, Id_category = idCategory.ID_category }); db.SaveChanges(); MessageBox.Show("Додано"); FillListView(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void but_confirm_Click(object sender, EventArgs e) { if (text_amount.Text == "" || text_name.Text == "") { MessageBox.Show("Заповніть всі поля!!!"); } else { // MessageBox.Show(combo_category.Text + " " + combo_producer.Text + " " + text_name.Text + " " + text_amount.Text + " " + numeric_datedie.Value); SilpoDBEntities db = new SilpoDBEntities(); Product product = new Product() { Name = text_name.Text, Expiry_time = (int)numeric_datedie.Value, ID_category = db.Category.Where(x => x.Name == combo_category.Text).First().ID_category, ID_producer = db.Producer.Where(x => x.Name == combo_producer.Text).First().ID_producer }; db.Product.Add(product); db.SaveChanges(); MessageBox.Show(text_name.Text + " Додано"); this.DialogResult = DialogResult.OK; this.Close(); } }
private void button_add_Click(object sender, EventArgs e) { foreach (var i in db.ShopBank) { balace = i.Balance.ToString(); } balace = (Double.Parse(balace) + Double.Parse(textBox_add.Text)).ToString(); foreach (var i in db.ShopBank) { i.Balance = Int32.Parse(balace); } db.SaveChanges(); listView_Balance.Items.Clear(); Thread th = new Thread(new ThreadStart(FillDB)); th.Start(); }
private void but_delete_Click(object sender, EventArgs e) { foreach (ListViewItem itm in listView_supply.SelectedItems) { if (itm.Selected) { int id = Int32.Parse(itm.Text); db.Supply.Remove(db.Supply.Where(a => a.ID_supply == id).First()); } } db.SaveChanges(); listView_supply.Items.Clear(); FillDB(); }
private void button_del_Click(object sender, ListViewItemSelectionChangedEventArgs e) { int i = Convert.ToInt32(listView1.FocusedItem.Index); //видаленя з ліста int id = Convert.ToInt32(listView1.FocusedItem.Text); //видалення з бд var del = db.Discount.Where(d => d.Id_discount == id).FirstOrDefault(); if (e.IsSelected) { string message = "Видалити?"; string caption = "Видалення"; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result; result = MessageBox.Show(message, caption, buttons); if (result == System.Windows.Forms.DialogResult.Yes) { listView1.Items.RemoveAt(i); db.Discount.Remove(del); db.SaveChanges(); } } }
private void but_ok_Click(object sender, EventArgs e) { SilpoDBEntities db = new SilpoDBEntities(); int id = db.Product.Where(x => x.Name == combo_prod.Text).First().ID_product; Supply supply = new Supply() { Id_product = id, Price = numeric_price.Value, MarkUp = (int)numeric_markup.Value, Amount = (int)numeric_amount.Value, Date_made = dateTime_made.Value, Date_supply = dateTime_supply.Value }; db.Supply.Add(supply); db.SaveChanges(); DateTime dt = dateTime_made.Value; double days = (double)db.Product.Where(x => x.ID_product == id).First().Expiry_time; Storage storage = new Storage() { Id_product = id, id_supply = db.Supply.ToList().Last().ID_supply, Available_items = (int)numeric_amount.Value, FinalDate = dt.AddDays(days) }; db.Storage.Add(storage); db.SaveChanges(); double price_product = (double)(numeric_price.Value + ((numeric_price.Value * numeric_markup.Value) / 100)); foreach (var i in db.Prices) { if (id == i.idProduct) { pr = true; } } if (pr == false) { Prices price = new Prices() { idProduct = id, Price = (decimal)price_product, Date = DateTime.Now, }; db.Prices.Add(price); db.SaveChanges(); } else { // var prs = db.Prices.Where(x => x.idProduct == id).ToArray().Last(); Prices last_prc = db.Prices.Where(x => x.idProduct == id).ToArray().Last(); if (price_product != (double)last_prc.Price) { Prices price = new Prices() { idProduct = id, Price = (decimal)price_product, Date = DateTime.Now, }; db.Prices.Add(price); db.SaveChanges(); } else { MessageBox.Show("Ціна не змінилась"); } } this.Hide(); }