public int AddVendorRegister(VendorDetails vendorDetails)
 {
     try
     {
         DALComponent objDALRegister = new DALComponent();
         objDALRegister.SetParameters("@VendorID", SqlDbType.Int, 4, vendorDetails.VendorID);
         objDALRegister.SetParameters("@LoginName", SqlDbType.VarChar, 50, vendorDetails.LoginName);
         objDALRegister.SetParameters("@LoginPassword", SqlDbType.VarChar, 50, vendorDetails.LoginPassword);
         objDALRegister.SetParameters("@VendorName", SqlDbType.VarChar, 50, vendorDetails.VendorName);
         objDALRegister.SetParameters("@VendorAddress", SqlDbType.VarChar, 50, vendorDetails.VendorAddress);
         objDALRegister.SetParameters("@VendorStreet", SqlDbType.VarChar, 50, vendorDetails.VendorStreet);
         objDALRegister.SetParameters("@VendorCityId", SqlDbType.Int, 4, vendorDetails.VendorCityId);
         objDALRegister.SetParameters("@VendorStateId", SqlDbType.Int, 4, vendorDetails.VendorStateId);
         objDALRegister.SetParameters("@VendorCountryId", SqlDbType.Int, 4, vendorDetails.VendorCountryId);
         objDALRegister.SetParameters("@VendorZipcode", SqlDbType.VarChar, 50, vendorDetails.VendorZipcode);
         objDALRegister.SetParameters("@VendorEmail", SqlDbType.VarChar, 50, vendorDetails.VendorEmail);
         objDALRegister.SetParameters("@VendorMobile", SqlDbType.VarChar, 50, vendorDetails.VendorMobile);
         objDALRegister.SetParameters("@VendorBusinessPhone", SqlDbType.VarChar, 50, vendorDetails.VendorBusinessPhone);
         objDALRegister.SetParameters("@CompanyName", SqlDbType.VarChar, 50, vendorDetails.CompanyName);
         objDALRegister.SetParameters("@OwnerName", SqlDbType.VarChar, 50, vendorDetails.OwnerName);
         objDALRegister.SetParameters("@ContactName", SqlDbType.VarChar, 50, vendorDetails.ContactName);
         objDALRegister.SetParameters("@ContactNumber", SqlDbType.VarChar, 50, vendorDetails.ContactNumber);
         objDALRegister.SetParameters("@CategoryId", SqlDbType.Int, 4, vendorDetails.CategoryId);
         objDALRegister.SetParameters("@CoverageArea", SqlDbType.VarChar, 50, vendorDetails.CoverageArea);
         objDALRegister.SetParameters("@WebsiteUrl", SqlDbType.VarChar, 50, vendorDetails.WebsiteUrl);
         objDALRegister.SetParameters("@GeoCode", SqlDbType.VarChar, 50, vendorDetails.GeoCode);
         objDALRegister.SetParameters("@MemberShipId", SqlDbType.Int, 4, vendorDetails.MemberShipId);
         objDALRegister.SetParameters("@CreditCardNumber", SqlDbType.VarChar, 50, vendorDetails.CreditCardNumber);
         objDALRegister.SetParameters("@CreditCardType", SqlDbType.VarChar, 50, vendorDetails.CreditCardType);
         objDALRegister.SetParameters("@CreditCardExpired", SqlDbType.VarChar, 50, vendorDetails.CreditCardExpired);
         objDALRegister.SetParameters("@CVCNumber", SqlDbType.VarChar, 50, vendorDetails.CVCNumber);
         objDALRegister.SetParameters("@idvalue", SqlDbType.Int, true);
         objDALRegister.SqlCommandText = "[CreateVendor]";
         int x = objDALRegister.CreateRecord();
         object y = objDALRegister.GetParameters("@idvalue");
         if (vendorDetails.VendorID != 0)
             return vendorDetails.VendorID;
         else
             return Int32.Parse(y.ToString());
     }
     catch (SqlException sqlEx)
     {
         throw new ApplicationException("Data error=" + sqlEx.Message.ToString());
     }
     catch (Exception ex)
     {
         throw new ApplicationException("Error=" + ex.Message.ToString());
     }
 }
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            strErrorMessage = "";
            intVaidError = 0;
            CheckValidation();

            if (intVaidError == 0)
            {
                ServeAtDoorstepData.VendorDetails objVenDetails = new ServeAtDoorstepData.VendorDetails();
                objVenDetails.LoginName = txtLoginname.Value.ToString();
                objVenDetails.LoginPassword = txtPassword.Value.ToString();
                objVenDetails.VendorID = 0;
                objVenDetails.VendorName = txtVendorName.Value.ToString();
                objVenDetails.VendorAddress = txtAddress.Value.ToString();
                objVenDetails.VendorStreet = txtStreet.Value.ToString();
                objVenDetails.VendorCityId = Convert.ToInt32(ddlCity.SelectedItem.Value.ToString());
                objVenDetails.VendorStateId = Convert.ToInt32(ddlState.SelectedItem.Value.ToString());
                objVenDetails.VendorCountryId = Convert.ToInt32(ddlCountry.Value.ToString());
                objVenDetails.VendorEmail = txtEmail.Value.ToString();
                objVenDetails.VendorZipcode = txtZipcode.Value.ToString();
                objVenDetails.VendorMobile = txtMobileNo.Value.ToString();
                objVenDetails.VendorBusinessPhone = txtBusinessNo.Value.ToString();
                objVenDetails.CompanyName = txtCompanyName.Value.ToString();
                objVenDetails.OwnerName = txtOwnerName.Value.ToString();
                objVenDetails.ContactName = txtContactName.Value.ToString();
                objVenDetails.ContactNumber = txtContactNo.Value.ToString();
                objVenDetails.CategoryId = 0;// Convert.ToInt32(ddlCategory.Value.ToString());
                objVenDetails.CoverageArea = txtCoverageArea.Value.ToString();
                objVenDetails.WebsiteUrl = txtWebsiteUrl.Value.ToString();
                objVenDetails.GeoCode = "0";//.Value.ToString();
                objVenDetails.MemberShipId = Convert.ToInt32(ddlMembership.Value.ToString());
                objVenDetails.CreditCardNumber = txtCredCardNo.Value.ToString();
                objVenDetails.CreditCardType = txtCredCardType.Value.ToString();
                objVenDetails.CreditCardExpired = txtExpiredDate.Value.ToString();
                objVenDetails.CVCNumber = txtCVC.Value.ToString();

                objService = new ServeAtDoorstepService();
                int intVendId = objService.AddVendorRegister(objVenDetails);

                for(int intCnt=0;intCnt<chkCateList.Items.Count;intCnt++)
                {
                    if (chkCateList.Items[intCnt].Selected == true)
                    {
                        int iCatID = Convert.ToInt32(chkCateList.Items[intCnt].Value.ToString());

                        objService = new ServeAtDoorstepService();
                        DataTable dtServ = objService.SelectServiceByCatID(iCatID);

                        //if (dtServ.Rows.Count > 0)
                        {
                            //for (int intSer = 0; intSer < dtServ.Rows.Count; intSer++)
                            {
                                VendorServiceDetails objVSData = new VendorServiceDetails();
                                objVSData.VendorServiceId = 0;
                                objVSData.VendorId = intVendId;
                                objVSData.CategoryId = iCatID;
                                objVSData.ServiceId = 0;// Convert.ToInt32(dtServ.Rows[0]["ServiceID"].ToString());
                                objVSData.Status = "1";

                                int i = objService.AddVendorService(objVSData);

                            }
                        }
                    }
                }

                #region .. VENDOR COVERAGE AREA ..

                //var requestUri = "https://www.zipwise.com/webservices/radius.php?key=yj7b6stzbr3lmmoo&zip=" + txtZipcode.Value.Trim() + "&radius=5&format=xml";
                //var requestUri = "https://zipcodedistanceapi.redline13.com/rest/VGO5Fus2poaNqECnpYc77kfZARW0TjgP04UFymHYLSMcxoAWnM3u6itHaqH4KXTK/radius.xml/" + txtZipcode.Value.Trim() + "/15/mile";
                var requestUri = "https://zipcodedistanceapi.redline13.com/rest/dtMOhbP1itLs2K2WQNccHRkUoEGJfDds7Zgoa6ptAbWCWYzMMLYuDjo1Y4LdIYGP/radius.xml/" + txtZipcode.Value.Trim() + "/15/mile";

                var webRequest = (HttpWebRequest)WebRequest.Create(requestUri);

                webRequest.Method = "GET";

                webRequest.ContentType = "application/xml";

                HttpWebResponse response;

                string responseContent = "";

                try
                {

                    response = (HttpWebResponse)webRequest.GetResponse();

                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.Load(response.GetResponseStream());

                    //Create namespace manager
                    int intAreaCount = 0;
                    string[] sCity = new string[500];
                    string[] state = new string[500];
                    string[] sZip = new string[500];
                    string[] sDis = new string[500];

                    XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
                    nsmgr.AddNamespace("rest", "http://schemas.microsoft.com/search/local/ws/rest/v1");
                    string s = xmlDoc.InnerXml.Contains("error").ToString();
                    if (xmlDoc.InnerXml.Contains("error").ToString() == "False")
                    {
                        XmlNodeList locationElements = xmlDoc.SelectNodes("results/result", nsmgr);
                        int i = 0;
                        foreach (XmlNode location in locationElements)
                        {
                            sZip[i] = location.SelectSingleNode("zip", nsmgr).InnerText;
                            //sCity[i] = location.SelectSingleNode("city", nsmgr).InnerText;
                            //state[i] = location.SelectSingleNode("state", nsmgr).InnerText;
                            //sDis[i] = location.SelectSingleNode("distance", nsmgr).InnerText;

                            i++;
                            intAreaCount++;
                        }
                    }
                    webRequest.Abort();

                    for (int iACnt = 0; iACnt < intAreaCount; iACnt++)
                    {
                        ServeAtDoorstepData.VendorAreaDetails objVendorArea = new VendorAreaDetails();
                        objVendorArea.VendorAreaID = 0;
                        objVendorArea.VendorId = intVendId;
                        objVendorArea.VAZipcode = sZip[iACnt];
                        objVendorArea.VACityName = "";// sCity[iACnt];
                        objVendorArea.VAState = "";//state[iACnt];
                        objVendorArea.VADistance = "";//sDis[iACnt];

                        int j = objService.AddVendorArea(objVendorArea);

                    }
                }
                catch (WebException webex)
                {
                    //lblResult.Text = "INVALID ZIPCODE";

                }

                #endregion

                SendMailtoUser(intVendId);

                lblEmailId.Text = txtEmail.Value.ToString();
                this.ModalPopupSuccess.Show();
                //Response.Redirect("Success.aspx?type=ven");
            }
            else
            {
                divErrorMessage.InnerHtml = strErrorMessage;

            }
        }
 public void UpdateVendorPassword(VendorDetails venDetails)
 {
     try
     {
         DALComponent objDAL = new DALComponent();
         objDAL.SetParameters("@vendorId", SqlDbType.Int, 4, venDetails.VendorID);
         objDAL.SetParameters("@password", SqlDbType.VarChar, 100, venDetails.LoginPassword);
         objDAL.SqlCommandText = "[UpdateVendorPassword]";
         int x = objDAL.UpdateRecord();
     }
     catch (SqlException sqlEx)
     {
         throw new ApplicationException("Data error=" + sqlEx.Message.ToString());
     }
     catch (Exception ex)
     {
         throw new ApplicationException("Error=" + ex.Message.ToString());
     }
 }