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 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 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 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 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++) { 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 { } }
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++) { 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"); }