protected void NotifyCustomer(int CustomerId, int VehicleId, int FinId) { Customer c = Customer.GetCustomerDetails(CustomerId); CustomerVehicleInfo v = CustomerVehicleInfo.GetCustomerVehicleInfoDetails(VehicleId, FinId, false); StringBuilder msg = new StringBuilder(); string lnk = string.Concat("<a href='https://www.emonthlies.com/VehicleDetails.aspx?id=", VehicleId, "'>Click here</a> to view your ad."); msg.Append("<p>Hi " + c.FirstName + ",</p>"); msg.Append(string.Concat("<p>This is to confirm that your listing for: ", v.ModelYear, " ", v.Manufacturer, " ", v.Model, " has been approved.</p>")); msg.Append("<p>This posting is valid only for 90 days. "); msg.Append("If you wish to extend your ad you will have to repost.</p>"); msg.Append(lnk); if (Mailer.SendMail2Client(c.Email, msg.ToString(), "Vehicle listing approved") == false) { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "info", " alert('Customer could not be notified.');", true); } }
protected void GvVehicles_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Page") { return; } string[] args = e.CommandArgument.ToString().Split(','); int VehicleId = Convert.ToInt32(args[0]); int FinId = Convert.ToInt32(args[1]); //string declined = args[2]; switch (e.CommandName) { case "Activate": Response.Redirect("~/admin/reviewvehicle.aspx?id=" + e.CommandArgument); break; case "Deactivate": if (CustomerVehicleInfo.SetApprovedStatus(VehicleId, FinId, false)) { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Info", "alert('The ad #" + VehicleId + " has been deactivated.');", true); GvVehicles.DataBind(); } else { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Info", "alert('Failed deleteing ad #" + VehicleId + ".');", true); } break; case "Repost": lblVehicleId.Text = e.CommandArgument.ToString(); CustomerVehicleInfo cvi = CustomerVehicleInfo.GetCustomerVehicleInfoDetails(VehicleId, FinId, false); Financial f = Financial.GetFinancialDetailsByVehicleId(VehicleId, FinId); int[] cars = { 22, 23, 26, 27, 30, 34, 35, 38 }; int[] suvs = { 25, 32, 36 }; int[] trucks = { 24, 28, 37 }; string selectedVtype = string.Empty; if (cars.Contains(cvi.VehicleCategoryId)) { selectedVtype = "22"; } else if (suvs.Contains(cvi.VehicleCategoryId)) { selectedVtype = "25"; } else if (trucks.Contains(cvi.VehicleCategoryId)) { selectedVtype = "24"; } BindModelDdl(cvi.Manufacturer, cvi.Model, cvi.OtherModel); rblVehicleType.SelectedValue = selectedVtype; ddlYear.SelectedValue = cvi.ModelYear.ToString(); DdlMakes.SelectedValue = cvi.Manufacturer; if (cvi.Manufacturer.Equals("Other")) { TxtMakeOther.Enabled = true; TxtMakeOther.Visible = true; TxtMakeOther.Text = cvi.OtherMake; } DdlModel.SelectedValue = cvi.Model; if (cvi.Model == "Other") { TxtModelOther.Enabled = true; TxtModelOther.Visible = true; TxtModelTrim.Visible = true; TxtModelTrim.Enabled = true; TxtModelTrim.Text = cvi.OtherTrim; DdlTrim.Enabled = false; DdlTrim.Visible = false; } else { TxtModelTrim.Visible = false; TxtModelTrim.Enabled = false; DdlTrim.Enabled = true; DdlTrim.Visible = true; BindTrim(cvi.Manufacturer, cvi.Model, cvi.ModelTrim.ToString()); DdlTrim.SelectedValue = cvi.ModelTrim.ToString(); } txtPurchasePrice.Text = f.PurchasePrice.ToString(); ddlPayCycle.SelectedValue = f.PaymentCycle; txtMonthlyWithTax.Text = f.PaymentWithTax.ToString(); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Info", " $('#myModal').modal('show');", true); break; default: break; } }
protected void LoadVehicleData(int VehicleId, int FinId) { int[] cars = { 22, 23, 26, 27, 30, 34, 35, 38 }; int[] suvs = { 25, 32, 36 }; int[] trucks = { 24, 28, 37 }; string selectedVtype = string.Empty; if (Request.QueryString["update"] != null) { ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "Success", "alert('Picture/video files updated.');", true); } CustomerVehicleInfo vehicle = CustomerVehicleInfo.GetCustomerVehicleInfoDetails(VehicleId, FinId, false); if (vehicle != null) { BindFeatures(); if (cars.Contains(vehicle.VehicleCategoryId)) { selectedVtype = "22"; } else if (suvs.Contains(vehicle.VehicleCategoryId)) { selectedVtype = "25"; } else if (trucks.Contains(vehicle.VehicleCategoryId)) { selectedVtype = "24"; } else { selectedVtype = vehicle.VehicleCategoryId.ToString(); } rblCondition.SelectedValue = vehicle.VehicleCondition; rblVehicleType.SelectedValue = selectedVtype; ddlYear.SelectedValue = vehicle.ModelYear.ToString(); DdlMakes.SelectedValue = vehicle.Manufacturer; if (vehicle.Manufacturer.Equals("Other")) { TxtMakeOther.Enabled = true; TxtMakeOther.Visible = true; TxtMakeOther.Text = vehicle.OtherMake; RfvMakeOther.Enabled = true; RfvMakeOther.Visible = true; } else { TxtMakeOther.Enabled = false; TxtMakeOther.Visible = false; RfvMakeOther.Enabled = false; RfvMakeOther.Visible = false; } BindModelDdl(vehicle.Manufacturer, vehicle.Model, vehicle.OtherModel); DdlModel.SelectedValue = vehicle.Model; BindTrim(vehicle.Manufacturer, vehicle.Model, vehicle.ModelTrim.ToString()); if (vehicle.Model == "Other") { TxtModelOther.Enabled = true; TxtModelOther.Visible = true; TxtModelOther.Text = vehicle.OtherModel; TxtModelTrim.Visible = true; TxtModelTrim.Enabled = true; //TxtModelTrim.Visible = true; //TxtModelTrim.Text = vehicle.OtherTrim; } else { TxtModelOther.Enabled = false; TxtModelOther.Visible = false; TxtModelTrim.Visible = false; TxtModelTrim.Enabled = false; DdlTrim.SelectedValue = vehicle.ModelTrim.ToString(); } if (DdlTrim.SelectedValue == "60931") { RfvTrim.Enabled = true; RfvTrim.Visible = true; TxtModelTrim.Enabled = true; TxtModelTrim.Visible = true; TxtModelTrim.Text = vehicle.OtherTrim; RfvTxtTrim.Enabled = true; RfvTxtTrim.Visible = true; } else { RfvTrim.Enabled = false; RfvTrim.Visible = false; RfvTxtTrim.Enabled = false; RfvTxtTrim.Visible = false; TxtModelTrim.Text = string.Empty; TxtModelTrim.Enabled = false; TxtModelTrim.Visible = false; } RfvModelOther.Enabled = false; RfvModelOther.Visible = false; txtDisplacement.Text = vehicle.Displacement; ddlBodyColour.SelectedValue = vehicle.ExteriorColor; ddlInteriorColour.Enabled = true; rfvInterior.Enabled = false; ddlInteriorColour.SelectedValue = vehicle.InteriorColor; ddlFuel.SelectedValue = vehicle.FuelType; txtMileage.Text = vehicle.CurrentMileage.ToString(); ddlTransmission.SelectedValue = vehicle.Transmission; ddlWheels.SelectedValue = vehicle.Wheels; cbxChrome.Checked = vehicle.ChromeWheels; ddlTires.SelectedValue = vehicle.Tires; cbxWinterTires.Checked = vehicle.ExtraWinterTires; List <VehicleFeatures> vf = VehicleFeatures.SelectAllByVehicleId(vehicle.Id); foreach (VehicleFeatures feature in vf) { foreach (Control c in pnlFeatures.Controls) { if (c is DropDownList) { DropDownList ddl = (DropDownList)c; foreach (ListItem item in ddl.Items) { if (item.Value == feature.FeatureId.ToString()) { item.Selected = true; continue; } } } if (c is CheckBoxList) { CheckBoxList cbx = (CheckBoxList)c; foreach (ListItem item in cbx.Items) { if (item.Value == feature.FeatureId.ToString()) { item.Selected = true; } } } } } txtComments.Text = vehicle.Comments; Session["AdExpiry"] = vehicle.Expires; Financial ltd = Financial.GetFinancialDetailsByVehicleId(vehicle.Id, FinId); Session["LeaseId"] = ltd.Id; rblLeaseOrFinance.SelectedValue = ltd.LeaseOrFinance; switch (ltd.LeaseOrFinance) { case "l": pnlFinancialInfo.Enabled = true; rfvPayCycle.Enabled = true; rfvMonthly.Enabled = true; txtLeaseExpiry.Enabled = true; txtKmAllowance.Enabled = true; txtExcessKmCharge.Enabled = true; txtBalloon.Enabled = false; txtBalloon.Text = string.Empty; txtBuyBack.Enabled = true; txtSecurityDeposit.Enabled = true; ddlPurchaseOpEndOfLease.Enabled = true; break; case "f": pnlFinancialInfo.Enabled = true; rfvPayCycle.Enabled = true; rfvMonthly.Enabled = true; txtLeaseExpiry.Enabled = false; txtLeaseExpiry.Text = string.Empty; txtKmAllowance.Enabled = false; txtKmAllowance.Text = string.Empty; txtExcessKmCharge.Enabled = false; txtExcessKmCharge.Text = string.Empty; txtSecurityDeposit.Enabled = false; txtBalloon.Enabled = true; txtBuyBack.Enabled = false; txtBuyBack.Text = string.Empty; ddlPurchaseOpEndOfLease.Enabled = false; ddlPurchaseOpEndOfLease.ClearSelection(); break; case "c": pnlFinancialInfo.Enabled = false; rfvPayCycle.Enabled = false; rfvMonthly.Enabled = false; ddlPurchaseOpEndOfLease.ClearSelection(); txtLeaseExpiry.Text = string.Empty; txtKmAllowance.Text = string.Empty; txtBalloon.Text = string.Empty; txtBuyBack.Text = string.Empty; txtExcessKmCharge.Text = string.Empty; break; } ddlPayCycle.SelectedValue = ltd.PaymentCycle; txtMonthlyWithTax.Text = ltd.PaymentWithTax.ToString(); txtOriginalDown.Text = ltd.OriginalDown.ToString(); txtSecurityDeposit.Text = ltd.SecurityDeposit.ToString(); ddlPurchaseOpEndOfLease.SelectedValue = ltd.PoEndOfLease; txtKmAllowance.Text = ltd.KmAllowance.ToString(); txtExcessKmCharge.Text = ltd.ExcessKmCharge.ToString(); txtOriginalLeaseTerm.Text = ltd.LeaseTerm.ToString(); txtLeaseExpiry.Text = (ltd.LeaseExpiry == null) ? "" : ltd.LeaseExpiry.ToString(); txtBuyBack.Text = ltd.BuyBack.ToString(); txtBalloon.Text = ltd.Balloon.ToString(); txtPurchasePrice.Text = ltd.PurchasePrice.ToString(); txtSummary.Text = Server.HtmlDecode(ltd.Summary); VehicleImage imgs = VehicleImage.SelectByVehicleId(vehicle.Id); Session["imgs"] = imgs; PlaceImages(imgs); } }