public async Task <ActionResult> Create([Bind(Include = "Id,Name")] Group group) { if (ModelState.IsValid) { group.Id = Guid.NewGuid(); db.Groups.Add(group); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(group)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Name,Latitude,Longtitude")] Supplier supplier) { if (ModelState.IsValid) { supplier.Id = Guid.NewGuid(); db.Suppliers.Add(supplier); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(supplier)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Name,Salary")] Position position) { if (ModelState.IsValid) { position.Id = Guid.NewGuid(); db.Positions.Add(position); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(position)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Name,Surname,PositionId")] Employee employee) { if (ModelState.IsValid) { employee.Id = Guid.NewGuid(); db.Employees.Add(employee); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.PositionId = new SelectList(db.Positions, "Id", "Name", employee.PositionId); return(View(employee)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Date,SupplierId")] Delivery delivery) { if (ModelState.IsValid) { delivery.Id = Guid.NewGuid(); db.Deliveries.Add(delivery); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.SupplierId = new SelectList(db.Suppliers, "Id", "Name", delivery.SupplierId); return(View(delivery)); }
public async Task <ActionResult> Create([Bind(Include = "MedicineId,DeliveryId,Quantity")] MedicineDelivery medicineDelivery) { if (ModelState.IsValid) { medicineDelivery.Id = Guid.NewGuid(); db.MedicineDeliveries.Add(medicineDelivery); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.DeliveryId = new SelectList(db.Deliveries, "Id", "Id", medicineDelivery.DeliveryId); ViewBag.MedicineId = new SelectList(db.Medicines, "Id", "Name", medicineDelivery.MedicineId); return(View(medicineDelivery)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Name,GroupId,SupplierId,Price")] Medicine medicine) { if (ModelState.IsValid) { medicine.Id = Guid.NewGuid(); db.Medicines.Add(medicine); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.GroupId = new SelectList(db.Groups, "Id", "Name", medicine.GroupId); ViewBag.SupplierId = new SelectList(db.Suppliers, "Id", "Name", medicine.SupplierId); ViewBag.Id = new SelectList(db.Warehouses, "MedicineId", "MedicineId", medicine.Id); return(View(medicine)); }
private async void btnCreateType_Click(object sender, EventArgs e) { string name = txtCreateTypeName.Text.Trim(); if (name == "") { MessageBox.Show("Fill Out", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (_db.TypeOfDrug.Any(t => t.type.ToLower() == name.ToLower())) { MessageBox.Show($"{name} alrady exists", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } TypeOfDrug type = new TypeOfDrug() { type = name }; _db.TypeOfDrug.Add(type); await _db.SaveChangesAsync(); MessageBox.Show("Done"); txtCreateTypeName.Text = ""; _cmb.Items.Clear(); _cmb.Items.AddRange(_db.TypeOfDrug.Select(t => new CB_TypeOfDrug { id = t.id, type = t.type }).ToArray()); }
private async void btnDeleteType_Click(object sender, EventArgs e) { int id = ((CB_TypeOfDrug)cmbDeleteType.SelectedItem).id; TypeOfDrug type = _db.TypeOfDrug.First(t => t.id == id); type.Deleted = false; //_db.TypeOfDrug.Remove(type); await _db.SaveChangesAsync(); MessageBox.Show("Deleted"); FillCmb(cmbDeleteType); FillCmb(_cmb); }