Ejemplo n.º 1
0
        protected void BtnUpdateCar_Click(object sender, EventArgs e)
        {
            CustomerVehicleInfo cvi = new CustomerVehicleInfo();
            Financial           f   = new Financial();

            cvi.Id = Convert.ToInt32(lblVehicleId.Text);
            cvi.VehicleCategoryId = Convert.ToInt16(rblVehicleType.SelectedValue);
            cvi.ModelYear         = Convert.ToInt16(ddlYear.SelectedValue);
            cvi.Manufacturer      = DdlMakes.SelectedValue;
            cvi.Model             = DdlModel.SelectedValue;
            cvi.Expires           = DateTime.Now.AddMonths(3);
            f.VehicleId           = cvi.Id;
            f.PurchasePrice       = Helpers.ConvertNullDblToZero(txtPurchasePrice.Text);
            f.PaymentCycle        = ddlPayCycle.SelectedValue;
            f.PaymentWithTax      = Convert.ToDouble(txtMonthlyWithTax.Text);
            if (DdlTrim.Enabled)
            {
                cvi.ModelTrim = Convert.ToInt32(DdlTrim.SelectedValue);
                cvi.OtherTrim = string.Empty;
                if (DdlTrim.SelectedItem.Text.Equals("Other"))
                {
                    cvi.OtherTrim = TxtModelTrim.Text;
                }
            }
            else
            {
                cvi.ModelTrim = 60931;
            }
            if (CustomerVehicleInfo.RepostSelectedVehicle(cvi))
            {
                if (Financial.UpdatePrice(f))
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Info", "alert('The ad #" + cvi.Id + " has been reposted.');", true);
                    GvVehicles.DataBind();
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Info", "alert('Failed reposting ad #" + cvi.Id + ".');", true);
            }
        }
Ejemplo n.º 2
0
        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;
            }
        }