Esempio n. 1
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");
         }
     }
 }
Esempio n. 2
0
 private void Product_Click(object sender, EventArgs e)
 {
     using (EntityModel db = new EntityModel())
     {
         listView3.Items.Clear();
         panel1.Visible = true;
         panel2.Visible = true;
         panel3.Visible = true;
         ListViewItem list;
         int          id      = 0;
         var          tapilan = db.products.ToList().Where(x => x.User_id == user).ToList();
         foreach (var item in tapilan)
         {
             id++;
             list = new ListViewItem(id.ToString());
             list.SubItems.Add(item.Name);
             list.SubItems.Add(item.Price);
             list.SubItems.Add(item.Quantity.ToString());
             list.SubItems.Add(item.Description);
             listView3.Items.Add(list);
         }
     }
 }
Esempio n. 3
0
 private void Custom_Click(object sender, EventArgs e)
 {
     using (EntityModel db = new EntityModel())
     {
         listView1.Items.Clear();
         panel1.Visible = true;
         panel2.Visible = false;
         panel3.Visible = false;
         ListViewItem list;
         int          id      = 0;
         var          tapilan = db.customs.ToList().Where(x => x.User_id == user).ToList();
         foreach (var item in tapilan)
         {
             id++;
             list = new ListViewItem(id.ToString());
             list.SubItems.Add(item.Name);
             list.SubItems.Add(item.Surname);
             list.SubItems.Add(item.Email);
             list.SubItems.Add(item.Phone);
             list.SubItems.Add(item.Address);
             listView1.Items.Add(list);
         }
     }
 }
Esempio n. 4
0
 private void Order_Click(object sender, EventArgs e)
 {
     using (EntityModel db = new EntityModel())
     {
         listView2.Items.Clear();
         panel1.Visible = true;
         panel2.Visible = true;
         panel3.Visible = false;
         ListViewItem list;
         int          id      = 0;
         var          tapilan = db.orders.ToList().Where(x => x.User_id == user).ToList().ToList();
         foreach (var item in tapilan)
         {
             id++;
             list = new ListViewItem(id.ToString());
             list.SubItems.Add(item.Client_id.Name);
             list.SubItems.Add(item.Product_id.Name);
             list.SubItems.Add(item.Quantity.ToString());
             list.SubItems.Add(item.OrderTime.ToString());
             list.SubItems.Add(item.Arrive.ToString());
             if (DateTime.Now > item.Arrive)
             {
                 list.SubItems.Add("Ended");
             }
             else if (DateTime.Now < item.Arrive)
             {
                 list.SubItems.Add("Waiting");
             }
             else if (DateTime.Now == item.Arrive)
             {
                 list.SubItems.Add("Sending");
             }
             listView2.Items.Add(list);
         }
     }
 }
Esempio n. 5
0
 private void comboBox1_TextChanged(object sender, EventArgs e)
 {
     using (EntityModel db = new EntityModel())
     {
         comboBox2.Items.Clear();
         var prod = db.products.ToList().Where(x => x.User_id == Form1.user);
         foreach (var item in prod)
         {
             if (item.Quantity > 0)
             {
                 comboBox2.Items.Add(item.Name);
             }
         }
         if (comboBox1.SelectedIndex < 1)
         {
             errorProvider1.SetError(comboBox1, "Client is empty");
         }
         else
         {
             errorProvider1.Clear();
         }
         if (comboBox2.SelectedIndex < 1)
         {
             errorProvider1.SetError(comboBox2, "Product is empty");
         }
         else
         {
             errorProvider1.Clear();
         }
         if (comboBox1.SelectedItem != null && comboBox2.SelectedItem != null)
         {
             errorProvider1.Clear();
             button1.Enabled = true;
         }
     }
 }
Esempio n. 6
0
 private void textBox1_TextChanged(object sender, EventArgs e)
 {
     if (panel1.Visible == true && panel2.Visible == false && panel3.Visible == false)
     {
         using (EntityModel db = new EntityModel())
         {
             ListViewItem list;
             int          id = 0;
             listView1.Items.Clear();
             if (textBox1.Text == "")
             {
                 var tapilan = db.customs.ToList().Where(x => x.User_id == user).ToList();
                 foreach (var item in tapilan)
                 {
                     id++;
                     list = new ListViewItem(id.ToString());
                     list.SubItems.Add(item.Name);
                     list.SubItems.Add(item.Surname);
                     list.SubItems.Add(item.Email);
                     list.SubItems.Add(item.Phone);
                     list.SubItems.Add(item.Address);
                     listView1.Items.Add(list);
                 }
             }
             else
             {
                 var tapilan = db.customs.ToList().Where(x => (x.Id.ToString().Contains(textBox1.Text) ||
                                                               x.Name.Contains(textBox1.Text) ||
                                                               x.Surname.Contains(textBox1.Text) ||
                                                               x.Phone.Contains(textBox1.Text) ||
                                                               x.Email.Contains(textBox1.Text) ||
                                                               x.Address.Contains(textBox1.Text)) &&
                                                         x.User_id == user
                                                         ).ToList();
                 foreach (var item in tapilan)
                 {
                     id++;
                     list = new ListViewItem(id.ToString());
                     list.SubItems.Add(item.Name);
                     list.SubItems.Add(item.Surname);
                     list.SubItems.Add(item.Email);
                     list.SubItems.Add(item.Phone);
                     list.SubItems.Add(item.Address);
                     listView1.Items.Add(list);
                 }
             }
         }
     }
     else if (panel1.Visible == true && panel2.Visible == true && panel3.Visible == false)
     {
         using (EntityModel db = new EntityModel())
         {
             ListViewItem list;
             int          id = 0;
             listView2.Items.Clear();
             if (textBox1.Text == "")
             {
                 var tapilan = db.orders.ToList().Where(x => x.User_id == user).ToList();
                 foreach (var item in tapilan)
                 {
                     id++;
                     list = new ListViewItem(id.ToString());
                     list.SubItems.Add(item.Client_id.Name);
                     list.SubItems.Add(item.Product_id.Name);
                     list.SubItems.Add(item.Quantity.ToString());
                     list.SubItems.Add(item.OrderTime.ToString());
                     list.SubItems.Add(item.Arrive.ToString());
                     if (DateTime.Now > item.Arrive)
                     {
                         list.SubItems.Add("Ended");
                     }
                     else if (DateTime.Now < item.Arrive)
                     {
                         list.SubItems.Add("Waiting");
                     }
                     else if (DateTime.Now == item.Arrive)
                     {
                         list.SubItems.Add("Sending");
                     }
                     listView2.Items.Add(list);
                 }
             }
             else
             {
                 var tapilan = db.orders.ToList().Where(x => (x.Id.ToString().Contains(textBox1.Text) ||
                                                              x.Arrive.ToString().Contains(textBox1.Text) ||
                                                              x.Client_id.Name.Contains(textBox1.Text) ||
                                                              x.Product_id.Name.Contains(textBox1.Text) ||
                                                              x.OrderTime.ToString().Contains(textBox1.Text) ||
                                                              x.Quantity.ToString().Contains(textBox1.Text)) &&
                                                        x.User_id == user
                                                        ).ToList();
                 foreach (var item in tapilan)
                 {
                     id++;
                     list = new ListViewItem(id.ToString());
                     list.SubItems.Add(item.Client_id.Name);
                     list.SubItems.Add(item.Product_id.Name);
                     list.SubItems.Add(item.Quantity.ToString());
                     list.SubItems.Add(item.OrderTime.ToString());
                     list.SubItems.Add(item.Arrive.ToString());
                     if (DateTime.Now > item.Arrive)
                     {
                         list.SubItems.Add("Ended");
                     }
                     else if (DateTime.Now < item.Arrive)
                     {
                         list.SubItems.Add("Waiting");
                     }
                     else if (DateTime.Now == item.Arrive)
                     {
                         list.SubItems.Add("Sending");
                     }
                     listView2.Items.Add(list);
                 }
             }
         }
     }
     else if (panel1.Visible == true && panel2.Visible == true && panel3.Visible == true)
     {
         using (EntityModel db = new EntityModel())
         {
             ListViewItem list;
             int          id = 0;
             listView3.Items.Clear();
             if (textBox1.Text == "")
             {
                 var tapilan = db.products.ToList().Where(x => x.User_id == user).ToList();
                 foreach (var item in tapilan)
                 {
                     id++;
                     list = new ListViewItem(id.ToString());
                     list.SubItems.Add(item.Name);
                     list.SubItems.Add(item.Price);
                     list.SubItems.Add(item.Quantity.ToString());
                     list.SubItems.Add(item.Description);
                     listView3.Items.Add(list);
                 }
             }
             else
             {
                 var tapilan = db.products.ToList().Where(x => (x.Id.ToString().Contains(textBox1.Text) ||
                                                                x.Name.Contains(textBox1.Text) ||
                                                                x.Description.Contains(textBox1.Text) ||
                                                                x.Quantity.ToString().Contains(textBox1.Text) ||
                                                                x.Price.Contains(textBox1.Text)) &&
                                                          x.User_id == user
                                                          ).ToList();
                 foreach (var item in tapilan)
                 {
                     id++;
                     list = new ListViewItem(id.ToString());
                     list.SubItems.Add(item.Name);
                     list.SubItems.Add(item.Price);
                     list.SubItems.Add(item.Quantity.ToString());
                     list.SubItems.Add(item.Description);
                     listView3.Items.Add(list);
                 }
             }
         }
     }
 }