protected void updateLogin()
    {
        string sql = "SELECT RELATIONSHIPID FROM USERTABLE UT WHERE UT.USERID='" + ID + "' AND PASSWORD='******' AND STATUS=2";
        Handler hdn = new Handler();
        DataTable dt = hdn.GetTable(sql);
        if (dt.Rows.Count > 0)
        {
            usertable obj1 = new usertable(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
            obj1.usertable_SRNO = -1;
            obj1.usertable_RELATIONSHIPID = -1;
            obj1.usertable_STATUS = 0;
            string condition = "USERID = '" + ID + "' AND PASSWORD = '******'";
            if (obj1.Insert(false, "usertable", condition))
            {
            }

            registrationtable obj = new registrationtable(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
            obj.registrationtable_SRNO = -1;
            obj.registrationtable_SPONSORID = -1;
            obj.registrationtable_STATUS = 0;
            string condition1 = "SRNO =" + dt.Rows[0][0].ToString(); ;
            if (obj.Insert(false, "registrationtable", condition1))
            {
            }
        }

    }
 protected void btnaccount_Click(object sender, EventArgs e)
 {
     string sponsorid = string.Empty;
     Handler hdn = new Handler();
     DataTable dt = hdn.GetTable("SELECT SRNO,NAME FROM REGISTRATIONTABLE RT WHERE SPONSORSEMICODE='" + txtsponsorid.Text.Trim() + "'");
     if (dt.Rows.Count > 0 && dt.Rows[0]["SRNO"].ToString() != string.Empty)
     {
         registrationtable obj = new registrationtable(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
         obj.registrationtable_SRNO = -1;
         obj.registrationtable_NAME = txtname.Text.Trim();
         obj.registrationtable_SEMICODE = txtsemid.Text.Trim();
         obj.registrationtable_PHONENO = txtmobileno.Text.Trim();
         obj.registrationtable_EMAILID = txtemail.Text.Trim();
         if (dt.Rows.Count > 0 && dt.Rows[0]["SRNO"].ToString() != string.Empty)
         {
             obj.registrationtable_SPONSORID = General.Parse<int>(dt.Rows[0]["SRNO"].ToString());
             obj.registrationtable_SPONSORNAME = dt.Rows[0]["NAME"].ToString();
             obj.registrationtable_SPONSORSEMICODE = txtsponsorid.Text.Trim();
         }
         else
         {
             obj.registrationtable_SPONSORID = -1;
         }
         
         obj.registrationtable_STATUS = -1;
         string condition = "SRNO=" + Session["userid"].ToString();
         if (obj.Insert(false, "registrationtable", condition))
         {
             MessageBox("Profile Updated Successfully");
         }
     }
 }
    protected void btnsubmit_Click(object sender, EventArgs e)
    {
        if (txtpassword.Text.Trim() != string.Empty)
        {
            registrationtable obj = new registrationtable(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
            obj.registrationtable_SRNO = -1;
            obj.registrationtable_SPONSORID = -1;
            obj.registrationtable_STATUS = 2;
            string condition = "SRNO=" + ViewState["registrationid"].ToString();
            if (obj.Insert(false, "registrationtable", condition))
            {
                usertable obj1 = new usertable(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
                obj1.usertable_SRNO = -1;
                obj1.usertable_STATUS = 2;
                obj1.usertable_NAME = txtmemname.Text;
                obj1.usertable_USERID = txtmememail.Text;
                obj1.usertable_PASSWORD = txtpassword.Text;
                obj1.usertable_ROLE = "USER";
                obj1.usertable_RELATIONSHIPID = General.Parse<int>(ViewState["registrationid"].ToString());
                if (obj1.Insert(true, "usertable"))
                {
                    string encryptedid = EncryptionMethod(txtmememail.Text);
                    string encryptedpassword = EncryptionMethod(txtpassword.Text);
                    string x = HttpContext.Current.Request.Url.ToString();
                    string[] s = { "superadminmemberlist.aspx" };
                    string[] spath = x.Split(s, StringSplitOptions.None);
                    string link = "http://crmproject.aishinfotech.net/activatelink.aspx?id=" + txtmememail.Text.Trim().ToLower() + "&psd=" + txtpassword.Text.Trim();
                    MessageBox("Mail Sent To User For Activation");
                    string body = "<html xmlns='http://www.w3.org/1999/xhtml'> <head runat='server'> <title>Registration</title> </head> " +
                        " <body> <form id='form1' runat='server'> <div style='  border: 4px solid #537DA3; height:544px; width:600px; background-color:#fff; left:42%; top:0; margin-left:-200px; z-index:99999; border-radius:10px; position:fixed;'>" +
                        " <img src='Images/logo.png' alt='' style='margin-left:3%; padding-top:5px;'  /> <div style='font-size:18px; font-family:Arial Balck; font-weight:bold; margin-left:22px; color:#93c220;'>Welcome To Marketing Project</div><br />" +
                        " <p style='margin-left:24px; line-height:22px;'>Hi " + txtmemname.Text + "   <br /> Welcome to<a href=''>Marketing Project</a><strong>Get Started!</strong> </p>" +
                        " <strong style='margin-left:24px;'>Your Login Details are :</strong> <p style='margin-left:24px;'><strong>UserName : </strong> &nbsp;&nbsp;" + txtmememail.Text.ToLower() + "<br />" +
                        " <strong>Password :</strong>&nbsp;&nbsp;&nbsp;" + txtpassword.Text + " </p> <p style='color:#b9b7b7; font-size:13px;margin-left:24px;'> If you forget your username/password in future, you can use the <a href='http://crmproject.aishinfotech.net/register.aspx'>forgot your password</a> link on<br /> <a href='http://crmproject.aishinfotech.net'> Marketing Project </a></p>" +
                        " <p style='margin-left:24px;'><strong>Activate Account</strong></p> <p style='color:#b9b7b7; font-size:13px;margin-left:24px; line-height:0px;'> Please visit below url </p><p style='margin-left:24px;line-height:17px;'><br/><a href='" + link + "'>" + link + "</a><br/></p>" +
                        " </form></body> </html>";
                    try
                    {
                        General.SendMail("", "*****@*****.**", "9850386144k", "smtp.gmail.com", 587, "Registration", body, txtmememail.Text, "", "");
                        //General.SendMail("", "*****@*****.**", "aish@123", "smtp.gmail.com", 587, "registration", body, txtmememail.Text, "", "");
                    }
                    catch (Exception ex)
                    {
                    }

                    
                }
            }
        }
        else
        {
            MessageBox("Please Generate Password");
        }
    }
    protected void btnaccount_Click(object sender, EventArgs e)
    {
        string sponsorid = string.Empty;
        Handler hdn = new Handler();
        DataTable dt = hdn.GetTable("SELECT SRNO,NAME FROM REGISTRATIONTABLE RT WHERE STATUS=0 AND SEMICODE='" + txtsponsorid.Text.Trim() + "'");

        if (dt.Rows.Count == 1  && dt.Rows[0]["SRNO"].ToString() != string.Empty)
        {
            registrationtable obj = new registrationtable(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
            obj.registrationtable_SRNO = -1;
            obj.registrationtable_NAME = txtname.Text.Trim();
            obj.registrationtable_SEMICODE = txtsemid.Text.Trim();
            obj.registrationtable_PHONENO = txtmobileno.Text.Trim();
            obj.registrationtable_EMAILID = txtemail.Text.Trim();
            if (dt.Rows.Count > 0 && dt.Rows[0]["SRNO"].ToString() != string.Empty)
            {
                obj.registrationtable_SPONSORID = General.Parse<int>(dt.Rows[0]["SRNO"].ToString());
            }
            else
            {
                obj.registrationtable_SPONSORID = -1;
            }
            obj.registrationtable_SPONSORNAME = txtsponsorname.Text.Trim();
            obj.registrationtable_SPONSORSEMICODE = txtsponsorid.Text.Trim();
            obj.registrationtable_STATUS = 1;
            if (obj.Insert(true, "registrationtable"))
            {
                txtname.Text = string.Empty;
                txtsemid.Text = string.Empty;
                txtmobileno.Text = string.Empty;
                txtemail.Text = string.Empty;
                txtsponsorid.Text = string.Empty;
                txtsponsorname.Text = string.Empty;

                MessageBox("You will recieve an E-mail shortly after Admin Approval. Thank You");
            }
            else
            {
                MessageBox("Please provide proper details");
            }
        }
        else
        {
            MessageBox("Please Enter Proper SAMI Id");
        }

    }
 protected void lnkdetails_Click(object sender, EventArgs e)
 {
     LinkButton lnk = (LinkButton)sender;
     if (lnk.CommandName == "0")
     {
         registrationtable obj = new registrationtable(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
         obj.registrationtable_SRNO = -1;
         obj.registrationtable_SPONSORID = -1;
         obj.registrationtable_STATUS = 1;
         string condition = "SRNO=" + lnk.CommandArgument.ToString();
         if (obj.Insert(false, "registrationtable", condition))
         {
         }
     }
     else if (lnk.CommandName == "1")
     {
         registrationtable obj = new registrationtable(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
         obj.registrationtable_SRNO = -1;
         obj.registrationtable_SPONSORID = -1;
         obj.registrationtable_STATUS = 0;
         string condition = "SRNO=" + lnk.CommandArgument.ToString();
         if (obj.Insert(false, "registrationtable", condition))
         {
         }
     }
     DataTable dtcontract = FillMemberList();
     ViewState["list"] = dtcontract;
     if (dtcontract.Rows.Count > 0)
     {
         gvmemberlist.DataSource = (DataTable)ViewState["list"];
         gvmemberlist.DataBind();
     }
     else
     {
         gvmemberlist.DataSource = null;
         gvmemberlist.DataBind();
     }
 }