protected void GvMyVehicles_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]); switch (e.CommandName) { case "Edit": Response.Redirect("viewmycarad.aspx?id=" + e.CommandArgument); break; case "Remove": VehicleImage imgs = VehicleImage.SelectByVehicleId(VehicleId); if (imgs != null) { if (Directory.Exists(Server.MapPath(imgs.ImgPath))) { Directory.Delete(Server.MapPath(imgs.ImgPath)); } } if (CustomerVehicleInfo.Delete(VehicleId)) { GvMyVehicles.DataBind(); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Info", "alert('Your vehicle #" + e.CommandArgument + " has been deleted.');", true); } else { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Info", "alert('Failed deleteing vehicle #" + e.CommandArgument + ".');", true); } break; case "Sold": ChangeStatus(FinId, VehicleId, "Sold"); break; case "SoldButMore": ChangeStatus(FinId, VehicleId, "Sold but more"); break; default: break; } }
protected string getVehicleData(object dr) { //ToDo: Sabuj: Use this code if uning improved speed code //var igvRow = (iSearch)dr; //var gvRow = Search.GetOneSearch(igvRow); var gvRow = (Search)dr; var imgs = VehicleImage.SelectByVehicleId(gvRow.VehicleId); string imgDiv = @"<div class='srimg border-grey'><div class='status'>"; if (gvRow.VehicleCondition.Equals("used")) { imgDiv += @"<p><span>Pre-Owned</span></p>"; } else { imgDiv += @"<p><span>New</span></p>"; } imgDiv += @"</div><div class='img-rounded centered'><img id='imgDetail' src='"; if (imgs != null) { imgDiv += @"/thumbnail.ashx?pic=" + imgs.Img1 + "&size=150'"; } else { imgDiv += @"'/images/cargrey.png'"; } imgDiv += @" alt='generic car image' />"; if (!string.IsNullOrEmpty(gvRow.Status)) { imgDiv += @"<p class='sold'><span>" + gvRow.Status + "</span></p>"; } imgDiv += @"</div></div>"; string vehData = @"<div class='srdetail'>"; string heading = gvRow.ModelYear.ToString(); if (gvRow.Manufacturer == "Other") { heading += " " + gvRow.MakeOther; } else { heading += " " + gvRow.Manufacturer; } if (gvRow.Model == "Other") { heading += " " + gvRow.ModelOther; } else { heading += " " + gvRow.Model; } if (gvRow.ModelTrim == "Other") { heading += " " + gvRow.OtherTrim; } else { heading += " " + gvRow.ModelTrim; } vehData += @"<strong>" + heading + "</strong><div>Id# " + gvRow.VehicleId; vehData += @"</div>City: " + gvRow.City; if (gvRow.VehicleCondition.Equals("used")) { var cfl = string.Empty; switch (gvRow.LeaseOrFinance) { case "f": cfl = "Finance"; break; case "l": cfl = "Lease"; break; case "c": cfl = "Cash price"; break; default: break; } vehData += @"<div>Finance or Lease: " + cfl + "</div>"; } vehData += @"<div class='bold'>Purchase price: " + gvRow.PurchasePrice.ToString(@"$#,##0.00;($#,##0.00\)") + "</div>"; if (gvRow.LeaseOrFinance.Equals("f") || gvRow.LeaseOrFinance.Equals("l")) { vehData += @"<div class='bold'>Payment cycle: " + gvRow.PaymentCycle + "</div>"; vehData += @"<div class='bold'>Payment: " + gvRow.PaymentWithTax.ToString(@"$#,##0.00;($#,##0.00\)") + "</div>"; vehData += @"<div>Term of loan: " + gvRow.LeaseTerm + "</div>"; if (gvRow.LeaseOrFinance.Equals("l")) { if (gvRow.VehicleCondition.Equals("used")) { vehData += @"<div>Odometer reading: " + gvRow.CurrentMileage.ToString("N0") + " Km</div>"; } vehData += @"<div>Free km's per year: " + gvRow.KmAllowance.ToString("N0") + "</div>"; } else { if (gvRow.VehicleCondition.Equals("used")) { vehData += @"<div>Odometer reading: " + gvRow.CurrentMileage.ToString("N0") + " Km</div>"; } } } else if (gvRow.LeaseOrFinance.Equals("c")) { if (gvRow.CurrentMileage > 1) { vehData += @"<div class='bold'>Odometer reading: " + gvRow.CurrentMileage.ToString("N0") + " Km</div>"; } } vehData += @"</div><div class='sraction'>"; if (gvRow.CustomerType.Equals("private")) { vehData += @"Private sales"; } else { vehData += Server.HtmlDecode(gvRow.Company); } vehData += @"<p>" + Server.HtmlDecode(gvRow.Comments) + "</p>"; vehData += @"<div class='centered'><a id='BtnShowDetails' class='btn btn-primary'"; vehData += @"href ='/VehicleDetails.aspx?id=" + gvRow.VehicleId + "&fid=" + gvRow.FinId + "'>Details</a></div></div><div class='clear'></div>"; return(imgDiv + vehData + "<br/><hr class='hred' />"); }
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); } }