private async void btnSale_Click(object sender, EventArgs e) { DateTime date = DateTime.Today; decimal total = decimal.Parse(lbTotal.Text); Sale sale = new Sale() { Time = date, Total = total, EmployeeId = _userId }; foreach (LS_Drug item in lsbDrugList.Items) { sale.SellDrugs.Add(new SellDrug { SaleId = sale.Id, DrugId = item.Id, DrugCount = item.Count }); } _db.Sales.Add(sale); await _db.SaveChangesAsync(); DecreaseDrugCount(); MessageBox.Show("Kef ele"); }
private async void btnAdminDelete_Click(object sender, EventArgs e) { string email = txtAdminMail.Text.Trim(); Employee employee = _db.Employees.First(em => em.Email == email); employee.Deleted = true; await _db.SaveChangesAsync(); MessageBox.Show("Employee deleted"); FillDgv(); HideInput(); }
private async void btnCreateType_Click(object sender, EventArgs e) { string name = txtCreateTypeName.Text.Trim(); if (name == "") { MessageBox.Show("Fill all input", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (_db.DrugTypes.Any(t => t.Name.ToLower() == name.ToLower())) { MessageBox.Show($"{name} already exist", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } DrugType type = new DrugType() { Name = name }; _db.DrugTypes.Add(type); await _db.SaveChangesAsync(); MessageBox.Show($"Succussfully added", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); txtCreateTypeName.Text = ""; _cmb.Items.Clear(); _cmb.Items.AddRange(_db.DrugTypes.Select(t => new CB_DrugType { Id = t.Id, Name = t.Name }).ToArray()); }
private async void btnDeleteType_Click(object sender, EventArgs e) { int id = ((CB_DrugType)cmbDeleteType.SelectedItem).Id; DrugType type = _db.DrugTypes.First(t => t.Id == id); type.Deleted = false; //_db.DrugTypes.Remove(type); await _db.SaveChangesAsync(); MessageBox.Show("Successfully deleted"); FillCmb(cmbDeleteType); FillCmb(_cmb); }
private async void btnRegister_Click(object sender, EventArgs e) { string name = txtRegisterName.Text.Trim(); string email = txtRegisterEmail.Text.Trim(); string password = txtRegisterPass.Text.Trim(); if (name == "" || email == "" || password == "") { MessageBox.Show("Please fill all input!!!"); return; } if (!email.IsEmail()) { MessageBox.Show("Email is not valid!!!"); return; } if (_db.Employees.Any(em => em.Email == email)) { MessageBox.Show("Email allready exist!!!"); return; } string hashPassword = password.PassHash(); Employee employee = new Employee { Name = name, Email = email, Password = hashPassword }; _db.Employees.Add(employee); await _db.SaveChangesAsync(); MessageBox.Show("Success"); this.Close(); }