Exemplo n.º 1
0
        public bool ValidateUser(string activationToken)
        {
            bool IsValid;
            var result = BusinessLogic.GetTempCPADetails(activationToken);
            DateTime now = DateTime.Now;
            TimeSpan weekSpan = now.AddDays(7) - now;

             DateTime ValidDate=DateTime.Now.Subtract(weekSpan);

               if (result == null || result.Tables[0].Rows.Count == 0)
            {
               IsValid = false;
               }
               else if  (result.Tables[0].Rows[0]["ActivationToken"].ToString() == activationToken && (DateTime)result.Tables[0].Rows[0]["CreatedDate"] >= ValidDate)
                {

                CPADetails newCustomer = new CPADetails();

                newCustomer.Email = result.Tables[0].Rows[0]["Email"].ToString();
                newCustomer.Password = result.Tables[0].Rows[0]["Password"].ToString();
                newCustomer.FirstName = result.Tables[0].Rows[0]["FirstName"].ToString();
                newCustomer.LastName = result.Tables[0].Rows[0]["LastName"].ToString();
                newCustomer.DateOfBirth = (DateTime)result.Tables[0].Rows[0]["DateOfBirth"];
                newCustomer.Gender = result.Tables[0].Rows[0]["Gender"].ToString();
                newCustomer.PhoneNumber = result.Tables[0].Rows[0]["Phone"].ToString();
                newCustomer.Image = (byte[])result.Tables[0].Rows[0]["CPAImage"];

                newCustomer.CompanyName = result.Tables[0].Rows[0]["CompanyName"].ToString();
                newCustomer.Address1= result.Tables[0].Rows[0]["Address1"].ToString();
                newCustomer.Address2= result.Tables[0].Rows[0]["Address2"].ToString();
                newCustomer.State = result.Tables[0].Rows[0]["State"].ToString();
                newCustomer.City = result.Tables[0].Rows[0]["City"].ToString();
                newCustomer.ZipCode = result.Tables[0].Rows[0]["ZipCode"].ToString();
               // newCustomer.SpecialityID = result.Tables[0].Rows[0]["SpecialityID"].ToString();
                newCustomer.Speciality = result.Tables[0].Rows[0]["Speciality"].ToString();
                newCustomer.Latitude = double.Parse(result.Tables[0].Rows[0]["Latitude"].ToString());
                newCustomer.Longitude = double.Parse(result.Tables[0].Rows[0]["Longitude"].ToString());
                newCustomer.TimeZoneID = result.Tables[0].Rows[0]["TimeZoneID"].ToString();

               bool result1 = BusinessLogic.CreateNewCPA(newCustomer);
                if (result1)
                    {
                        int count = BusinessLogic.DeleteTempCPADetails(activationToken);
                        IsValid = true;
                    }
                else
                    {
                        IsValid = false;
                    }

                }
            else
            {
                //String message = "Validation Expire";
                IsValid = false;

            }

            return IsValid;
        }
Exemplo n.º 2
0
        public bool ValidateUser(string activationToken)
        {
            bool     IsValid;
            var      result   = BusinessLogic.GetTempCPADetails(activationToken);
            DateTime now      = DateTime.Now;
            TimeSpan weekSpan = now.AddDays(7) - now;

            DateTime ValidDate = DateTime.Now.Subtract(weekSpan);

            if (result == null || result.Tables[0].Rows.Count == 0)
            {
                IsValid = false;
            }
            else if (result.Tables[0].Rows[0]["ActivationToken"].ToString() == activationToken && (DateTime)result.Tables[0].Rows[0]["CreatedDate"] >= ValidDate)
            {
                CPADetails newCustomer = new CPADetails();

                newCustomer.Email       = result.Tables[0].Rows[0]["Email"].ToString();
                newCustomer.Password    = result.Tables[0].Rows[0]["Password"].ToString();
                newCustomer.FirstName   = result.Tables[0].Rows[0]["FirstName"].ToString();
                newCustomer.LastName    = result.Tables[0].Rows[0]["LastName"].ToString();
                newCustomer.DateOfBirth = (DateTime)result.Tables[0].Rows[0]["DateOfBirth"];
                newCustomer.Gender      = result.Tables[0].Rows[0]["Gender"].ToString();
                newCustomer.PhoneNumber = result.Tables[0].Rows[0]["Phone"].ToString();
                newCustomer.Image       = (byte[])result.Tables[0].Rows[0]["CPAImage"];

                newCustomer.CompanyName = result.Tables[0].Rows[0]["CompanyName"].ToString();
                newCustomer.Address1    = result.Tables[0].Rows[0]["Address1"].ToString();
                newCustomer.Address2    = result.Tables[0].Rows[0]["Address2"].ToString();
                newCustomer.State       = result.Tables[0].Rows[0]["State"].ToString();
                newCustomer.City        = result.Tables[0].Rows[0]["City"].ToString();
                newCustomer.ZipCode     = result.Tables[0].Rows[0]["ZipCode"].ToString();
                // newCustomer.SpecialityID = result.Tables[0].Rows[0]["SpecialityID"].ToString();
                newCustomer.Speciality = result.Tables[0].Rows[0]["Speciality"].ToString();
                newCustomer.Latitude   = double.Parse(result.Tables[0].Rows[0]["Latitude"].ToString());
                newCustomer.Longitude  = double.Parse(result.Tables[0].Rows[0]["Longitude"].ToString());
                newCustomer.TimeZoneID = result.Tables[0].Rows[0]["TimeZoneID"].ToString();

                bool result1 = BusinessLogic.CreateNewCPA(newCustomer);
                if (result1)
                {
                    int count = BusinessLogic.DeleteTempCPADetails(activationToken);
                    IsValid = true;
                }
                else
                {
                    IsValid = false;
                }
            }
            else
            {
                //String message = "Validation Expire";
                IsValid = false;
            }


            return(IsValid);
        }
