Пример #1
0
    protected void btnSaveCarDetails_Click(object sender, EventArgs e)
    {
        DealerActions objActions = new DealerActions();
        try
        {
            DataSet dsCheckUser = objActions.DealerCheckUniqueID(txtDealerUniqueID.Text, Session[Constants.DealerCode].ToString());
            if (dsCheckUser.Tables[0].Rows.Count > 0)
            {

                MdepAlertSave.Show();
                lblAlertSave.Visible = true;
                lblAlertSave.Text = "Dealer inventory id already exist. Please enter a unique Dealer inventory id.";
                return;
            }

            int UID = Convert.ToInt32(Session[Constants.USER_ID].ToString());
            objUsedCarsInfo.DealerUniqueID = txtDealerUniqueID.Text;
            objUsedCarsInfo.YearOfMake = Convert.ToInt32(ddlYear.SelectedItem.Text);
            Session["SelYear"] = ddlYear.SelectedItem.Text;
            Session["SelMake"] = ddlMake.SelectedItem.Text;
            Session["SelModel"] = ddlModel.SelectedItem.Text;
            objUsedCarsInfo.MakeModelID = Convert.ToInt32(ddlModel.SelectedItem.Value);

            if (ddlStyle.SelectedItem.Value == "-1")
            {
                objUsedCarsInfo.BodytypeID = 0;
            }
            else
            {
                objUsedCarsInfo.BodytypeID = Convert.ToInt32(ddlStyle.SelectedItem.Value);
            }

            //if ((Session["CarID"] == null) || (Session["CarID"].ToString() == ""))
            //{
            //    objUsedCarsInfo.Carid = Convert.ToInt32(0);
            //}
            //else
            //{
            //    objUsedCarsInfo.Carid = Convert.ToInt32(Session["CarID"].ToString());
            //}

            if (txtAskingPrice.Text == "")
            {
                objUsedCarsInfo.Price = 0.00;
            }
            else
            {
                objUsedCarsInfo.Price = Convert.ToDouble(txtAskingPrice.Text);
            }

            if (txtCurrentPrice.Text == "")
            {
                objUsedCarsInfo.CurrentPrice = "0";
            }
            else
            {
                objUsedCarsInfo.CurrentPrice = txtCurrentPrice.Text;
            }

            if (txtPurchaseCost.Text == "")
            {
                objUsedCarsInfo.PurchaseCost = "0";
            }
            else
            {
                objUsedCarsInfo.PurchaseCost = txtPurchaseCost.Text;
            }

            if (txtMileage.Text == "")
            {
                objUsedCarsInfo.Mileage = "0";
            }
            else
            {
                objUsedCarsInfo.Mileage = txtMileage.Text;
            }

            objUsedCarsInfo.ExteriorColor = ddlExteriorColor.SelectedItem.Text;
            objUsedCarsInfo.InteriorColor = ddlInteriorColor.SelectedItem.Text;
            objUsedCarsInfo.Transmission = ddlTransmission.SelectedItem.Text;
            objUsedCarsInfo.NumberOfDoors = ddlDoorCount.SelectedItem.Value;
            objUsedCarsInfo.DriveTrain = ddlDriveTrain.SelectedItem.Value;
            objUsedCarsInfo.VIN = txtVin.Text;
            objUsedCarsInfo.NumberOfCylinder = ddlCylinderCount.SelectedItem.Value;
            objUsedCarsInfo.FueltypeId = Convert.ToInt32(ddlFuelType.SelectedItem.Value);
            objUsedCarsInfo.CurrentPrice = txtCurrentPrice.Text;
            objUsedCarsInfo.PurchaseCost = txtPurchaseCost.Text;

            if (txtZip.Text.Length == 4)
            {
                objUsedCarsInfo.Zipcode = "0" + txtZip.Text;
            }
            else
            {
                objUsedCarsInfo.Zipcode = txtZip.Text;
            }
            objUsedCarsInfo.City = GeneralFunc.ToProper(txtCity.Text);
            objUsedCarsInfo.State = ddlLocationState.SelectedItem.Text;
            string Condition = string.Empty;
            string CondiDescrip = string.Empty;
            Condition = GeneralFunc.ToProper(txtCondition.Text);
            string Title = txtTitle.Text;
            CondiDescrip = ddlCondition.SelectedItem.Text;

            int Isactive;
            int CarIDs;
            int FeatureID;
            objUsedCarsInfo.SellerName = txtSellerName.Text ;
            objUsedCarsInfo.Address1 = txtSellerAddress.Text;
            objUsedCarsInfo.City = GeneralFunc.ToProper(txtCity.Text);
            objUsedCarsInfo.StateID = ddlLocationState.SelectedItem.Value.ToString();
            if (txtZip.Text.Length == 4)
            {
                objUsedCarsInfo.Zip = "0" + txtZip.Text;
            }
            else
            {
                objUsedCarsInfo.Zip = txtZip.Text;
            }
            objUsedCarsInfo.Phone = txtSellerPhone.Text;

            objUsedCarsInfo.State = ddlLocationState.SelectedItem.Text.ToString();

            if (txtZip.Text.Length == 4)
            {
                objUsedCarsInfo.Zip = "0" + txtZip.Text;
            }
            else
            {
                objUsedCarsInfo.Zip = txtZip.Text;
            }
            objUsedCarsInfo.Phone = txtSellerPhone.Text;
            objUsedCarsInfo.Email = txtSellerEmail.Text;

            if ((Session[Constants.SellerID] == null) || (Session[Constants.SellerID].ToString() == ""))
            {
                objUsedCarsInfo.SellerID = Convert.ToInt32(0);
            }
            else
            {
                objUsedCarsInfo.SellerID = Convert.ToInt32(Session[Constants.SellerID].ToString());
            }
            //CarIDs = Convert.ToInt32(Session["CarID"].ToString());

            DataSet dsPackages = objActions.USP_ChkPackageForAddCar(UID);

            int PaymentID;

            //**************************************************???///
            //during we need take user package from dealer package id
            //**************************************************???///
            int UserPackID = 0;
            int PackageID = 0;
            if (dsPackages.Tables[0].Rows.Count > 0)
            {
                UserPackID = Convert.ToInt32(dsPackages.Tables[0].Rows[0]["UserPackID"].ToString());
                PackageID = Convert.ToInt32(dsPackages.Tables[0].Rows[0]["PackageID"].ToString());
                Session["PackageID"] = PackageID;

            }
            else
            {
                dsPackages = objActions.USP_ChkExistingPackage(UID);
                if (dsPackages.Tables[0].Rows.Count > 0)
                {
                    UserPackID = Convert.ToInt32(dsPackages.Tables[0].Rows[0]["UserPackID"].ToString());
                    PackageID = Convert.ToInt32(dsPackages.Tables[0].Rows[0]["PackageID"].ToString());
                    Session["PackageID"] = PackageID;
                }

            }
            objUsedCarsInfo.AdStatus = resAction1.SelectedItem.Value;

            int PostingID;

            if (Session["PostingID"] == null)
            {
                PostingID = Convert.ToInt32(0);
            }
            else if (Session["PostingID"].ToString() == "")
            {
                PostingID = Convert.ToInt32(0);
            }
            else
            {
                PostingID = Convert.ToInt32(Session["PostingID"]);
            }

            PaymentID = Convert.ToInt32(0);

            if (PackageID == 1)
            {
                Session["isActive"] = false;
            }

            DataSet dsCarFeature = new DataSet();
            DataSet dsPosting = new DataSet();

            String strHostName = Request.UserHostAddress.ToString();
            string strIp = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();

            DataSet dsCarsDetails = objActions.SaveCarAndSellerInfo(objUsedCarsInfo, Condition, CondiDescrip, Title, UID, UID, PackageID, PaymentID, UserPackID, PostingID, strIp, Session[Constants.DealerCode].ToString());

            Session["CarID"] = Convert.ToInt32(dsCarsDetails.Tables[0].Rows[0]["CarID"].ToString());
            Session["PostingID"] = dsCarsDetails.Tables[0].Rows[0]["PostingID"].ToString();
            Session[Constants.SellerID] = dsCarsDetails.Tables[0].Rows[0]["sellerID"].ToString();

            for (int i = 1; i < 52; i++)
            {
                if (Session["CarID"] == null)
                {
                    CarIDs = 0;
                }
                else
                {
                    CarIDs = Convert.ToInt32(Session["CarID"].ToString());
                }
                string ChkBoxID = "chkFeatures" + i.ToString();
                CheckBox ChkedBox = (CheckBox)form1.FindControl(ChkBoxID);
                if (ChkedBox.Checked == true)
                {
                    Isactive = 1;
                }
                else
                {
                    Isactive = 0;
                }
                FeatureID = i;
                dsCarFeature = objActions.USP_SaveCarFeatures(CarIDs, FeatureID, Isactive, UID);
            }
            Session["CarID"] = Convert.ToInt32(dsCarFeature.Tables[0].Rows[0]["CarID"].ToString());

            //lblErrorMSg.Visible = true;

            //lblErrorMSg.Text = "You car Details Added";

            //MpeAlert.Show();
            Session["CarID"] = null;
            Session["PostingID"] = null;
            Session[Constants.SellerID] = null;
            Response.Redirect("PicsUpload.aspx?CarInventoryID=" + dsCarsDetails.Tables[0].Rows[0]["PostingID"].ToString() + "P" + txtDealerUniqueID.Text + "");

        }
        catch (Exception ex)
        {
        }
    }
