Beispiel #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     using (EntityModel db = new EntityModel())
     {
         db.products.Add(new Prod()
         {
             Name = textBox1.Text, Price = textBox2.Text, Quantity = (int)numericUpDown1.Value, Description = richTextBox1.Text, User_id = Form1.user
         });
         db.SaveChanges();
         Close();
     }
 }
Beispiel #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     using (EntityModel db = new EntityModel())
     {
         db.customs.Add(new Custom()
         {
             Name = textBox1.Text, Surname = textBox2.Text, Email = textBox3.Text, Phone = maskedTextBox1.Text, Address = richTextBox1.Text, User_id = Form1.user
         });
         db.SaveChanges();
         Close();
     }
 }
Beispiel #3
0
 private void button1_Click(object sender, EventArgs e)
 {
     using (EntityModel db = new EntityModel())
     {
         string[] vs       = comboBox1.SelectedItem.ToString().Split(' ');
         var      prod     = db.products.ToList().FirstOrDefault(x => x.Name == comboBox2.SelectedItem.ToString());
         var      clientId = db.customs.ToList().FirstOrDefault(x => x.Name == vs[0]);
         db.orders.Add(new Orders()
         {
             Client_id = clientId, Product_id = prod, Quantity = (int)numericUpDown1.Value, Arrive = dateTimePicker1.Value, OrderTime = DateTime.Now, User_id = Form1.user
         });
         db.SaveChanges();
         prod.Quantity -= (int)numericUpDown1.Value;
         Close();
     }
 }
Beispiel #4
0
 private void Button1_Click(object sender, EventArgs e)
 {
     using (EntityModel db = new EntityModel())
     {
         var y = db.Users.ToList().Where(x => (x.UserName == textBox1.Text)).ToList();
         if (y.Count == 0)
         {
             User user1 = new User()
             {
                 UserName = textBox1.Text, Password = textBox2.Text, Name = textBox4.Text, Surname = textBox5.Text
             };
             db.Users.Add(user1);
             db.SaveChanges();
             Close();
         }
         else
         {
             MessageBox.Show("The user already exists");
         }
     }
 }