Exemplo n.º 3
0
        protected void btnSignUp_Click(object sender, EventArgs e)
        {
            if (!Isvalididate())
                return;
            Guid userGuid1 = Guid.NewGuid();
            string userGuid = userGuid1.ToString();
            if (!SendEmail1(userGuid))
            {
                return;
            }
            if (Page.IsValid)
            {
                CPADetails newCPA = new CPADetails();
                //TODO: use calendar control
                newCPA.CompanyName = txtCompanyName.Text;
                newCPA.Email = txtEmail.Text;
                newCPA.FirstName = txtFirstName.Text;
                newCPA.LastName = txtLastName.Text;
                newCPA.Password = txtPassword.Text;
                newCPA.Gender = rbtnMale.Checked ? "M" : "F";
                newCPA.DateOfBirth = DateTime.Parse(txtDateOfBirth.Text);
                newCPA.Address1 = txtOfficeAddress1.Text;
                newCPA.Address2 = txtOfficeAddress2.Text;
                newCPA.ZipCode = txtZipCode.Text;
                newCPA.State = ddlState.SelectedItem.Text;
                newCPA.City = ddlCity.SelectedItem.Text;
                newCPA.PhoneNumber = txtPhNumberPart1.Text;
                newCPA.TimeZoneID = ddlTimeZone.SelectedValue?? string.Empty;
                // Find Latitude longitude of CPA from address
                string address = string.Concat(newCPA.Address1, " ", newCPA.Address2, " ", newCPA.City , " " , newCPA.State, " ", newCPA.ZipCode);
                FindCoordinatesOfCPA(address,newCPA);

                //TODO: check how to handle speciality
                // newCPA.SpecialityID = ddlSpeciality.SelectedValue;
                newCPA.Speciality = txtSpeciality.Text;

                if (ImageUpload != null && ImageUpload.PostedFile != null)
                {
                    int len = ImageUpload.PostedFile.ContentLength;
                    byte[] pic = new byte[len];
                    ImageUpload.PostedFile.InputStream.Read(pic, 0, len);
                    newCPA.Image = pic;
                }
                else
                { newCPA.Image = new byte[0]; }

                newCPA.ActivationToken = userGuid.ToString();
                newCPA.CreatedDate = DateTime.Now;

                bool result = BusinessLogic.CreateNewTempCPA(newCPA);
                if (result)
                {

                    Response.Redirect("~/CPA/VerifyEmail.aspx?Email=" + txtEmail.Text);
                }
            }
        }
Exemplo n.º 4
0
        protected void FindCoordinatesOfCPA(string address, CPADetails newCPA)
        {
            double latitutde  = 0;
            double longitutde = 0;

            string     url     = "http://maps.google.com/maps/api/geocode/xml?address=" + address + "&sensor=false";
            WebRequest request = WebRequest.Create(url);

            using (WebResponse response = (HttpWebResponse)request.GetResponse())
            {
                using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
                {
                    DataSet dsResult = new DataSet();
                    dsResult.ReadXml(reader);
                    DataTable dtCoordinates = new DataTable();
                    dtCoordinates.Columns.AddRange(new DataColumn[4] {
                        new DataColumn("Id", typeof(int)),
                        new DataColumn("Address", typeof(string)),
                        new DataColumn("Latitude", typeof(string)),
                        new DataColumn("Longitude", typeof(string))
                    });
                    foreach (DataRow row in dsResult.Tables["result"].Rows)
                    {
                        string  geometry_id = dsResult.Tables["geometry"].Select("result_id = " + row["result_id"].ToString())[0]["geometry_id"].ToString();
                        DataRow location    = dsResult.Tables["location"].Select("geometry_id = " + geometry_id)[0];
                        dtCoordinates.Rows.Add(row["result_id"], row["formatted_address"], location["lat"], location["lng"]);

                        double.TryParse(location["lat"].ToString(), out latitutde);
                        double.TryParse(location["lng"].ToString(), out longitutde);
                        newCPA.Latitude  = latitutde;
                        newCPA.Longitude = longitutde;
                    }
                    if (dtCoordinates.Rows.Count > 0)
                    {
                        //pnlScripts.Visible = true;
                        //rptMarkers.DataSource = dtCoordinates;
                        //rptMarkers.DataBind();
                    }
                }
            }
        }
Exemplo n.º 5
0
        protected void btnSignUp_Click(object sender, EventArgs e)
        {
            if (!Isvalididate())
            {
                return;
            }
            Guid   userGuid1 = Guid.NewGuid();
            string userGuid  = userGuid1.ToString();

            if (!SendEmail1(userGuid))
            {
                return;
            }
            if (Page.IsValid)
            {
                CPADetails newCPA = new CPADetails();
                //TODO: use calendar control
                newCPA.CompanyName = txtCompanyName.Text;
                newCPA.Email       = txtEmail.Text;
                newCPA.FirstName   = txtFirstName.Text;
                newCPA.LastName    = txtLastName.Text;
                newCPA.Password    = txtPassword.Text;
                newCPA.Gender      = rbtnMale.Checked ? "M" : "F";
                newCPA.DateOfBirth = DateTime.Parse(txtDateOfBirth.Text);
                newCPA.Address1    = txtOfficeAddress1.Text;
                newCPA.Address2    = txtOfficeAddress2.Text;
                newCPA.ZipCode     = txtZipCode.Text;
                newCPA.State       = ddlState.SelectedItem.Text;
                newCPA.City        = ddlCity.SelectedItem.Text;
                newCPA.PhoneNumber = txtPhNumberPart1.Text;

                // Find Latitude longitude of CPA from address
                string address = string.Concat(newCPA.Address1, " ", newCPA.Address2, " ", newCPA.City, " ", newCPA.State, " ", newCPA.ZipCode);
                FindCoordinatesOfCPA(address, newCPA);

                //TODO: check how to handle speciality
                // newCPA.SpecialityID = ddlSpeciality.SelectedValue;
                newCPA.Speciality = txtSpeciality.Text;

                if (ImageUpload != null && ImageUpload.PostedFile != null)
                {
                    int    len = ImageUpload.PostedFile.ContentLength;
                    byte[] pic = new byte[len];
                    ImageUpload.PostedFile.InputStream.Read(pic, 0, len);
                    newCPA.Image = pic;
                }
                else
                {
                    newCPA.Image = new byte[0];
                }

                newCPA.ActivationToken = userGuid.ToString();
                newCPA.CreatedDate     = DateTime.Now;

                bool result = BusinessLogic.CreateNewTempCPA(newCPA);
                if (result)
                {
                    Response.Redirect("~/CPA/VerifyEmail.aspx?Email=" + txtEmail.Text);
                }
            }
        }
Exemplo n.º 6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!Isvalididate())
                return;

            CPADetails CPAUser =new CPADetails();
            //TODO: use calendar control
            CPAUser.UserID = Session["userID"].ToString();
            //customer.UserID = "3";
            CPAUser.CompanyName=txtCompanyName.Text;
            CPAUser.Address1=txtOfficeAddress1.Text;
            CPAUser.Address2=txtOfficeAddress2.Text;
            CPAUser.City = ddlCity.SelectedItem.Text;
            CPAUser.State = ddlState.SelectedItem.Text;
            CPAUser.ZipCode=txtZipCode.Text;
            CPAUser.PhoneNumber = txtPhNumberPart1.Text + "-" + txtPhNumberPart2.Text + "-" + txtPhNumberPart3.Text;
            CPAUser.FirstName = txtFirstName.Text;
            CPAUser.LastName = txtLastName.Text;
              //  CPAUser.Image=
               // string str = txtDD.Text + "/" + txtMM.Text + "/" + txtYYYY.Text;
            CPAUser.DateOfBirth = DateTime.Parse(txtDOB.Text);
            CPAUser.Gender = rbtnMale.Checked ? "M" : "F";
            //if (ddlSpeciality.SelectedValue == "Other")
            //{
            //    CPAUser.Speciality = BusinessLogic.GetNewSpecialityID().ToString();
            //}
            //else
            //{
            //    CPAUser.Speciality = ddlSpeciality.SelectedValue;
            //}
            CPAUser.SpecialityID = ddlSpeciality.SelectedValue;
            CPAUser.Speciality = txtSpeciality.Text;
            CPAUser.Email = txtEmail.Text;
            CPAUser.Password = txtPassword.Text;

            //Session["Image"] = "Handler.ashx?QueryCPAID=" + Session["userID"];
            if (ImageUpload.HasFile)
            {
                int len = ImageUpload.PostedFile.ContentLength;
                byte[] pic = new byte[len];
                ImageUpload.PostedFile.InputStream.Read(pic, 0, len);
                CPAUser.Image = pic;

            }
            else
            {
                CPAUser.Image=BusinessLogic.GetCPAImage(int.Parse(Session["userID"].ToString()));
            }
            //CPAUser.DateOfBirth = DateTime.Parse(txtDD.Text + "/" + txtMM.Text + "/" + txtYYYY.Text);

             bool result=BusinessLogic.UpdateCPADetails(CPAUser);

             if (result)
             {
                 Session["userName"] = txtFirstName.Text;
                System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('Save Sucessful')</SCRIPT>");
                RefreshUserDetails();
                pnlEditCPAProfile.Visible = false;
                pnlCPAProfile.Visible = true;
             }
        }
Exemplo n.º 7
0
        protected void btnSignUp_Click(object sender, EventArgs e)
        {
            if (!Isvalididate())
                return;
            Guid userGuid1 = Guid.NewGuid();
            string userGuid = userGuid1.ToString();
            if (!SendEmail1(userGuid))
            {
                return;
            }
            if (Page.IsValid)
            {
                CPADetails newCPA = new CPADetails();
                //TODO: use calendar control
                newCPA.CompanyName = txtCompanyName.Text;
                newCPA.DateOfBirth = DateTime.Parse(txtDOB.Text);
                newCPA.Email = txtEmail.Text;
                newCPA.FirstName = txtFirstName.Text;
                newCPA.LastName = txtLastName.Text;
                newCPA.Password = txtPassword.Text;
                newCPA.PhoneNumber = txtPhNumberPart1.Text + '-' + txtPhNumberPart2.Text + '-' + txtPhNumberPart3.Text;
                newCPA.Gender = rbtnMale.Checked ? "M" : "F";

                newCPA.Address1 = txtOfficeAddress1.Text;
                newCPA.Address2 = txtOfficeAddress2.Text;
                newCPA.ZipCode = txtZipCode.Text;
                newCPA.State = ddlState.SelectedItem.Text;
                newCPA.City = ddlCity.SelectedItem.Text;

                //TODO: check how to handle speciality
               // newCPA.SpecialityID = ddlSpeciality.SelectedValue;
                newCPA.Speciality = txtSpeciality.Text ;

                int len = ImageUpload.PostedFile.ContentLength;
                byte[] pic = new byte[len];
                ImageUpload.PostedFile.InputStream.Read(pic, 0, len);
                newCPA.Image = pic;

                newCPA.ActivationToken = userGuid.ToString();
                newCPA.CreatedDate = DateTime.Now;

                bool result = BusinessLogic.CreateNewTempCPA(newCPA);
                //if (result)
                //{
                //    //TODO: set login user name. FormsAuthentication.SetCookies
                //    Session["roleID"] = 2;

                //    string user;

                //    if ((user = BusinessLogic.GetLoggedInCPAName(txtEmail.Text, txtPassword.Text)) != null)
                //    {
                //        Session["userName"] = user;
                //    }
                //    int userID = BusinessLogic.GetNewUserID();
                //    Session["userID"] = userID;
                //    Response.Redirect("~/CPA/ManageAppointment.aspx");
                //}
                if (result)
                {

                    Response.Redirect("~/CPA/VerifyEmail.aspx?Email=" + txtEmail.Text);
                }
            }
        }
Exemplo n.º 8
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!Isvalididate())
            {
                return;
            }

            CPADetails CPAUser = new CPADetails();

            //TODO: use calendar control
            CPAUser.UserID = Session["userID"].ToString();
            //customer.UserID = "3";
            CPAUser.CompanyName = txtCompanyName.Text;
            CPAUser.Address1    = txtOfficeAddress1.Text;
            CPAUser.Address2    = txtOfficeAddress2.Text;
            CPAUser.City        = ddlCity.SelectedItem.Text;
            CPAUser.State       = ddlState.SelectedItem.Text;
            CPAUser.ZipCode     = txtZipCode.Text;
            CPAUser.PhoneNumber = txtPhoneNumber.Text;
            CPAUser.FirstName   = txtFirstName.Text;
            CPAUser.LastName    = txtLastName.Text;
            //  CPAUser.Image=
            // string str = txtDD.Text + "/" + txtMM.Text + "/" + txtYYYY.Text;
            CPAUser.DateOfBirth = DateTime.Parse(txtDateOfBirth.Text);
            CPAUser.Gender      = rbtnMale.Checked ? "M" : "F";
            //if (ddlSpeciality.SelectedValue == "Other")
            //{
            //    CPAUser.Speciality = BusinessLogic.GetNewSpecialityID().ToString();
            //}
            //else
            //{
            //    CPAUser.Speciality = ddlSpeciality.SelectedValue;
            //}
            CPAUser.SpecialityID = ddlSpeciality.SelectedValue;
            CPAUser.Speciality   = txtSpeciality.Text;
            CPAUser.Email        = txtEmail.Text;
            //CPAUser.Password = txtPassword.Text;

            //Session["Image"] = "Handler.ashx?QueryCPAID=" + Session["userID"];
            if (ImageUpload.HasFile)
            {
                int    len = ImageUpload.PostedFile.ContentLength;
                byte[] pic = new byte[len];
                ImageUpload.PostedFile.InputStream.Read(pic, 0, len);
                CPAUser.Image = pic;
            }
            else
            {
                CPAUser.Image = BusinessLogic.GetCPAImage(int.Parse(Session["userID"].ToString()));
            }
            if (CPAUser.Image == null)
            {
                CPAUser.Image = new byte[0];
            }

            bool result = BusinessLogic.UpdateCPADetails(CPAUser);

            if (result)
            {
                Session["userName"] = txtFirstName.Text;
                System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('Save Sucessful')</SCRIPT>");
                RefreshUserDetails();
            }
        }
Exemplo n.º 9
0
        protected void FindCoordinatesOfCPA(string address, CPADetails newCPA)
        {
            double latitutde = 0;
            double longitutde = 0;

            string url = "http://maps.google.com/maps/api/geocode/xml?address=" + address + "&sensor=false";
            WebRequest request = WebRequest.Create(url);
            using (WebResponse response = (HttpWebResponse)request.GetResponse())
            {
                using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
                {
                    DataSet dsResult = new DataSet();
                    dsResult.ReadXml(reader);
                    DataTable dtCoordinates = new DataTable();
                    dtCoordinates.Columns.AddRange(new DataColumn[4] { new DataColumn("Id", typeof(int)),
                    new DataColumn("Address", typeof(string)),
                    new DataColumn("Latitude",typeof(string)),
                    new DataColumn("Longitude",typeof(string)) });
                    foreach (DataRow row in dsResult.Tables["result"].Rows)
                    {
                        string geometry_id = dsResult.Tables["geometry"].Select("result_id = " + row["result_id"].ToString())[0]["geometry_id"].ToString();
                        DataRow location = dsResult.Tables["location"].Select("geometry_id = " + geometry_id)[0];
                        dtCoordinates.Rows.Add(row["result_id"], row["formatted_address"], location["lat"], location["lng"]);

                        double.TryParse(location["lat"].ToString(), out latitutde);
                        double.TryParse(location["lng"].ToString(), out longitutde);
                        newCPA.Latitude = latitutde;
                        newCPA.Longitude = longitutde;
                    }
                    if (dtCoordinates.Rows.Count > 0)
                    {
                        //pnlScripts.Visible = true;
                        //rptMarkers.DataSource = dtCoordinates;
                        //rptMarkers.DataBind();
                    }
                }
            }
        }