protected void FullfillService(int ID) { SalitaEntities db = new SalitaEntities(); var Need = db.CustomerNeeds.Single(p => p.CustomerNeed_ID == ID); Need.WasFullfilled = true; db.SaveChanges(); if (this.txtServiceDesc.Text.Length > 19) { if (this.txtServiceDesc.Text.Substring(0, 20) == "Transportacion Fuera") { // Take customer out of salita int Customer_ID = Convert.ToInt32(ViewState["Customer_ID"]); Visit v = db.Visits.SingleOrDefault(p => p.Customer_ID == Customer_ID && p.InLounge == true); if (v != null) { v.InLounge = false; db.SaveChanges(); } } } }
protected void cmdOK_Click(object sender, EventArgs e) { try { int Service_ID = 3; int Customer_ID = Convert.ToInt32(ViewState["id"]); SalitaEntities db = new SalitaEntities(); DateTime from = Convert.ToDateTime(DateTime.Today.ToShortDateString() + " 12:00AM"); DateTime to = Convert.ToDateTime(DateTime.Today.ToShortDateString() + " 11:59PM"); if (db.CustomerNeeds.SingleOrDefault(p => p.Customer_ID == Customer_ID && p.RequestDateTime >= from && p.RequestDateTime <= to && p.RequestedService_ID == Service_ID && p.WasFullfilled == false) == null) { CustomerNeed S = new CustomerNeed(); S.Customer_ID = Customer_ID; S.RequestDateTime = DateTime.Now; S.WasFullfilled = false; S.RequestedService_ID = Service_ID; // 3 == fuera del dealer S.Address_Line = this.txtSendTo.Text; S.Town = this.txtTown.Text; S.ZipCode = this.txtZipCode.Text; S.FromDealer = (this.cmbWhereTo.SelectedIndex == 0) ? true : false; S.Canceled = false; db.CustomerNeeds.Add(S); db.SaveChanges(); if (this.cbRoundTrip.Checked) { S.WasFullfilled = false; S.RequestedService_ID = 4; // 4 == transportacion al dealer S.RequestDateTime = Convert.ToDateTime(DateTime.Today.ToShortDateString() + " " + this.cmbTime.SelectedValue); S.FromDealer = !S.FromDealer; db.CustomerNeeds.Add(S); db.SaveChanges(); } Response.Redirect("report_transportation.aspx"); } else { throw new Exception("Ya existe un pedido de transportación para hoy el cliente con id: " + Customer_ID.ToString()); } } catch (Exception E) { this.CustomValidator1.IsValid = false; this.CustomValidator1.ErrorMessage = E.Message; } }
protected void lbComplete_Click(object sender, EventArgs e) { try { int id = Convert.ToInt32(ViewState["id"]); var R = db.CustomerNeeds.Single(p => p.CustomerNeed_ID == id); int?RequestedService_ID = R.RequestedService_ID; this.db.CustomerNeeds.Remove(R); this.db.SaveChanges(); // // Update the AG Form // if (RequestedService_ID == 3) { // Only update the drive to record DateTime NeedDateLow = Convert.ToDateTime(R.RequestDateTime.Value.ToShortDateString() + " 12:00AM"); DateTime NeedDateHigh = Convert.ToDateTime(R.RequestDateTime.Value.ToShortDateString() + " 11:59PM"); var V = db.Visits.Single(p => p.Customer_ID == R.Customer_ID && p.VisitDate >= NeedDateLow && p.VisitDate <= NeedDateHigh); V.AG_DriveTo = ""; V.AG_Companions = 0; V.AG_ExitTime = ""; V.AG_LL = false; db.SaveChanges(); } else if (RequestedService_ID == 4) { // Only update the drive from record DateTime NeedDateLow = Convert.ToDateTime(R.RequestDateTime.Value.ToShortDateString() + " 12:00AM"); DateTime NeedDateHigh = Convert.ToDateTime(R.RequestDateTime.Value.ToShortDateString() + " 11:59PM"); var V = db.Visits.Single(p => p.Customer_ID == R.Customer_ID && p.VisitDate >= NeedDateLow && p.VisitDate <= NeedDateHigh); V.AG_RR = false; db.SaveChanges(); } Response.Redirect("transport_page.aspx"); } catch (Exception E) { this.CustomValidator1.IsValid = false; this.CustomValidator1.ErrorMessage = E.Message; } }
public static void LeaveLounge(int Customer_ID) { SalitaEntities db = new SalitaEntities(); // // Cancel requests except for transportation // var Needs = db.CustomerNeeds.Where(p => p.Customer_ID == Customer_ID && p.WasFullfilled == false && p.Canceled == false && p.RequestedService_ID != 3 && p.RequestedService_ID != 4); foreach (CustomerNeed N in Needs) { SalitaEntities db2 = new SalitaEntities(); var NeedToUpdate = db2.CustomerNeeds.Single(p => p.CustomerNeed_ID == N.CustomerNeed_ID); NeedToUpdate.Canceled = true; db2.SaveChanges(); } // // Take customer out // var V = db.Visits.SingleOrDefault(p => p.Customer_ID == Customer_ID && p.InLounge == true); if (V != null) { V.InLounge = false; db.SaveChanges(); } }
public static void FullfillService(int ID, string Note) { SalitaEntities db = new SalitaEntities(); var Need = db.CustomerNeeds.Single(p => p.CustomerNeed_ID == ID); Need.WasFullfilled = true; db.SaveChanges(); /* * if (this.txtServiceDesc.Text.Length > 19) * { * if (this.txtServiceDesc.Text.Substring(0, 20) == "Transportacion Fuera") * { * // Take customer out of salita * int Customer_ID = Convert.ToInt32(ViewState["Customer_ID"]); * * Visit v = db.Visits.SingleOrDefault(p => p.Customer_ID == Customer_ID && p.InLounge == true); * * if (v != null) * { * v.InLounge = false; * * db.SaveChanges(); * } * } * } */ }
protected void cmdOK_Click(object sender, EventArgs e) { try { int vid = Convert.ToInt32(ViewState["vid"]); SalitaEntities db = new SalitaEntities(); var V = db.Visits.Single(p => p.Visit_ID == vid); V.Mood = ViewState["m"].ToString(); db.SaveChanges(); UpdateHub.SendServer(""); Response.Redirect("default.aspx"); } catch (Exception E) { this.CustomValidator1.IsValid = false; this.CustomValidator1.ErrorMessage = E.Message; if (E.InnerException != null) { this.CustomValidator1.ErrorMessage += " InnerException: " + E.InnerException.Message; } } }
protected void lbEdit_Click(object sender, EventArgs e) { try { SalitaEntities db = new SalitaEntities(); int id = Convert.ToInt32(ViewState["Service_ID"]); var N = db.CustomerNeeds.Single(p => p.CustomerNeed_ID == id); N.Address_Line = this.txtAddressLine1.Value; N.Town = this.txtTown.Value; N.ZipCode = this.txtZipCode.Text; N.RequestDateTime = Convert.ToDateTime(DateTime.Today.ToShortDateString() + " " + this.cmbTime.SelectedValue); // TODO: add a field for # of companions db.SaveChanges(); // // Edit the AG Form // if (N.RequestedService_ID == 3) { // Only update the drive to record DateTime NeedDateLow = Convert.ToDateTime(N.RequestDateTime.Value.ToShortDateString() + " 12:00AM"); DateTime NeedDateHigh = Convert.ToDateTime(N.RequestDateTime.Value.ToShortDateString() + " 11:59PM"); var V = db.Visits.Single(p => p.Customer_ID == N.Customer_ID && p.VisitDate >= NeedDateLow && p.VisitDate <= NeedDateHigh); V.AG_DriveTo = this.txtAddressLine1.Value; V.AG_Companions = Convert.ToInt32(this.cmbCompanions.SelectedValue); V.AG_ExitTime = this.cmbTime.Text; db.SaveChanges(); } Response.Redirect("transport_page.aspx"); } catch (Exception E) { this.CustomValidator1.IsValid = false; this.CustomValidator1.ErrorMessage = E.Message; } }
public static void ChangeSeat(int Customer_ID, int Seat_X, int Seat_Y) { SalitaEntities db = new SalitaEntities(); var V = db.Visits.SingleOrDefault(p => p.Customer_ID == Customer_ID && p.InLounge == true); if (V != null) { V.Seat_X = Seat_X; V.Seat_Y = Seat_Y; db.SaveChanges(); } }
public static void SetService(int Customer_ID, int Service_ID, string Note) { SalitaEntities db = new SalitaEntities(); var Need = new CustomerNeed(); Need.RequestDateTime = DateTime.Now; Need.Customer_ID = Customer_ID; Need.WasFullfilled = false; Need.Note = Note; Need.RequestedService_ID = Service_ID; Need.Canceled = false; db.CustomerNeeds.Add(Need); db.SaveChanges(); }
protected void SetService(int Customer_ID, int Service_ID) { SalitaEntities db = new SalitaEntities(); var Need = new CustomerNeed(); Need.RequestDateTime = DateTime.Now; Need.Customer_ID = Customer_ID; Need.WasFullfilled = false; Need.Note = this.txtServiceNote.Text; Need.RequestedService_ID = Service_ID; Need.Canceled = false; db.CustomerNeeds.Add(Need); db.SaveChanges(); }
public static void ProcessService(int Customer_ID, int Service_ID) { SalitaEntities db = new SalitaEntities(); if (db.CustomerNeeds.SingleOrDefault(p => p.Customer_ID == Customer_ID && p.RequestedService_ID == Service_ID && p.WasFullfilled == false) == null) { CustomerNeed S = new CustomerNeed(); S.Customer_ID = Customer_ID; S.RequestDateTime = DateTime.Now; S.WasFullfilled = false; S.RequestedService_ID = Service_ID; S.Canceled = false; db.CustomerNeeds.Add(S); db.SaveChanges(); } }