protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { btn_Checkout.Attributes.Add("onmouseover", "this.src= '" + this.Page.ResolveClientUrl("~/Images/Checkout2.jpg") + "'"); btn_Checkout.Attributes.Add("onmouseout", "this.src= '" + this.Page.ResolveClientUrl("~/Images/Checkout1.jpg") + "'"); PopulateDropDown(); PopulateDropDown2(); Session["CouponUsed"] = "NIL"; Session["free"] = 0; decimal round = Convert.ToDecimal(Session["TotalPrice"]); ServiceOrderEntities soe = new ServiceOrderEntities(); string strOrderId = Request.QueryString["Id"]; int orderId = Convert.ToInt32(strOrderId); OrderView order = soe.OrderView.Find(orderId); lbl_Name.Text = order.ExpertFullName; lbl_Price.Text = String.Format("{0:N2}", order.Price); Session["OriginalPrice"] = order.Price; Session["FinalPrice"] = order.Price; lbl_Service.Text = order.ServiceName; lbl_Duration.Text = String.Format("{0} Hours", order.TimeslotCount); Session["Duration"] = order.TimeslotCount; lbl_Count.Text = Coupon.seeAvaliable(Session["UserId"].ToString()).ToString(); if (lbl_Count.Text.Equals("0")) { btn_ViewCoupons.Visible = false; } } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (IsValid) { int userId = Convert.ToInt32(Session["UserId"]); int serviceId = Convert.ToInt32(Request.QueryString["Id"]); Label lblPrice = fvService.FindControl("lblPrice") as Label; Label lblSurcharge = fvService.FindControl("lblSurcharge") as Label; Label lblUrgentDays = fvService.FindControl("lblUrgentDays") as Label; decimal surcharge = Convert.ToDecimal(lblSurcharge.Text); int urgentDays = Convert.ToInt32(lblUrgentDays.Text); DateTime serviceDate = calTimeslot.SelectedDate; decimal unitPrice = Convert.ToDecimal(lblPrice.Text); if ((serviceDate - DateTime.Now).Days < urgentDays) { unitPrice = unitPrice + surcharge; } List <DateTime> selectedTimeslots = new List <DateTime>(); foreach (ListViewDataItem item in lvTimeslot.Items) { CheckBox chkTimeslot = item.FindControl("chkTimeslot") as CheckBox; if (chkTimeslot.Checked) { string strTime = chkTimeslot.Text; DateTime timeslot = serviceDate.Date + TimeSpan.FromHours(Convert.ToInt32(strTime.Split(':')[0])); selectedTimeslots.Add(timeslot); } } ServiceOrderEntities soe = new ServiceOrderEntities(); Order order = new Order(); order.UserId = userId; order.ServiceId = serviceId; order.Price = unitPrice * selectedTimeslots.Count; order.Address = "Please Enter Address."; order.ServiceDate = serviceDate; foreach (DateTime timeslot in selectedTimeslots) { OrderTimeslot ots = new OrderTimeslot(); ots.Order = order; ots.ServiceId = serviceId; ots.Timeslot = timeslot; order.OrderTimeslot.Add(ots); } order.Status = "PENDING"; order.Enabled = true; order.CreatedDateTime = DateTime.Now; soe.Order.Add(order); soe.SaveChanges(); Response.Redirect(String.Format("~/UserPages/OrderForm.aspx?Id={0}", order.Id)); } }
protected void btn_Decline_Click(object sender, EventArgs e) { ServiceOrderEntities soe = new ServiceOrderEntities(); int orderId = Convert.ToInt32(Request.QueryString["OrderId"]); Order order = soe.Order.Find(orderId); order.Status = "REJECTED"; soe.SaveChanges(); Response.Redirect("~/ExpertPages/OrderView2.aspx"); }
protected void lnkOrderCancel_Click(object sender, EventArgs e) { int orderId = Convert.ToInt32(Request.QueryString["Id"]); ServiceOrderEntities soe = new ServiceOrderEntities(); Order order = soe.Order.Find(orderId); order.Status = "CANCELLED"; soe.SaveChanges(); }
protected void btnSave_Click(object sender, EventArgs e) { if (IsValid) { int orderId = Convert.ToInt32(Request.QueryString["Id"]); DateTime serviceDate = calTimeslot.SelectedDate; List <DateTime> selectedTimeslots = new List <DateTime>(); foreach (ListViewDataItem item in lvTimeslot.Items) { CheckBox chkTimeslot = item.FindControl("chkTimeslot") as CheckBox; if (chkTimeslot.Checked) { string strTime = chkTimeslot.Text; DateTime timeslot = serviceDate.Date + TimeSpan.FromHours(Convert.ToInt32(strTime.Split(':')[0])); selectedTimeslots.Add(timeslot); } } ServiceOrderEntities soe = new ServiceOrderEntities(); Order order = soe.Order.Find(orderId); order.ServiceDate = serviceDate; order.OrderTimeslot.Clear(); foreach (DateTime timeslot in selectedTimeslots) { OrderTimeslot ots = new OrderTimeslot(); ots.Order = order; ots.ServiceId = order.ServiceId.Value; ots.Timeslot = timeslot; order.OrderTimeslot.Add(ots); } order.CreatedDateTime = DateTime.Now; soe.SaveChanges(); Response.Redirect(String.Format("~/UserPages/OrderPayment.aspx?Id={0}", order.Id)); } }
protected void btn_Submit_Click(object sender, EventArgs e) { if (IsValid) { int userId = Convert.ToInt32(Session["UserId"]); int orderId = Convert.ToInt32(Request.QueryString["OrderId"]); ServiceOrderEntities soe = new ServiceOrderEntities(); Order o = soe.Order.Find(orderId); o.Status = "COMPLETED"; OrderReview or = new OrderReview(); or.OrderId = orderId; or.Reviews = tb_Comments.Text; or.Rating = Rating1.CurrentRating; or.CreatedDateTime = DateTime.Now; o.OrderReview = or; soe.SaveChanges(); Response.Redirect(String.Format("~/UserPages/OrderDetail.aspx?Id={0}", orderId)); } }
protected void Bind(int orderId) { if (Session["UserId"] == null) { Response.Redirect("~/Default.aspx"); } else { int userId = Convert.ToInt32(Session["UserId"]); ServiceOrderEntities soe = new ServiceOrderEntities(); OrderView ov = soe.OrderView.Find(orderId); if (ov.UserId == userId) { lbl_Worker.Text = ov.ExpertFullName; btn_Cancel.PostBackUrl = String.Format("~/UserPages/OrderDetail.aspx?Id={0}", orderId); } else { Response.Redirect("~/Default.aspx"); } } }