private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { Company_ProjectEntities company_Project = new Company_ProjectEntities(); try { int itmID = int.Parse(textBox1.Text); var st = (from i in company_Project.Storages where i.name == comboBox1.Text select i).First(); var check = (from q in company_Project.Storage_item where q.Item_ID == itmID && q.Storage_ID == st.ID_storage select q).First(); string manf = dateTimePicker1.Value.ToShortDateString(); string exp = dateTimePicker2.Value.ToShortDateString(); var itNAme = (from i in company_Project.items where i.name == comboBox2.Text && i.size == textBox3.Text && i.ManifuctureDate == manf && i.expireDate == exp select i).First(); textBox4.Text = check.amount.ToString(); New_btn.Enabled = false; Update_btn.Enabled = true; Delete_btn.Enabled = true; } catch { textBox4.Text = ""; New_btn.Enabled = true; Update_btn.Enabled = false; Delete_btn.Enabled = false; } }
private void comboBox4_SelectedIndexChanged(object sender, EventArgs e) { Company_ProjectEntities company_Project = new Company_ProjectEntities(); var item = (from i in company_Project.items where i.name == comboBox4.Text select i).First(); textBox2.Text = item.ID_item.ToString(); }
private void Save_Recipt_Click(object sender, EventArgs e) { Company_ProjectEntities company_Project = new Company_ProjectEntities(); /*List<String> quantity = new List<String>(); * List<String> productname = new List<String>(); * List<String> Manfdate = new List<String>(); * List<String> expDate = new List<String>(); */ for (int a = 0; a < dt.Rows.Count; a++) { Transport_items tran = new Transport_items(); tran.Transaction_ID = int.Parse(textBox1.Text); tran.From_Storage = comboBox1.Text; tran.To_Storage = comboBox4.Text; tran.Product_Name = dt.Rows[a][2].ToString(); if (listBox1.SelectedItem == null) { MessageBox.Show("select supplier"); break; } else { tran.supplier_Name = listBox1.SelectedItem.ToString(); } tran.amount = dt.Rows[a][3].ToString(); tran.TransactionDate = dateTimePicker1.Value.ToShortDateString(); company_Project.Transport_items.Add(tran); company_Project.SaveChanges(); string qq = dt.Rows[a][2].ToString(); var it = (from i in company_Project.items where i.name == qq select i).First(); var st_from = (from i in company_Project.Storages where i.name == comboBox1.Text select i).First(); var st_to = (from i in company_Project.Storages where i.name == comboBox4.Text select i).First(); var check = (from q in company_Project.Storage_item where q.Item_ID == it.ID_item && q.Storage_ID == st_from.ID_storage select q).First(); check.amount -= int.Parse(dt.Rows[a][3].ToString()); var check2 = (from q in company_Project.Storage_item where q.Item_ID == it.ID_item && q.Storage_ID == st_to.ID_storage select q).First(); check2.amount += int.Parse(dt.Rows[a][3].ToString()); company_Project.SaveChanges(); /*quantity.Add(dt.Rows[a][3].ToString()); * productname.Add(dt.Rows[a][2].ToString()); * Manfdate.Add(dt.Rows[a][4].ToString()); * expDate.Add(dt.Rows[a][5].ToString());*/ } /*string quantity_output = string.Join(", ", quantity); * string productname_output = string.Join(", ", productname); * string Manfdate_output = string.Join(", ", Manfdate); * string expDate_output = string.Join(", ", expDate);*/ MessageBox.Show("items added"); }
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { Company_ProjectEntities company_Project = new Company_ProjectEntities(); var item = (from i in company_Project.items where i.name == comboBox2.Text select i).First(); textBox2.Text = item.ID_item.ToString(); dateTimePicker2.Value = DateTime.Parse(item.ManifuctureDate); dateTimePicker3.Value = DateTime.Parse(item.expireDate); }
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { Company_ProjectEntities company_Project = new Company_ProjectEntities(); var check = (from q in company_Project.items where q.name == comboBox2.Text select q).First(); textBox1.Text = check.ID_item.ToString(); textBox3.Text = check.size; dateTimePicker1.Value = DateTime.Parse(check.ManifuctureDate); dateTimePicker2.Value = DateTime.Parse(check.expireDate); }
private void comboBox1_showList() { comboBox1.Items.Clear(); Company_ProjectEntities company_Project = new Company_ProjectEntities(); var name = from names in company_Project.Customers_Suppliers select names; foreach (var items in name) { comboBox1.Items.Add(items.name); } }
public Storages_Report() { InitializeComponent(); Company_ProjectEntities company_Project = new Company_ProjectEntities(); var stroge = from s in company_Project.Storages select s; comboBox1.Items.Add("==All=="); foreach (var items in stroge) { comboBox1.Items.Add(items.name); } }
private void Delete_cust_Click(object sender, EventArgs e) { Company_ProjectEntities company_Project = new Company_ProjectEntities(); var CS = (from names in company_Project.Customers_Suppliers where names.ID == textBox1.Text select names).First(); company_Project.Customers_Suppliers.Remove(CS); company_Project.SaveChanges(); MessageBox.Show($"{comboBox1.Text} Updated"); EmptyForm(); }
private void Delete_btn_Click(object sender, EventArgs e) { Company_ProjectEntities company_Project = new Company_ProjectEntities(); int combo_id = int.Parse(comboBox1.Text); var str = (from s in company_Project.Storages where s.ID_storage == combo_id select s).First(); company_Project.Storages.Remove(str); company_Project.SaveChanges(); MessageBox.Show($"{textBox2.Text} Deleted."); EmptyForm(); comboBox_showList(); }
private void Delete_btn_Click(object sender, EventArgs e) { Company_ProjectEntities company_Project = new Company_ProjectEntities(); int itmID = int.Parse(textBox1.Text); var st = (from i in company_Project.Storages where i.name == comboBox1.Text select i).First(); var check = (from q in company_Project.Storage_item where q.Item_ID == itmID && q.Storage_ID == st.ID_storage select q).First(); company_Project.Storage_item.Remove(check); var it = (from i in company_Project.items where i.ID_item == itmID select i).First(); company_Project.items.Remove(it); company_Project.SaveChanges(); MessageBox.Show("item deleted"); }
private void showList() { comboBox1.Items.Clear(); Company_ProjectEntities company_Project = new Company_ProjectEntities(); var stroge = from s in company_Project.Storages select s; foreach (var items in stroge) { comboBox1.Items.Add(items.name); } var sup = from e in company_Project.Customers_Suppliers where e.type == "Cus" select e; foreach (var i in sup) { listBox1.Items.Add(i.name); } }
private void comboBox_showList() { comboBox1.Items.Clear(); comboBox2.Items.Clear(); Company_ProjectEntities company_Project = new Company_ProjectEntities(); var stroge = from s in company_Project.Storages select s; foreach (var items in stroge) { comboBox1.Items.Add(items.ID_storage); } var name = from names in company_Project.Emloyees select names; foreach (var items in name) { comboBox2.Items.Add(items.name); } }
private void Delete_Recipt_Click(object sender, EventArgs e) { dataGridView1.Rows.Clear(); Company_ProjectEntities company_Project = new Company_ProjectEntities(); try { var item = (from i in company_Project.items where i.name == comboBox2.Text select i).First(); var st = (from i in company_Project.Storages where i.name == comboBox1.Text select i).First(); var amount = (from q in company_Project.Storage_item where q.Item_ID == item.ID_item && q.Storage_ID == st.ID_storage select q).First(); textBox4.Text = amount.amount.ToString(); } catch { MessageBox.Show("no item selected"); } }
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { Company_ProjectEntities company_Project = new Company_ProjectEntities(); var item = (from i in company_Project.items where i.name == comboBox2.Text select i).First(); textBox2.Text = item.ID_item.ToString(); dateTimePicker2.Value = DateTime.Parse(item.ManifuctureDate); dateTimePicker3.Value = DateTime.Parse(item.expireDate); var st = (from i in company_Project.Storages where i.name == comboBox1.Text select i).First(); var amount = (from q in company_Project.Storage_item where q.Item_ID == item.ID_item && q.Storage_ID == st.ID_storage select q).First(); textBox4.Text = amount.amount.ToString(); }
private void comboBox_showList() { comboBox1.Items.Clear(); Company_ProjectEntities company_Project = new Company_ProjectEntities(); var stroge = from s in company_Project.Storages select s; foreach (var items in stroge) { comboBox1.Items.Add(items.name); } var item = from i in company_Project.items select i; foreach (var items in item) { comboBox2.Items.Add(items.name); } }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { comboBox4.Items.Clear(); comboBox1.Enabled = false; Company_ProjectEntities company_Project = new Company_ProjectEntities(); var st = (from i in company_Project.Storages where i.name == comboBox1.Text select i).First(); var itemID = from i in company_Project.Storage_item where i.Storage_ID == st.ID_storage select i; foreach (var items in itemID) { var item = (from i in company_Project.items where i.ID_item == items.Item_ID select i).First(); comboBox4.Items.Add(item.name); } }
private void Update_btn_Click(object sender, EventArgs e) { Company_ProjectEntities company_Project = new Company_ProjectEntities(); int combo_id = int.Parse(comboBox1.Text); var str = (from s in company_Project.Storages where s.ID_storage == combo_id select s).First(); str.name = textBox2.Text; str.Phone = int.Parse(textBox1.Text); str.location = textBox4.Text; str.Comment = textBox6.Text; var CS = (from names in company_Project.Emloyees where names.ID_Emp == str.Manger_ID select names).First(); comboBox2.Text = str.name; company_Project.SaveChanges(); MessageBox.Show($"{str.name} Updated"); EmptyForm(); Update_btn.Enabled = false; }
private void button1_Click(object sender, EventArgs e)//search { Company_ProjectEntities company_Project = new Company_ProjectEntities(); if (comboBox1.Text == "==All==") { var stroge = from s in company_Project.Storages select s; dataGridView1.DataSource = stroge.ToList(); } else { var stroge = from s in company_Project.Storages where s.name == comboBox1.Text select s; dataGridView1.DataSource = stroge.ToList(); } if (comboBox1.Text == "==All==") { var stroge1 = from s in company_Project.Storages select s; foreach (var i in stroge1) { var it_in_st = from s in company_Project.Storage_item where s.Storage_ID == i.ID_storage select s; foreach (var ie in it_in_st) { var it = from s in company_Project.items where s.ID_item == s.ID_item select s; dataGridView2.DataSource = it.ToList(); } } } else { var stroge1 = (from s in company_Project.Storages where s.name == comboBox1.Text select s).First(); var it_in_st = from s in company_Project.Storage_item where s.Storage_ID == stroge1.ID_storage select s; foreach (var i in it_in_st) { var it = from s in company_Project.items where s.ID_item == s.ID_item select s; dataGridView2.DataSource = it.ToList(); } } }
private void login_Click(object sender, EventArgs e) { Company_ProjectEntities company_Project = new Company_ProjectEntities(); Emloyee emp = (from q in company_Project.Emloyees select q).First(); if (emp.name == textBox1.Text && emp.Password == int.Parse(textBox2.Text)) { string Username = textBox1.Text; MainBody mainBody = new MainBody(button1.Text, Username); this.Hide(); mainBody.ShowDialog(); this.Show(); } else { MessageBox.Show("Wrong Username & PAssword"); } }
private void Search_Click(object sender, EventArgs e) { Update_btn.Enabled = true; Company_ProjectEntities company_Project = new Company_ProjectEntities(); int _ID = int.Parse(comboBox1.SelectedItem.ToString()); var str = (from s in company_Project.Storages where s.ID_storage == _ID select s).First(); textBox1.Text = str.Phone.ToString(); textBox2.Text = str.name; textBox4.Text = str.location; textBox6.Text = str.Comment; var CS = (from names in company_Project.Emloyees where names.ID_Emp == str.Manger_ID select names).First(); comboBox2.Text = CS.name; }
private void Update_btn_Click(object sender, EventArgs e) { Company_ProjectEntities company_Project = new Company_ProjectEntities(); int itmID = int.Parse(textBox1.Text); var it = (from i in company_Project.items where i.ID_item == itmID select i).First(); it.name = comboBox2.Text; it.size = textBox3.Text; it.expireDate = dateTimePicker2.Value.ToShortDateString(); it.ManifuctureDate = dateTimePicker1.Value.ToShortDateString(); var st = (from i in company_Project.Storages where i.name == comboBox1.Text select i).First(); var check = (from q in company_Project.Storage_item where q.Item_ID == itmID && q.Storage_ID == st.ID_storage select q).First(); check.amount = int.Parse(textBox4.Text); company_Project.SaveChanges(); MessageBox.Show($"{it.name} Updated"); }
private void Update_cust_Click(object sender, EventArgs e) { Company_ProjectEntities company_Project = new Company_ProjectEntities(); var CS = (from names in company_Project.Customers_Suppliers where names.ID == textBox1.Text select names).First(); CS.name = comboBox1.Text; CS.type = con_ID; CS.BirthDate = dateTimePicker1.Value.ToShortDateString(); CS.phone = int.Parse(textBox4.Text); CS.mobile = int.Parse(textBox5.Text); CS.fax = int.Parse(textBox6.Text); CS.Mail = textBox7.Text; CS.website = textBox2.Text; CS.Location = textBox3.Text; CS.Comments = textBox8.Text; company_Project.SaveChanges(); MessageBox.Show($"{CS.name} Updated"); EmptyForm(); }
private void New_cust_Click(object sender, EventArgs e) { Customers_Suppliers CS = new Customers_Suppliers(); check_radio(); Random rnd = new Random(); textBox1.Text = rnd.Next().ToString(); if (con_ID == null) { MessageBox.Show("please select the Radiobutton"); } else { CS.ID = con_ID + "-" + textBox1.Text; CS.name = comboBox1.Text; CS.type = con_ID; CS.BirthDate = dateTimePicker1.Value.ToShortDateString(); CS.phone = int.Parse(textBox4.Text); CS.mobile = int.Parse(textBox5.Text); CS.fax = int.Parse(textBox6.Text); CS.Mail = textBox7.Text; CS.website = textBox2.Text; CS.Location = textBox3.Text; CS.Comments = textBox8.Text; if (CS.name == null) { MessageBox.Show("name is empty"); } else { Company_ProjectEntities company_Project = new Company_ProjectEntities(); company_Project.Customers_Suppliers.Add(CS); company_Project.SaveChanges(); MessageBox.Show($"New {CS.type} Added"); } } EmptyForm(); comboBox1_showList(); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { Company_ProjectEntities company_Project = new Company_ProjectEntities(); textBox1.Text = textBox2.Text = textBox3.Text = textBox4.Text = textBox5.Text = textBox6.Text = textBox7.Text = textBox8.Text = String.Empty; var name = (from names in company_Project.Customers_Suppliers where names.name == comboBox1.SelectedItem.ToString() select names).First(); textBox1.Text = name.ID; textBox2.Text = name.website; textBox3.Text = name.Location; textBox4.Text = name.phone.ToString(); textBox5.Text = name.mobile.ToString(); textBox6.Text = name.fax.ToString(); textBox7.Text = name.Mail; textBox8.Text = name.Comments; dateTimePicker1.Value = DateTime.Parse(name.BirthDate); if (name.type == "Sup") { radioButton1.Checked = true; radioButton2.Checked = false; con_ID = "Sup"; } else if (name.type == "Cus") { radioButton1.Checked = false; radioButton2.Checked = true; con_ID = "Cus"; } }
private void New_Click(object sender, EventArgs e) { Company_ProjectEntities company_Project = new Company_ProjectEntities(); Storage storage = new Storage(); Random rnd = new Random(); comboBox1.Text = rnd.Next().ToString(); storage.ID_storage = int.Parse(comboBox1.Text); storage.name = textBox2.Text; storage.location = textBox4.Text; storage.Comment = textBox6.Text; storage.Phone = int.Parse(textBox1.Text); var CS = (from names in company_Project.Emloyees where names.name == comboBox2.Text select names).First(); try { var str_checl = (from s in company_Project.Storages where s.Manger_ID == CS.ID_Emp select s).First(); var str = (from s in company_Project.Storages where s.Manger_ID == CS.ID_Emp select s).First(); MessageBox.Show($"Sorry this employee manage {str.name}"); } catch { storage.Manger_ID = CS.ID_Emp; company_Project.Storages.Add(storage); company_Project.SaveChanges(); MessageBox.Show($"New {storage.name} Added"); EmptyForm(); comboBox_showList(); } }
private void Save_Recipt_Click(object sender, EventArgs e) { Company_ProjectEntities company_Project = new Company_ProjectEntities(); for (int a = 0; a < dt.Rows.Count; a++) { Permission per = new Permission(); per.permission_ID = int.Parse(textBox1.Text); per.typePermission = "rec"; per.Date_permission = dateTimePicker1.Value.ToShortDateString(); string st_name = dt.Rows[a][0].ToString(); var st = (from i in company_Project.Storages where i.name == st_name select i).First(); per.stroage_id = st.ID_storage; string it_name = dt.Rows[a][1].ToString(); var it = (from i in company_Project.items where i.name == it_name select i).First(); per.item_id = it.ID_item; per.amount_item = int.Parse(dt.Rows[a][2].ToString()); if (listBox1.SelectedItem == null) { MessageBox.Show("select supplier"); break; } else { string newper = listBox1.SelectedItem.ToString(); var sup = (from q in company_Project.Customers_Suppliers where q.name == newper && q.type == "Sup" select q).First(); per.name_id = sup.ID; } per.expireDate = dateTimePicker4.Value.ToShortDateString(); per.Comment = textBox4.Text; company_Project.Permissions.Add(per); company_Project.SaveChanges(); try { var check = (from i in company_Project.Storage_item where i.Storage_ID == st.ID_storage && i.Item_ID == it.ID_item select i).First(); check.amount += int.Parse(dt.Rows[a][2].ToString()); } catch { Storage_item st_it = new Storage_item(); st_it.Storage_ID = st.ID_storage; st_it.Item_ID = it.ID_item; st_it.amount = int.Parse(dt.Rows[a][2].ToString()); company_Project.Storage_item.Add(st_it); } company_Project.SaveChanges(); } MessageBox.Show("items added"); }
private void New_Click(object sender, EventArgs e) { Company_ProjectEntities company_Project = new Company_ProjectEntities(); try { string manf = dateTimePicker1.Value.ToShortDateString(); string exp = dateTimePicker2.Value.ToShortDateString(); var itNAme = (from i in company_Project.items where i.name == comboBox2.Text && i.size == textBox3.Text && i.ManifuctureDate == manf && i.expireDate == exp select i).First(); Storage_item si = new Storage_item(); si.amount = int.Parse(textBox4.Text); si.Item_ID = int.Parse(textBox1.Text); var st = (from i in company_Project.Storages where i.name == comboBox1.Text select i).First(); si.Storage_ID = st.ID_storage; company_Project.Storage_item.Add(si); company_Project.SaveChanges(); MessageBox.Show($"New {comboBox2.Text} added in {comboBox1.Text}."); } catch { item it = new item(); Random rnd = new Random(); textBox1.Text = rnd.Next().ToString(); it.ID_item = int.Parse(textBox1.Text); try { var itNAme = (from i in company_Project.items where i.name == comboBox2.Text select i).First(); MessageBox.Show("this name is exist."); } catch { it.name = comboBox2.Text; it.size = textBox3.Text; it.ManifuctureDate = dateTimePicker1.Value.ToShortDateString(); it.expireDate = dateTimePicker2.Value.ToShortDateString(); Storage_item si = new Storage_item(); if (textBox4.Text == String.Empty) { MessageBox.Show("item have to have ammount"); } else { si.amount = int.Parse(textBox4.Text); } si.Item_ID = int.Parse(textBox1.Text); var st = (from i in company_Project.Storages where i.name == comboBox1.Text select i).First(); si.Storage_ID = st.ID_storage; company_Project.Storage_item.Add(si); company_Project.items.Add(it); company_Project.SaveChanges(); MessageBox.Show($"New {comboBox2.Text} added in {comboBox1.Text}."); } } }
private void Save_Recipt_Click(object sender, EventArgs e) { Company_ProjectEntities company_Project = new Company_ProjectEntities(); for (int a = 0; a < dt.Rows.Count; a++) { Client cl = new Client(); cl.Recipt_ID = int.Parse(textBox1.Text); cl.date = dateTimePicker1.Value.ToShortDateString(); string st_name = comboBox1.Text; var st = (from i in company_Project.Storages where i.name == st_name select i).First(); cl.storage_id = st.ID_storage; string it_name = dt.Rows[a][0].ToString(); var it = (from i in company_Project.items where i.name == it_name select i).First(); cl.item_id = it.ID_item; cl.amount = int.Parse(dt.Rows[a][1].ToString()); if (listBox1.SelectedItem == null) { MessageBox.Show("select supplier"); break; } else { string newper = listBox1.SelectedItem.ToString(); var sup = (from q in company_Project.Customers_Suppliers where q.name == newper && q.type == "Cus" select q).First(); cl.custumer_id = sup.ID; } cl.selling_Price = float.Parse(dt.Rows[a][2].ToString()); cl.Tax = float.Parse(textBox5.Text); var check = (from i in company_Project.Storage_item where i.Storage_ID == st.ID_storage && i.Item_ID == it.ID_item select i).First(); if (check.amount > int.Parse(dt.Rows[a][1].ToString())) { check.amount -= int.Parse(dt.Rows[a][1].ToString()); company_Project.Clients.Add(cl); company_Project.SaveChanges(); } else { MessageBox.Show($"{dt.Rows[a][0]} can't sell it because the amount in store is less than you selling \namount in store: {check.amount} "); } } try { int trans = int.Parse(textBox1.Text); var check_trans = (from i in company_Project.Clients where i.Recipt_ID == trans select i).First(); MessageBox.Show($"items Sold with transaction: {textBox1.Text} ."); newForm(); } catch { } }