protected void LoadRecords(GridView gv, Boolean FromDealer) { DateTime from = Convert.ToDateTime(this.txtFrom.Value + " 12:00AM"); DateTime to = Convert.ToDateTime(this.txtTo.Value + " 11:59PM"); bool Todays = (this.ddlReportType.SelectedIndex == 0) ? true : false; SalitaEntities db = new SalitaEntities(); IQueryable <v_CustomerNeeds> R = null; if (Todays) { R = db.v_CustomerNeeds.Where(p => p.FromDealer == FromDealer && p.WasFullfilled == false && p.RequestDateTime >= from && p.RequestDateTime <= to && (p.RequestedService_ID == 3 || p.RequestedService_ID == 4)).OrderBy(p => p.RequestDateTime).OrderBy(p => p.WasFullfilled); } else { R = db.v_CustomerNeeds.Where(p => p.FromDealer == FromDealer && p.RequestDateTime >= from && p.RequestDateTime <= to && (p.RequestedService_ID == 3 || p.RequestedService_ID == 4)).OrderBy(p => p.RequestDateTime).OrderBy(p => p.WasFullfilled); } gv.DataSource = R.ToList(); gv.DataBind(); if (R != null) { if (FromDealer) { gv.Caption = "Llevar del dealer a destino: " + R.Count(); } else { gv.Caption = "Recojer en dirección y llevar al dealer: " + R.Count(); } } }
protected void LoadRecords() { DateTime fromDate = Convert.ToDateTime(this.txtFrom.Value + " 12:00AM"); DateTime toDate = Convert.ToDateTime(this.txtTo.Value + " 11:59PM"); bool Todays = (RadioButtonList1.SelectedIndex == 0) ? true : false; SalitaEntities db = new SalitaEntities(); //var R = db.v_CustomerNeeds.Where(p => p.RequestDateTime >= from && p.RequestDateTime <= to).OrderBy(p => p.RequestDateTime); var R = from p in db.v_CustomerNeeds where (p.RequestDateTime >= fromDate && p.RequestDateTime <= toDate) group p by p.ServiceDescription into g select new { name = g.Key, count = g.Count() }; this.gvRecords.DataSource = R.ToList(); this.gvRecords.DataBind(); if (R != null) { this.gvRecords.Caption = "Tipos de servicio: " + R.Count(); } }
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; } } }
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 cbUseRegisteredAddress_CheckedChanged(object sender, EventArgs e) { try { if (cbUseRegisteredAddress.Checked) { SalitaEntities db = new SalitaEntities(); int Customer_ID = Convert.ToInt32(ViewState["id"]); var C = db.Customers.Single(p => p.Customer_ID == Customer_ID); this.txtSendTo.Text = C.Address; this.txtZipCode.Text = C.ZipCode; this.txtTown.Text = C.Town; } else { this.txtSendTo.Text = ""; this.txtZipCode.Text = ""; this.txtTown.Text = ""; } } catch (Exception E) { this.CustomValidator1.IsValid = false; this.CustomValidator1.ErrorMessage = E.Message; } }
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(); } } } }
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(); } }
protected void LoadNeed(int id) { SalitaEntities db = new SalitaEntities(); var N = db.v_CustomerNeeds.Single(p => p.CustomerNeed_ID == id); this.lblFullName.Text = N.FullName; }
protected void Page_Load(object sender, EventArgs e) { try { if (!Page.IsPostBack) { SalitaEntities db = new SalitaEntities(); if (Request.QueryString["id"] == null || Request.QueryString["vid"] == null) { this.cmdOK.Enabled = false; throw new Exception("id or visit_id was not supplied."); } else { ViewState["Customer_ID"] = Request.QueryString["id"]; ViewState["m"] = Request.QueryString["m"]; ViewState["vid"] = Request.QueryString["vid"]; int cid = Convert.ToInt32(ViewState["Customer_ID"]); string m = ViewState["m"].ToString(); Customer C = db.Customers.Single(p => p.Customer_ID == cid); this.lblFullName.Text = C.FullName; //CustomerService S = db.CustomerServices.Single(p => p.CustomerService_ID == sid); //this.lblServiceRequested.Text = S.ServiceDescription; if (m == "N") { this.imageIcon.ImageUrl = @"images\customer_neutral.png"; } else if (m == "G") { this.imageIcon.ImageUrl = @"images\face_idle.png"; } else if (m == "B") { this.imageIcon.ImageUrl = @"images\face_bad.png"; } } } } 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 Page_Load(object sender, EventArgs e) { try { if (!Page.IsPostBack) { SalitaEntities db = new SalitaEntities(); if (Request.QueryString["id"] == null || Request.QueryString["sid"] == null) { this.cmdOK.Enabled = false; throw new Exception("id or sid was not supplied."); } else { ViewState["Customer_ID"] = Request.QueryString["id"]; ViewState["sid"] = Request.QueryString["sid"]; int cid = Convert.ToInt32(ViewState["Customer_ID"]); int sid = Convert.ToInt32(ViewState["sid"]); Customer C = db.Customers.Single(p => p.Customer_ID == cid); this.lblFullName.Text = C.FullName; CustomerService S = db.CustomerServices.Single(p => p.CustomerService_ID == sid); this.lblServiceRequested.Text = S.ServiceDescription; if (sid == 1) { this.imageIcon.ImageUrl = @"images\pop_water.png"; } else if (sid == 2) { this.imageIcon.ImageUrl = @"images\pop_soda.png"; } else if (sid == 3) { this.imageIcon.ImageUrl = @"images\pop_cafe.png"; } } } } 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 LoadLists() { SalitaEntities db = new SalitaEntities(); var L = db.HourSlots.Where(p => p.IsActive == true).OrderBy(p => p.HourSlotOrder); this.cmbTime.DataSource = L.ToList(); this.cmbTime.DataTextField = "HourSlotTime"; this.cmbTime.DataValueField = "HourSlotTime"; this.cmbTime.DataBind(); }
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 txtZipCode_TextChanged(object sender, EventArgs e) { if (this.txtZipCode.Text != "") { SalitaEntities db = new SalitaEntities(); ListZip z = db.ListZips.SingleOrDefault(p => p.ZipCode == this.txtZipCode.Text); if (z != null) { this.txtTown.Value = z.City; } } }
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 IEnumerable <v_CustomerNeeds> GetAllNeeds() { SalitaEntities db = new SalitaEntities(); DateTime from = Convert.ToDateTime(DateTime.Today.ToShortDateString() + " 12:00AM"); DateTime to = Convert.ToDateTime(DateTime.Today.ToShortDateString() + " 11:59PM"); var needs = db.v_CustomerNeeds.Where(p => p.WasFullfilled == false && p.Canceled == false && p.RequestDateTime >= from && p.RequestDateTime <= to).OrderBy(p => p.RequestDateTime); JavaScriptSerializer TheSerializer = new JavaScriptSerializer(); var TheJson = TheSerializer.Serialize(needs.ToList()); //return TheJson; return(needs); }
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(); } }
protected void LoadNeed(int id) { SalitaEntities db = new SalitaEntities(); var N = db.v_CustomerNeeds.Single(p => p.CustomerNeed_ID == id); this.lblFullName.InnerText = "Editar transportación para el cliente: " + N.FullName; this.txtAddressLine1.Value = N.Address_Line; this.txtZipCode.Text = N.ZipCode; this.txtTown.Value = N.Town; string Time = N.RequestDateTime.Value.ToShortTimeString(); if (this.cmbTime.Items.FindByText(Time) != null) { this.cmbTime.Items.FindByText(Time).Selected = true; } }
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; } }
protected void Page_Load(object sender, EventArgs e) { try { if (!Page.IsPostBack) { if (Request.QueryString["id"] == null) { this.cmdOK.Enabled = false; throw new Exception("id was not supplied."); } else { ViewState["id"] = Request.QueryString["id"]; int ID = Convert.ToInt32(ViewState["id"]); SalitaEntities db = new SalitaEntities(); var Need = db.v_CustomerNeeds.Single(p => p.CustomerNeed_ID == ID); ViewState["Customer_ID"] = Need.Customer_ID; this.lblFullName.Text = Need.FullName; this.txtServiceDesc.Text = Need.ServiceDescription + ((Need.Address_Line != null) ? ": " : "") + Need.Address_Line + " " + Need.Town; ViewState["ServiceType"] = Need.ServiceType; } } } 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 txtZipCode_TextChanged(object sender, EventArgs e) { try { if (this.txtZipCode.Text != "") { SalitaEntities db = new SalitaEntities(); ListZip z = db.ListZips.SingleOrDefault(p => p.ZipCode == this.txtZipCode.Text); if (z != null) { this.txtTown.Text = z.City; } } } catch (Exception E) { this.CustomValidator1.IsValid = false; this.CustomValidator1.ErrorMessage = E.Message; } }
protected void UpdateRequest(int id) { SalitaEntities db = new SalitaEntities(); var N = db.v_CustomerNeeds.Single(p => p.CustomerNeed_ID == id); }
protected void lbLogin_Click(object sender, EventArgs e) { try { SalitaEntities db = new SalitaEntities(); var U = db.Users.SingleOrDefault(p => p.Username == this.txtUsername.Value && p.UserPassword == this.txtPassword.Text); if (U != null) { Session["Username"] = U.Username; Session["Role"] = U.Role; HttpCookie cookie = FormsAuthentication.GetAuthCookie(this.txtUsername.Value, false); var ticket = FormsAuthentication.Decrypt(cookie.Value); // Store UserData inside the Forms Ticket with all the attributes // in sync with the web.config var newticket = new FormsAuthenticationTicket(ticket.Version, ticket.Name, ticket.IssueDate, ticket.Expiration, false, // always persistent "admin", ticket.CookiePath); // Encrypt the ticket and store it in the cookie cookie.Value = FormsAuthentication.Encrypt(newticket); cookie.Expires = newticket.Expiration.AddHours(24); this.Context.Response.Cookies.Set(cookie); if (Session["Role"].ToString() == "D") { Response.Redirect("transport_page.aspx"); } else { Response.Redirect("default.aspx"); } } else { SalitaEntities db2 = new SalitaEntities(); DateTime From = Convert.ToDateTime(DateTime.Today.ToShortDateString() + " 12:00AM"); DateTime To = Convert.ToDateTime(DateTime.Today.ToShortDateString() + " 11:59PM"); //var C = db2.v_RecentVisits.SingleOrDefault(p => p.VisitDate >= From && p.VisitDate <= To && p.Phone == this.txtUsername.Text && this.txtPassword.Text.Trim() == p.LoginPIN); var C = db2.v_RecentVisits.SingleOrDefault(p => p.Phone == this.txtUsername.Value && this.txtPassword.Text.Trim() == p.LoginPIN); if (C != null) { Session["Username"] = C.FullName; Session["Role"] = "C"; Session["Customer_ID"] = C.Customer_ID; HttpCookie cookie = FormsAuthentication.GetAuthCookie(this.txtUsername.Value, false); var ticket = FormsAuthentication.Decrypt(cookie.Value); // Store UserData inside the Forms Ticket with all the attributes // in sync with the web.config var newticket = new FormsAuthenticationTicket(ticket.Version, ticket.Name, ticket.IssueDate, ticket.Expiration, false, // persistent "customer", ticket.CookiePath); // Encrypt the ticket and store it in the cookie cookie.Value = FormsAuthentication.Encrypt(newticket); //cookie.Expires = newticket.Expiration.AddHours(24); this.Context.Response.Cookies.Set(cookie); Response.Redirect(@"\CustomerHome\default.aspx"); } else { this.CustomValidator1.IsValid = false; this.CustomValidator1.ErrorMessage = "Incorrect username or password."; } } } catch (Exception E) { this.CustomValidator1.IsValid = false; this.CustomValidator1.ErrorMessage = E.Message; if (E.InnerException != null) { this.CustomValidator1.ErrorMessage += " Inner exception: " + E.InnerException.Message; } } }