private void buttonEdit_Click(object sender, EventArgs e) { if (listViewOrders.SelectedItems.Count == 1) { if (comboBoxClient.SelectedItem != null && comboBoxService.SelectedItem != null && comboBoxStatus.SelectedItem != null) { OrdersSet ordersSet = listViewOrders.SelectedItems[0].Tag as OrdersSet; ordersSet.Id_Client = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]); ordersSet.Id_Service = Convert.ToInt32(comboBoxService.SelectedItem.ToString().Split('.')[0]); if (dateTimePickerDate.Value > dateTimePickerDeadline.Value) { throw new Exception("Дата начала не может быть позже даты окончания."); } ordersSet.Date = dateTimePickerDate.Value; ordersSet.Deadline = dateTimePickerDeadline.Value; ordersSet.Status = comboBoxStatus.SelectedItem.ToString(); Program.RBS_Project.SaveChanges(); ShowOrders(); } else { MessageBox.Show("Заполнены не все поля!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
public ActionResult DeleteConfirmed(int id) { OrdersSet ordersSet = db.OrdersSets.Find(id); db.OrdersSets.Remove(ordersSet); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Order_Id,UserId,Renting_Start_Date,Renting_End_Date,Total_Renting_Fee")] OrdersSet ordersSet) { if (ModelState.IsValid) { db.Entry(ordersSet).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(ordersSet)); }
// GET: OrdersSets/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } OrdersSet ordersSet = db.OrdersSets.Find(id); if (ordersSet == null) { return(HttpNotFound()); } return(View(ordersSet)); }
public ActionResult Create([Bind(Include = "Order_Id,Renting_Start_Date,Renting_End_Date,Total_Renting_Fee")] OrdersSet ordersSet) { ordersSet.UserId = User.Identity.GetUserId(); ModelState.Clear(); TryValidateModel(ordersSet); if (ModelState.IsValid) { db.OrdersSets.Add(ordersSet); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(ordersSet)); }
private void buttonDelete_Click(object sender, EventArgs e) { try { if (listViewOrders.SelectedItems.Count == 1) { OrdersSet orders = listViewOrders.SelectedItems[0].Tag as OrdersSet; Program.RBS_Project.OrdersSet.Remove(orders); Program.RBS_Project.SaveChanges(); ShowOrders(); } comboBoxClient.SelectedItem = null; comboBoxService.SelectedItem = null; comboBoxStatus.SelectedItem = null; dateTimePickerDate.Value = DateTime.Now; dateTimePickerDeadline.Value = DateTime.Now; } catch { MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void listViewOrders_SelectedIndexChanged(object sender, EventArgs e) { if (listViewOrders.SelectedItems.Count == 1) { OrdersSet orders = listViewOrders.SelectedItems[0].Tag as OrdersSet; comboBoxClient.SelectedIndex = comboBoxClient.FindString(orders.Id_Client.ToString()); comboBoxService.SelectedIndex = comboBoxService.FindString(orders.Id_Service.ToString()); comboBoxStatus.SelectedIndex = comboBoxStatus.FindString(orders.Status); dateTimePickerDate.Value = orders.Date; dateTimePickerDeadline.Value = orders.Deadline; } else { comboBoxClient.SelectedItem = null; comboBoxService.SelectedItem = null; comboBoxStatus.SelectedItem = null; dateTimePickerDate.Value = DateTime.Now; dateTimePickerDeadline.Value = DateTime.Now; } }