Пример #2
0
    private void SaveDetails()
    {
        try
        {
            int UID = Convert.ToInt32(Session[Constants.USER_ID].ToString());
            objcarsInfo.YearOfMake = Convert.ToInt32(ddlYear.SelectedItem.Text);
            objcarsInfo.MakeModelID = Convert.ToInt32(ddlModel.SelectedItem.Value);
            objcarsInfo.BodytypeID = Convert.ToInt32(ddlStyle.SelectedItem.Value);
            if ((Session["CarID"] == null) || (Session["CarID"].ToString() == ""))
            {
                objcarsInfo.Carid = Convert.ToInt32(0);
            }
            else
            {
                objcarsInfo.Carid = Convert.ToInt32(Session["CarID"].ToString());
            }
            if (txtAskingPrice.Text == "")
            {
                objcarsInfo.Price = Convert.ToDouble("0");
            }
            else
            {
                objcarsInfo.Price = Convert.ToDouble(txtAskingPrice.Text);
            }
            if (txtMileage.Text == "")
            {
                objcarsInfo.Mileage = "0";
            }
            else
            {
                objcarsInfo.Mileage = txtMileage.Text;
            }
            objcarsInfo.ExteriorColor = ddlExteriorColor.SelectedItem.Text;
            objcarsInfo.InteriorColor = ddlInteriorColor.SelectedItem.Text;
            objcarsInfo.Transmission = ddlTransmission.SelectedItem.Text;
            objcarsInfo.DriveTrain = ddlDriveTrain.SelectedItem.Value;
            objcarsInfo.NumberOfDoors = ddlDoorCount.SelectedItem.Value;
            objcarsInfo.VIN = txtVin.Text;
            objcarsInfo.NumberOfCylinder = ddlCylinderCount.SelectedItem.Value;

            objcarsInfo.FueltypeId = Convert.ToInt32(ddlFuelType.SelectedItem.Value);

            if (txtZip.Text.Length == 4)
            {
                objcarsInfo.Zipcode = "0" + txtZip.Text;
            }
            else
            {
                objcarsInfo.Zipcode = txtZip.Text;
            }

            objcarsInfo.City = GeneralFunc.ToProper(txtCity.Text);

            objcarsInfo.StateID = ddlLocationState.SelectedItem.Value;

            string Condition = string.Empty;
            string CondiDescrip = string.Empty;
            Condition = GeneralFunc.ToProper(txtCondition.Text);
            string Title = txtTitle.Text;
            CondiDescrip = ddlCondition.SelectedItem.Text;

            objcarsInfo.CurrentPrice = txtCurrentPrice.Text;
            objcarsInfo.PurchaseCost = txtPurchaseCost.Text;
            DealerActions objDealer = new DealerActions();
            objcarsInfo.Title = txtTitle.Text;

            DataSet dsCarsDetails = objDealer.USP_SaveCarDetails(objcarsInfo, Condition, CondiDescrip, Title, UID);

            Session["CarID"] = Convert.ToInt32(dsCarsDetails.Tables[0].Rows[0]["CarID"].ToString());

            int Isactive;
            int CarIDs;
            int FeatureID;
            objUsedCarsInfo.SellerName = txtSellerName.Text;

            objUsedCarsInfo.Address1 = txtSellerAddress.Text;
            objUsedCarsInfo.City = GeneralFunc.ToProper(txtCity.Text);
            objUsedCarsInfo.State = ddlLocationState.SelectedItem.Text.ToString();
            objUsedCarsInfo.StateID = ddlLocationState.SelectedItem.Value.ToString();
            if (txtZip.Text.Length == 4)
            {
                objUsedCarsInfo.Zip = "0" + txtZip.Text;
            }
            else
            {
                objUsedCarsInfo.Zip = txtZip.Text;
            }

            objUsedCarsInfo.Phone = txtSellerPhone.Text;
            objUsedCarsInfo.Email = txtSellerEmail.Text;

            if ((Session["SellerID"] == null) || (Session["SellerID"].ToString() == ""))
            {
                objUsedCarsInfo.SellerID = Convert.ToInt32(0);
            }
            else
            {
                objUsedCarsInfo.SellerID = Convert.ToInt32(Session["SellerID"].ToString());
            }
            CarIDs = Convert.ToInt32(Session["CarID"].ToString());

            int PackageID;
            int PaymentID;
            int PostingID;

            PackageID = Convert.ToInt32(Session["PackageID"]);

            if (Session["PaymentID"] == null)
            {
                PaymentID = Convert.ToInt32(0);
            }
            else if (Session["PaymentID"].ToString() == "")
            {
                PaymentID = Convert.ToInt32(0);
            }
            else
            {
                PaymentID = Convert.ToInt32(Session["PaymentID"]);
            }

            if (Session["PostingID"] == null)
            {
                PostingID = Convert.ToInt32(0);
            }
            else if (Session["PostingID"].ToString() == "")
            {
                PostingID = Convert.ToInt32(0);
            }
            else
            {
                PostingID = Convert.ToInt32(Session["PostingID"]);
            }

            String strHostName = Request.UserHostAddress.ToString();
            string strIp = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();

            int UserPackID = 0;

            DealerActions objActions = new DealerActions();

            DataSet dsPackages = objActions.USP_ChkPackageForAddCar(UID);

            if (dsPackages.Tables[0].Rows.Count > 0)
            {
                UserPackID = Convert.ToInt32(dsPackages.Tables[0].Rows[0]["UserPackID"].ToString());
            }
            else
            {
                dsPackages = objActions.USP_ChkExistingPackage(UID);
                if (dsPackages.Tables[0].Rows.Count > 0)
                {
                    UserPackID = Convert.ToInt32(dsPackages.Tables[0].Rows[0]["UserPackID"].ToString());

                }
            }

            DataSet dsposting = new DataSet();
            dsposting = objDealer.USP_SaveSellerInfo(objUsedCarsInfo, CarIDs, UID, PackageID, PaymentID, UserPackID, PostingID, strIp);

            Session["PostingID"] = dsposting.Tables[0].Rows[0]["PostingID"].ToString();

            for (int i = 1; i < 52; i++)
            {
                if (Session["CarID"] == null)
                {
                    CarIDs = 0;
                }
                else
                {
                    CarIDs = Convert.ToInt32(Session["CarID"].ToString());
                }
                string ChkBoxID = "chkFeatures" + i.ToString();
                CheckBox ChkedBox = (CheckBox)form1.FindControl(ChkBoxID);
                if (ChkedBox.Checked == true)
                {
                    Isactive = 1;
                }
                else
                {
                    Isactive = 0;
                }
                FeatureID = i;

                DataSet dsCarFeature = objDealer.USP_SaveCarFeatures(CarIDs, FeatureID, Isactive, UID);
                Session["CarID"] = Convert.ToInt32(dsCarFeature.Tables[0].Rows[0]["CarID"].ToString());
            }

            mpealteruser.Show();
            lblErr.Visible = true;
            lblErr.Text = "Car details saved successfully <br />Do you want to add photos now?";
            // Response.Redirect("placeadPhotos.aspx");
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }