protected void RegisterButton_Click(object sender, EventArgs e)
    {
        AccessDB dbObj = new AccessDB();
        dbObj.Open();
        //verify if registration record already exists
        dbObj.Query = string.Format("select userregisterationid from tbluserregisteration where EmailID='{0}'", Email.Text); ;
        dbObj.ExecuteQuery();
        if (dbObj.Dataset.Tables[0].Rows.Count > 0)
        {
            ConfirmationLabel.Style.Add("color", "Red");
            ConfirmationLabel.Text = string.Format("Sorry! Our system shows an account is already registered with this email -{0}. If you have forgotten your password, use the 'Forgot Password' link to get your password.", Email.Text);
            ConfirmationLabel.Visible = true;
        }
        else
        {
            dbObj.Dataset.Reset();
            //Insert details into the db
            dbObj.Query = string.Format(@"insert into tblUserRegisteration (FirstName,LastName,FamilyBranch,BornInto,HomePhone,EmailID,Passwd,Address1,Address2,City,State,Country,Pincode,RegistrationDate)
                                    values('{0}','{1}','{2}','{3}','{4}','{5}',AES_ENCRYPT('{6}','{7}'),'{8}','{9}','{10}','{11}','{12}',{13},current_timestamp()); "
                                        , FirstName.Text, LastName.Text, FamilyBranch.SelectedValue, rdlConnection.SelectedValue, PhoneNumber.Text, Email.Text, Password.Text, Constants.AESKey, Address1.Text, Address2.Text, CityDitrict.Text, State.Text
                                        , Country.Text, int.Parse(PinCode.Text));
            dbObj.ExecuteNonQuery();

            //Get the current users' userregisterationid
            dbObj.Dataset.Reset();
            dbObj.Query = string.Format("select userregisterationid, registrationDate from tbluserregisteration where EmailID='{0}' and FirstName='{1}' and LastName='{2}'", Email.Text, FirstName.Text, LastName.Text); ;
            dbObj.ExecuteQuery();
            long UserRegID = (long)dbObj.Dataset.Tables[0].Rows[0][0];
            DateTime dtReg = (DateTime)dbObj.Dataset.Tables[0].Rows[0][1];
            //Mail to admin
            string mailBody = string.Format(Constants.AdminMailText) + Environment.NewLine + string.Format("\n\nFirstName:{0}\nLastName:{1}\nFamily:{2}\nAddress:{3}\nEmail:{4}\nHomePhone:{5}\nRegisteration Date:{6}"
                                                        , FirstName.Text, LastName.Text, FamilyBranch.Text, string.Concat(Address1.Text, ",", Address2.Text, ",", CityDitrict.Text, "-", PinCode.Text, ",", State.Text, ",", Country.Text, ","), Email.Text, PhoneNumber.Text, dtReg)
                                                        + Environment.NewLine + "http://www.Kallivayalil.com/ActivateUser.aspx?UserRegID=" + UserRegID.ToString();

            dbObj.Dataset.Reset();
            dbObj.Query = string.Format(@"Select emailaddress from tbluserlogin where isadmin=true");
            dbObj.ExecuteQuery();

            for (int i = 0; i < dbObj.Dataset.Tables[0].Rows.Count; i++)
            {
                SendMailMessage(dbObj.Dataset.Tables[0].Rows[i][0].ToString(), "*****@*****.**", mailBody);
            }

            //mail to user.
            mailBody = string.Empty;
            mailBody = string.Format(Constants.UserMailText) + Environment.NewLine + string.Format("\n\nFirstName:{0}\nLastName:{1}\nFamily:{2}\nAddress:{3}\nEmail:{4}\nHomePhone:{5}\nRegistration Date:{6}"
                                                        , FirstName.Text, LastName.Text, FamilyBranch.Text, string.Concat(Address1.Text, ",", Address2.Text, ",", CityDitrict.Text, "-", PinCode.Text, ",", State.Text, ",", Country.Text, ","), Email.Text, PhoneNumber.Text, dtReg);
            SendMailMessage(Email.Text, "RegistrationMail @ Kallivayalil.com", mailBody);

            ConfirmationLabel.Style.Add("color", "Green");
            ConfirmationLabel.Text = "Thank You for registering. A confirmation email has been sent to the emailaddress you provided. We will review your information and your account will be activated at the earliest.";
            ConfirmationLabel.Visible = true;
            UserRegistration.Visible = false;
        }
        dbObj.Close();
    }
    protected void SubmitBtn_Click(object sender, EventArgs e)
    {
        AccessDB dbObj = new AccessDB();
        dbObj.Open();
        dbObj.Query = string.Format("Select emailaddress,CAST( AES_DECRYPT( passwd, 'kalli' ) AS CHAR( 100 ) ) from tbluserlogin where emailaddress ='{1}'", Constants.AESKey, UserNameTbx.Text);
        dbObj.ExecuteQuery();

        if (dbObj.Dataset.Tables[0].Rows.Count > 0)
        {
            Mail mailObj = new Mail();
            mailObj.To = UserNameTbx.Text;
            mailObj.Subject = "Reply: Forgot Password Request";
            mailObj.MailBody = string.Format("Dear Ma'am/Sir, \r\n Username:{0} \r\n Password:{1} \r\n Regards, \r\n Admin team.", UserNameTbx.Text, dbObj.Dataset.Tables[0].Rows[0][1]);
            mailObj.SendMailMessage();

            VerificationLbl.Text = "Your password has been sent to your email.";
            VerificationLbl.Visible = true;
        }
        else
        {
            VerificationLbl.Text = "The UserName provided is not valid.Kindly verify and retry / contact the Admin Team.";
            VerificationLbl.Visible = true;
        }
        dbObj.Close();
    }
示例#3
0
 private void BindData()
 {
     AccessDB dbObj = new AccessDB();
     dbObj.Open();
     dbObj.Query = string.Format("Select * from tblspecialevents where eventname ={0} and eventdate='{1}'", Session["EventName"], Session["EventDate"]);
     dbObj.ExecuteQuery();
     DetailsView1.DataSource = dbObj.Dataset;
     DetailsView1.DataBind();
     dbObj.Close();
 }
示例#4
0
    public DataSet GetData()
    {
        string eventQuery = string.Empty;
        if (Session["UserLogin"] != null)
        {
            eventQuery = "Select eventname, eventdate, eventtype, eventdetails from tblspecialevents ";
        }
        else
        {
            eventQuery = "Select eventname, eventdate, eventtype, eventdetails from tblspecialevents where IsPublic=1";
        }

        dbObj = new AccessDB();
        dbObj.Open();

        dbObj.Query = eventQuery;
        dbObj.ExecuteQuery();

        DataSet ds = new DataSet();
        DataTable dt = new DataTable("News");
        DataRow dr;
        dt.Columns.Add(new DataColumn("Id", typeof(Int32)));
        dt.Columns.Add(new DataColumn("Url", typeof(string)));
        dt.Columns.Add(new DataColumn("Desc", typeof(string)));
        string eventImage="images/celebration.gif";
        string eventTitle = string.Empty;
        string eventDetails = string.Empty;
        string eventType = string.Empty;
        DateTime dtobj = DateTime.Now;
        for (int i = 0; i < dbObj.Dataset.Tables[0].Rows.Count; i++)
        {

            dr = dt.NewRow();
            dr[0] = i + 1;
            dtobj = (DateTime)dbObj.Dataset.Tables[0].Rows[i][1];
            eventTitle = String.Format("{0} on {1}/{2}/{3}<br/>", dbObj.Dataset.Tables[0].Rows[i][0], dtobj.Day, dtobj.Month, dtobj.Year);
            eventDetails = String.Format("<u>Event Details</u>:<br/> {0}", dbObj.Dataset.Tables[0].Rows[i][3]);
            eventType = dbObj.Dataset.Tables[0].Rows[i][2].ToString();
            eventImage=GetEventImage(eventType);
            dr[1] = string.Format("javascript:openQuickAddDialog(1000, 101, '{0}','{1}','{2}');", eventTitle, eventDetails, eventImage);
            //dr[1] = string.Format("Event.aspx?EventName={0}&EventDate={3}-{2}-{1}", dbObj.Dataset.Tables[0].Rows[i][0], dtobj.Day, dtobj.Month, dtobj.Year);

            dr[2] = eventTitle;
            dt.Rows.Add(dr);
        }
        ds.Tables.Add(dt);
        Session["dt"] = dt;
        dbObj.Close();
        return ds;
    }
    private void refreshGrid()
    {
        DataSet ds = new DataSet();
        ds.Tables.Add(new DataTable());

        DataTable dt = new DataTable();
        dt.Columns.Add("EventName");
        dt.Columns.Add("EventType");
        dt.Columns.Add("EventDetails");
        dt.Columns.Add("EventDate");
        dt.Columns.Add("ContactPerson");
        dt.Columns.Add("ContactNumber");

        AccessDB dbobj = new AccessDB();
        dbobj.Open();
        //if (d3.Text == string.Empty)
        //    d3.Text = "01.01.2000";
        //if (d4.Text == string.Empty)
        //    d4.Text = "12.31.2030";
        string whereclause = string.Empty;
        if (d3.Text != string.Empty && d4.Text != string.Empty)
            whereclause = string.Format(" where eventdate between STR_TO_DATE('{0}','%M %d, %Y')  and STR_TO_DATE('{1}','%M %d, %Y')", d3.Text, d4.Text);
        dbobj.Dataset.Reset();

        dbobj.Query = string.Format("Select SocialEventID,eventname as EventName,eventtype as EventType,eventdetails as EventDetails,startdate as StartDate,DATE_FORMAT(eventdate, '%a %d %b, %Y') as EventDate,contactperson as ContactPerson,contactnumber as ContactNumber,ispublic,updatedby,DATE_FORMAT(updateddate,'%d/%m/%y') as updateddate from tblspecialevents" + whereclause);
        dbobj.ExecuteQuery();

        for (int i = 0; i < dbobj.Dataset.Tables[0].Rows.Count; i++)
        {
            dt.ImportRow(dbobj.Dataset.Tables[0].Rows[i]);
        }

        GridView1.DataSource = dt;
        GridView1.DataBind();
        dbobj.Close();
    }
示例#6
0
    private void BindData()
    {
        string spouseQuery = "Select 'SProfile.aspx' Page, s.SpID UserProfileID,s.FirstName,s.LastName,s.PreferredName,l.EmailAddress,u.FamilyBranch,s.MobilePhone,u.Address1, u.Address2,u.City,u.State,u.Country from tblspouse s left outer join tbluserlogin l on s.SpID=l.UserProfileID left outer join tbluserprofile u on s.SpouseID=u.UserProfileID where ";
        AccessDB dbObj = new AccessDB();
        dbObj.Open();
        dbObj.Query = "Select 'ViewProfile.aspx' Page,u.UserProfileID UserProfileID,u.FirstName,u.LastName,u.PreferredName,l.EmailAddress,u.FamilyBranch,u.HomePhone,u.Address1, u.Address2,u.City,u.State,u.Country from tbluserprofile u left outer join tbluserlogin l on u.UserProfileID=l.UserProfileID where ";
        string searchOperator = rdlMatchOption.SelectedValue;
        if (ddlFamilyBranch.SelectedValue != string.Empty)
        {
            dbObj.Query += string.Format(" FamilyBranch= '{0}' {1}"
                                               , ddlFamilyBranch.SelectedValue, searchOperator);
            spouseQuery += string.Format(" FamilyBranch= '{0}' {1}"
                                               , ddlFamilyBranch.SelectedValue, searchOperator);
        }
        if (txtName.Text != string.Empty)
        {
            dbObj.Query += string.Format(" (u.FirstName like '%{0}%' OR u.LastName like '%{0}%' OR u.PreferredName like '%{0}%') {1}"
                                               , txtName.Text, searchOperator);
            spouseQuery += string.Format(" (s.FirstName like '%{0}%' OR s.LastName like '%{0}%' OR s.PreferredName like '%{0}%') {1}"
                                               , txtName.Text, searchOperator);
        }

        if (txtPlace.Text != string.Empty)
        {
            dbObj.Query += string.Format(" (Country like '%{0}%' OR State like '%{0}%' OR City like '%{0}%' OR Address1 like '%{0}%' OR Address2 like '%{0}%') {1}", txtPlace.Text, searchOperator);
            spouseQuery += string.Format(" (Country like '%{0}%' OR State like '%{0}%' OR City like '%{0}%' OR Address1 like '%{0}%' OR Address2 like '%{0}%') {1}", txtPlace.Text, searchOperator);
        }

        if (dbObj.Query.EndsWith(searchOperator))
            dbObj.Query = dbObj.Query.Substring(0, dbObj.Query.Length - searchOperator.Length);
        else
            dbObj.Query = dbObj.Query.Substring(0, dbObj.Query.Length - 6);

        if (spouseQuery.EndsWith(searchOperator))
            spouseQuery = spouseQuery.Substring(0, spouseQuery.Length - searchOperator.Length);
        else
            spouseQuery = spouseQuery.Substring(0, spouseQuery.Length - 6);

        dbObj.Query = dbObj.Query + " union " + spouseQuery;
        dbObj.ExecuteQuery();

        grdSearch.DataSource = dbObj.Dataset;
        grdSearch.DataBind();

        //setting the color for the ppl who have passed away
        dbObj.Dataset.Reset();
        dbObj.Query = "select isdead from tbluserprofile where";
        searchOperator = rdlMatchOption.SelectedValue;
        if (ddlFamilyBranch.SelectedValue != string.Empty)
        {
            dbObj.Query += string.Format(" FamilyBranch= '{0}' {1}"
                                               , ddlFamilyBranch.SelectedValue, searchOperator);
        }
        if (txtName.Text != string.Empty)
        {
            dbObj.Query += string.Format(" (FirstName like '%{0}%' OR LastName like '%{0}%' OR PreferredName like '%{0}%') {1}"
                                               , txtName.Text, searchOperator);
        }

        if (txtPlace.Text != string.Empty)
        {
            dbObj.Query += string.Format(" (Country like '%{0}%' OR State like '%{0}%' OR City like '%{0}%' OR Address1 like '%{0}%' OR Address2 like '%{0}%') {1}", txtPlace.Text, searchOperator);
        }

        if (dbObj.Query.EndsWith(searchOperator))
            dbObj.Query = dbObj.Query.Substring(0, dbObj.Query.Length - searchOperator.Length);
        else
            dbObj.Query = dbObj.Query.Substring(0, dbObj.Query.Length - 6);
        dbObj.ExecuteQuery();

        for (int i = 0; i < dbObj.Dataset.Tables[0].Rows.Count; i++)
        {
            if ((short)dbObj.Dataset.Tables[0].Rows[i][0] == 1)
                gridCol.Add(i, Color.Red);
            else
                gridCol.Add(i, Color.Black);
        }
        if (grdSearch.Rows.Count > 0)
            Label2.Visible = true;
        else
            Label2.Visible = false;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        string UserName = (string)Session["UserLogin"];
        if (UserName == null)
        {
            Session.Add("PageToLoad", "http://www.kallivayalil.com/Kallivayalil/LinkProfile.aspx");
            Response.Redirect("default.aspx");
        }

        if (Session["SelectedProfileID"] == null)
        {
            ProfileDetailslbl.Visible = false;
            RadioButtonList1.Visible = false;
            NewUserLbl.ForeColor = Color.Green;
            NewUserLbl.Visible = true;
        }
        else
        {
            if (Session["Borninto"].ToString() == "B")
            {
                dbObj = new AccessDB();
                dbObj.Dataset.Reset();
                dbObj.Query = string.Format(@"SELECT tbluserprofile.UserProfileID,Salutation, FirstName, MiddleName,
                                        LastName, PreferredName, Gender, FamilyBranch, HouseName, BornOn, MaritalStatus,
                                        Occupation, Employer,  AlternateEmailAddress, Address1,Address2, City, State, Pincode,
                                        Country, HomePhone, MobilePhone, Website  FROM tbluserprofile WHERE
                                        ((UserProfileID = {0}) and IsActive!=1)", Session["SelectedProfileID"]);
                dbObj.ExecuteQuery();
                DetailsView2.DataSource = dbObj.Dataset.Tables[0];
                DetailsView2.DataBind();
                dbObj.Close();

            }
            else
            {
                dbObj = new AccessDB();
                dbObj.Dataset.Reset();
                dbObj.Query = string.Format(@"SELECT tblspouse.spid,tblspouse.Salutation, tblspouse.FirstName,
                                        tblspouse.LastName, tblspouse.PreferredName, tblspouse.Gender, tblspouse.Familyname, tblspouse.BornOn,
                                        tbluserprofile.City, tbluserprofile.State, tbluserprofile.Pincode,
                                        tbluserprofile.Country, tbluserprofile.mobilePhone  FROM tblspouse,tbluserprofile WHERE
                                        ((spid = {0}) and tblspouse.IsActive!=1)", Session["SelectedProfileID"]);
                dbObj.ExecuteQuery();
                DetailsView2.DataSource = dbObj.Dataset.Tables[0];
                DetailsView2.DataBind();
                dbObj.Close();
            }

        }
    }
    private void registerNewUser(out string emailID, out string activatedUser)
    {
        newUser = true;
        dbObj = new AccessDB();
        dbObj.Open();
        bool isAdmin = false;
        char ProfileType = 'U';
        if (CheckBox1.Checked)
            isAdmin = true;

        //Fetch the row for the registeration table.
        dbObj.Query = string.Format(@"Select borninto,emailID,passwd,firstName,LastName,FamilyBranch,HomePhone
                                ,Address1,Address2,city,state,country,pincode from tbluserregisteration
                                    where userregisterationid={0} "
                            , Session["UserRegID"]);
        dbObj.ExecuteQuery();
        emailID = (string)dbObj.Dataset.Tables[0].Rows[0][1];
        string borninto = dbObj.Dataset.Tables[0].Rows[0][0].ToString();
        //Add entry to the profile table and set the selectedProfileID to the new entry's ID.

        if (dbObj.Dataset.Tables[0].Rows[0][0].ToString() == "B")
        {
            //insert into the profile table -> borninto is true
            dbObj.Query = string.Format(@"insert into tbluserprofile (firstname,lastname,familyBranch,homephone,address1,address2,city
                                         ,state,country,pincode,createddate,isactive) values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}',curdate(),1)"
                                        , dbObj.Dataset.Tables[0].Rows[0][3], dbObj.Dataset.Tables[0].Rows[0][4], dbObj.Dataset.Tables[0].Rows[0][5]
                                        , dbObj.Dataset.Tables[0].Rows[0][6], dbObj.Dataset.Tables[0].Rows[0][7], dbObj.Dataset.Tables[0].Rows[0][8]
                                        , dbObj.Dataset.Tables[0].Rows[0][9], dbObj.Dataset.Tables[0].Rows[0][10], dbObj.Dataset.Tables[0].Rows[0][11]
                                        , dbObj.Dataset.Tables[0].Rows[0][12]);
            dbObj.ExecuteNonQuery();

            //fetch the last inserted userprofileid from tbluserprofile
            dbObj.Dataset.Reset();
            dbObj.Query = "select max(userprofileid) from tbluserprofile";
            dbObj.ExecuteQuery();
            Session.Add("SelectedProfileID", dbObj.Dataset.Tables[0].Rows[0][0]);
        }
        else
        {
            //insert into the spouse table when borninto is false.
            dbObj.Query = string.Format(@"insert into tblspouse (firstname,lastname,mobilephone,emailaddress,activationdate,activatedby,isactive) values ('{0}','{1}','{2}','{3}',curdate(),'{4}',1)"
                                        , dbObj.Dataset.Tables[0].Rows[0][3], dbObj.Dataset.Tables[0].Rows[0][4], dbObj.Dataset.Tables[0].Rows[0][6]
                                        , dbObj.Dataset.Tables[0].Rows[0][1],Session["UserLogin"]);
            dbObj.ExecuteNonQuery();
            //fetchin the spouseid field is an issue here ...
            //fetch the last inserted userprofileid from tbluserprofile
            dbObj.Dataset.Reset();
            dbObj.Query = "select max(spid) from tblspouse";
            dbObj.ExecuteQuery();
            Session.Add("SelectedProfileID", dbObj.Dataset.Tables[0].Rows[0][0]);
            ProfileType = 'S';

        }

        //Fetch the row for the registeration table.
        dbObj.Dataset.Reset();
        dbObj.Query = string.Format(@"Select borninto,emailID,passwd,firstName,LastName,FamilyBranch,HomePhone
                                ,Address1,Address2,city,state,country,pincode from tbluserregisteration
                                    where userregisterationid={0} "
                               , Session["UserRegID"]);
        dbObj.ExecuteQuery();

        //insert a row into the tbluserlogin table.Link the profile ID to the Login table.
        string temp = string.Format(@"Insert into tbluserlogin (userprofileid,profileType,emailaddress,passwd,
                                        creationdate,updationdate,updatedby,activationdate,activatedby
                                    ,isadmin) values({0},'{6}','{1}',(select passwd as pass from tbluserregisteration where userregisterationid = {5}),curdate(),curdate(),'{2}',curdate(),'{3}',{4})",
                                    Session["SelectedProfileID"], dbObj.Dataset.Tables[0].Rows[0][1]
                                    , Session["UserLogin"], Session["UserLogin"], isAdmin, Session["UserRegID"], ProfileType);

        dbObj.Query = temp;
        dbObj.ExecuteNonQuery();
        isAdmin = false;
        if (borninto == "B")
        {
            if (RadioButtonList1.Items[0].Selected)
            {

                //update isactive,updation date,updated by in tbluserprofile.
                dbObj.Query = string.Format(@"Update tbluserprofile set Isactive=true,createddate=curdate()
                                    ,updateddate=curdate(),updatedby='{0}',firstName='{2}',lastName='{3}',FamilyBranch='{4}',HomePhone='{5}'
                                    ,Address1='{6}',Address2='{7}',city='{8}',state='{9}',country='{10}',pincode='{11}' where UserProfileID = {1}"
                                            , Session["UserLogin"], Session["SelectedProfileID"], dbObj.Dataset.Tables[0].Rows[0][2]
                                            , dbObj.Dataset.Tables[0].Rows[0][3], dbObj.Dataset.Tables[0].Rows[0][4], dbObj.Dataset.Tables[0].Rows[0][5]
                                            , dbObj.Dataset.Tables[0].Rows[0][6], dbObj.Dataset.Tables[0].Rows[0][7], dbObj.Dataset.Tables[0].Rows[0][8]
                                            , dbObj.Dataset.Tables[0].Rows[0][9], dbObj.Dataset.Tables[0].Rows[0][10], dbObj.Dataset.Tables[0].Rows[0][11]);
                dbObj.ExecuteNonQuery();
            }
            else if (RadioButtonList1.Items[1].Selected)
            {
                //update isactive,updation date,updated by in tbluserprofile.
                dbObj.Query = string.Format(@"Update tbluserprofile set Isactive=true,createddate=curdate()
                                    ,updateddate=curdate(),updatedby='{0}' where UserProfileID = {1}"
                                            , Session["UserLogin"], Session["SelectedProfileID"]);
                dbObj.ExecuteNonQuery();

            }
        }
        else if (borninto == "M")
        {

            if (RadioButtonList1.Items[0].Selected)
            {

                //update isactive,updation date,updated by in tbluserprofile.
                dbObj.Query = string.Format(@"Update tblspouse set Isactive=true
                                    ,updateddate=curdate(),updatedby='{0}',firstName='{2}',lastName='{3}',mobilePhone='{4}'
                                    emailID='{5}' where UserProfileID = {1}"
                                            , Session["UserLogin"], Session["SelectedProfileID"], dbObj.Dataset.Tables[0].Rows[0][2]
                                            , dbObj.Dataset.Tables[0].Rows[0][3], dbObj.Dataset.Tables[0].Rows[0][5], dbObj.Dataset.Tables[0].Rows[0][0]
                                          );
                dbObj.ExecuteNonQuery();
            }
            else if (RadioButtonList1.Items[1].Selected)
            {
                //update isactive,updation date,updated by in tbluserprofile.
                dbObj.Query = string.Format(@"Update tblspouse set Isactive=true,activationdate=curdate(),activatedby = '{0}'
                                    ,updateddate=curdate(),updatedby='{0}' where UserProfileID = {1}"
                                            , Session["UserLogin"], Session["SelectedProfileID"]);
                dbObj.ExecuteNonQuery();

            }
        }

        dbObj.Dataset.Reset();
        dbObj.Query = string.Format(@"select emailID from tbluserregisteration where userregisterationid={0} "
                                    , Session["UserRegID"]);
        dbObj.ExecuteQuery();

        activatedUser = dbObj.Dataset.Tables[0].Rows[0][0].ToString();

        //delete entry from the registeration table.
        dbObj.Query = string.Format(@"delete from tbluserregisteration
                                    where userregisterationid={0} "
                                    , Session["UserRegID"]);
        dbObj.ExecuteNonQuery();
    }
    private void registerExistingUser(out string emailID, out string activatedUser)
    {
        dbObj = new AccessDB();
        dbObj.Open();
        bool isAdmin = false;
        char ProfileType = 'U';
        //Fetch the row for the registeration table.
        dbObj.Query = string.Format(@"Select borninto,emailID,passwd,firstName,LastName,FamilyBranch,HomePhone
                                ,Address1,Address2,city,state,country,pincode from tbluserregisteration
                                    where userregisterationid={0} "
                            , Session["UserRegID"]);
        dbObj.ExecuteQuery();

        if (CheckBox1.Checked)
            isAdmin = true;

        if (dbObj.Dataset.Tables[0].Rows[0][0].ToString() == "M")
            ProfileType = 'S';

        //insert a row into the tbluserlogin table.Link the profile ID to the Login table.
        string temp = string.Format(@"Insert into tbluserlogin (userprofileid,profiletype,emailaddress,passwd,
                                        creationdate,updationdate,updatedby,activationdate,activatedby
                                    ,isadmin) values({0},'{6}','{1}',(select passwd as pass from tbluserregisteration where userregisterationid = {5}),curdate(),curdate(),'{2}',curdate(),'{3}',{4})",
                                    Session["SelectedProfileID"], dbObj.Dataset.Tables[0].Rows[0][1]
                                    , Session["UserLogin"], Session["UserLogin"], isAdmin, Session["UserRegID"],ProfileType);
        emailID = (string)dbObj.Dataset.Tables[0].Rows[0][1];
        dbObj.Query = temp;
        dbObj.ExecuteNonQuery();
        isAdmin = false;

        if (RadioButtonList1.Items[0].Selected)
        {

            //update isactive,updation date,updated by in tbluserprofile.
            dbObj.Query = string.Format(@"Update tbluserprofile set Isactive=true,createddate=curdate()
                                    ,updateddate=curdate(),updatedby='{0}',firstName='{2}',lastName='{3}',FamilyBranch='{4}',HomePhone='{5}'
                                    ,Address1='{6}',Address2='{7}',city='{8}',state='{9}',country='{10}',pincode='{11}' where UserProfileID = {1}"
                                        , Session["UserLogin"], Session["SelectedProfileID"], dbObj.Dataset.Tables[0].Rows[0][4]
                                        , dbObj.Dataset.Tables[0].Rows[0][5], dbObj.Dataset.Tables[0].Rows[0][6], dbObj.Dataset.Tables[0].Rows[0][7]
                                        , dbObj.Dataset.Tables[0].Rows[0][8], dbObj.Dataset.Tables[0].Rows[0][9], dbObj.Dataset.Tables[0].Rows[0][10]
                                        , dbObj.Dataset.Tables[0].Rows[0][11], dbObj.Dataset.Tables[0].Rows[0][12], dbObj.Dataset.Tables[0].Rows[0][13]);
            dbObj.ExecuteNonQuery();
        }
        else if (RadioButtonList1.Items[1].Selected)
        {
            //update isactive,updation date,updated by in tbluserprofile.
            dbObj.Query = string.Format(@"Update tbluserprofile set Isactive=true,createddate=curdate()
                                    ,updateddate=curdate(),updatedby='{0}' where UserProfileID = {1}"
                                        , Session["UserLogin"], Session["SelectedProfileID"]);
            dbObj.ExecuteNonQuery();

        }

        dbObj.Query = string.Format(@"select emailID from tbluserregisteration where userregisterationid={0} "
                                    , Session["UserRegID"]);
        dbObj.ExecuteQuery();

        activatedUser = dbObj.Dataset.Tables[0].Rows[0][0].ToString();

        //delete entry from the registeration table.
        dbObj.Query = string.Format(@"delete from tbluserregisteration
                                    where userregisterationid={0} "
                                    , Session["UserRegID"]);
        dbObj.ExecuteNonQuery();
    }
    protected void LoginButton_Click(object sender, ImageClickEventArgs e)
    {
        AccessDB dbObj = new AccessDB();
        string userName = string.Empty;
        string paswd = string.Empty;

        //Retrieving the Username and Password entered by the user.
        userName = Login1.UserName;
        paswd = Login1.Password;

        dbObj.Open();
        dbObj.Query = string.Format("Select * from tbluserlogin where EmailAddress='{0}' and Passwd=AES_ENCRYPT('{1}','{2}')"
            , userName, paswd,Constants.AESKey);
        dbObj.ExecuteQuery();

        if (dbObj.Dataset.Tables[0].Rows.Count > 0)
        {
            //Username and pasword exists for this user.
            Session.Add("UserLogin", userName);
            Session.Add("ID", dbObj.Dataset.Tables[0].Rows[0]["UserProfileID"]);
            Session.Add("IsAdmin", dbObj.Dataset.Tables[0].Rows[0][7]);
            Session.Add("PType", dbObj.Dataset.Tables[0].Rows[0]["ProfileType"]);
            dbObj.Dataset.Clear();
            dbObj.Close();

            dbObj.Query = string.Format("Select * from tbluserprofile where UserProfileID={0}", Session["ID"]);
            dbObj.ExecuteQuery();
            if (dbObj.Dataset.Tables[0].Rows.Count > 0)
            {
                Session.Add("UserName", dbObj.Dataset.Tables[0].Rows[0]["FirstName"] + " " + dbObj.Dataset.Tables[0].Rows[0]["LastName"]);
            }
            if (Session["PageToLoad"] != null)
            {
                Response.Redirect(Session["PageToLoad"].ToString());
                Session.Remove("PageToLoad");
            }
            else
                Response.Redirect("Default.aspx");
        }
        else
        {
            dbObj.Query = string.Format("Select * from tbluserlogin where EmailAddress='{0}'", userName);
            dbObj.ExecuteQuery();
            if (dbObj.Dataset.Tables[0].Rows.Count > 0)
            {
                //Username exists but not activated.
                dbObj.Dataset.Clear();
                dbObj.Close();
                Login1.FailureText = "Login Failed. Incorrect Login Information.";
                Login1.FailureAction = LoginFailureAction.Refresh;
            }
            else
            {
                dbObj.Query = string.Format("Select * from tbluserregisteration where EmailId='{0}'", userName);
                dbObj.ExecuteQuery();
                if (dbObj.Dataset.Tables[0].Rows.Count > 0)
                {
                    //Username exists but not activated.
                    dbObj.Dataset.Clear();
                    dbObj.Close();
                    Login1.FailureText = "Your account has not been activated by the Administrator. Sorry for the delay.";
                    Login1.FailureAction = LoginFailureAction.Refresh;
                }
                else
                {
                    Login1.FailureText = "Invalid User Name and Password.";
                    Login1.FailureAction = LoginFailureAction.Refresh;
                }
            }

        }
    }