private void button1_Click(object sender, EventArgs e) { bool found = false; Data data = new Data(); PharmacyData db = new PharmacyData(); IQueryable <Medicament> medsList = from b in db.Medicaments orderby b.Id select b; List <Medicament> medicaments = medsList.ToList(); foreach (Medicament medicament in medicaments) { if (medicament.MedName == "Algocalmin" && medicament.MedQuantity > 0) { Data.AlgocalminQuantity++; //medicament.MedQuantity--; found = true; //db.SaveChanges(); } } if (found == false) { this.Hide(); Form notFound = new MedicamentInsuficient(); notFound.Show(); } else { this.Hide(); Form bought = new ProductBought(); bought.Show(); } }
private void loginButton_Click(object sender, EventArgs e) { bool logged = false; PharmacyData db = new PharmacyData(); IQueryable <TbUser> tbUsersList = from b in db.TbUsers orderby b.Id select b; List <TbUser> tbUsers = tbUsersList.ToList(); foreach (TbUser tbUser in tbUsers) { if (tbUser.Username == usernameBox.Text && !string.IsNullOrWhiteSpace(usernameBox.Text)) { if (tbUser.Password == passwordBox.Text && !string.IsNullOrWhiteSpace(passwordBox.Text)) { this.Hide(); Form MainForm = new MainForm(Convert.ToString(usernameBox.Text)); MainForm.Show(); logged = true; } } } if (logged == false) { this.Hide(); Form LoginError = new LoginError(); LoginError.Show(); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); var db = new PharmacyData(); }
private void searchButton_Click(object sender, EventArgs e) { if (numeMedicamentBox.Text != null && numeOrasBox.Text != null && !string.IsNullOrWhiteSpace(numeMedicamentBox.Text) && !string.IsNullOrWhiteSpace(numeOrasBox.Text)) { PharmacyData db = new PharmacyData(); IQueryable <Medicament> medsList = from b in db.Medicaments orderby b.Id select b; List <Medicament> medicaments = medsList.ToList(); foreach (Medicament medicament in medicaments) { if (medicament.MedName == numeMedicamentBox.Text) { if (medicament.MedName == "Paracetamol" && numeOrasBox.Text == "Cluj") { this.Hide(); Form paracetamol = new Paracetamol(); paracetamol.Show(); } else if (medicament.MedName == "Vitamine" && numeOrasBox.Text == "Timisoara") { this.Hide(); Form vitamine = new Vitamine(); vitamine.Show(); } else if (medicament.MedName == "Algocalmin" && numeOrasBox.Text == "Brasov") { this.Hide(); Form algocalmin = new Algocalmin(); algocalmin.Show(); } else if (medicament.MedName == "Coldrex" && numeOrasBox.Text == "Bucuresti") { this.Hide(); Form coldrex = new Coldrex(); coldrex.Show(); } else { this.Hide(); Form notFound = new MedNotFound(); notFound.Show(); } } } } }
private void button3_Click(object sender, EventArgs e) { PharmacyData db = new PharmacyData(); IQueryable <Medicament> medsList = from b in db.Medicaments orderby b.Id select b; List <Medicament> medicaments = medsList.ToList(); foreach (Medicament medicament in medicaments) { if (medicament.MedName == "Paracetamol") { medicament.MedQuantity = medicament.MedQuantity - Data.ParacetamolQuantity; } if (medicament.MedName == "Algocalmin") { medicament.MedQuantity = medicament.MedQuantity - Data.AlgocalminQuantity; } if (medicament.MedName == "Coldrex") { medicament.MedQuantity = medicament.MedQuantity - Data.ColdrexQuantity; } if (medicament.MedName == "Vitamine") { medicament.MedQuantity = medicament.MedQuantity - Data.VitamineQuantity; } } db.SaveChanges(); Data.ParacetamolQuantity = 0; Data.AlgocalminQuantity = 0; Data.ColdrexQuantity = 0; Data.VitamineQuantity = 0; this.Hide(); Form comanda = new ComandaFinalizata(); comanda.Show(); }
private void registerButton_Click(object sender, EventArgs e) { /*if (usernameBox.Text != null && passwordBox.Text != null && confirmPasswordBox.Text != null &&!string.IsNullOrWhiteSpace(usernameBox.Text) && !string.IsNullOrWhiteSpace(passwordBox.Text)) * { * if (passwordBox.Text == confirmPasswordBox.Text && passwordBox.Text != null && !string.IsNullOrWhiteSpace(passwordBox.Text)) * { * /*var db = new PharmacyData(); * TbUser tbUser = new TbUser(); * tbUser.Username = usernameBox.Text; * tbUser.Password = passwordBox.Text; * db.TbUsers.Add(tbUser); * db.SaveChanges(); * PharmacyData db = new PharmacyData(); * IQueryable<TbUser> tbUsersList = from b in db.TbUsers * orderby b.Id * select b; * List<TbUser> tbUsers = tbUsersList.ToList(); * * foreach (TbUser tbUser in tbUsers) * { * if (tbUser.Username == usernameBox.Text && !string.IsNullOrWhiteSpace(usernameBox.Text)) * { * if (tbUser.Password == passwordBox.Text && !string.IsNullOrWhiteSpace(passwordBox.Text)) * { * * } * } * } * } * }*/ bool found = false; if (usernameBox.Text != null && passwordBox.Text != null && confirmPasswordBox.Text != null && !string.IsNullOrWhiteSpace(usernameBox.Text) && !string.IsNullOrWhiteSpace(passwordBox.Text)) { PharmacyData db = new PharmacyData(); IQueryable <TbUser> tbUsersList = from b in db.TbUsers orderby b.Id select b; List <TbUser> tbUsers = tbUsersList.ToList(); foreach (TbUser tbUser in tbUsers) { if (tbUser.Username == usernameBox.Text && !string.IsNullOrWhiteSpace(usernameBox.Text)) { found = true; MessageBox.Show("User already exists!"); } } } if (found == false) { if (passwordBox.Text == confirmPasswordBox.Text && passwordBox.Text != null && !string.IsNullOrWhiteSpace(passwordBox.Text)) { var db = new PharmacyData(); TbUser tbUser = new TbUser(); tbUser.Username = usernameBox.Text; tbUser.Password = passwordBox.Text; db.TbUsers.Add(tbUser); db.SaveChanges(); } } }