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 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 btnedit_Click(object sender, EventArgs e)
    {
        usertable user = new usertable(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
        user.usertable_SRNO = -1;
        user.usertable_NAME = txteditname.Text.Trim().ToString();
        user.usertable_DESIGNATION = ddleditdesignation.SelectedItem.Text.Trim().ToString();
        user.usertable_DEPARTMENT = ddleditdepartment.SelectedItem.Text.Trim().ToString();
        if (rdeditfemale.Checked)
        {
            user.usertable_GENDER = "FEMALE";
        }
        else
        {
            user.usertable_GENDER = "MALE";
        }

        user.usertable_EMAIL = txteditemail.Text.Trim().ToString();
        user.usertable_PHONE = txteditphone.Text.Trim().ToString();
        user.usertable_USERID = txtedituserid.Text.Trim().ToString();
        user.usertable_PASSWORD = txteditpassword.Text.Trim().ToString();
        user.usertable_STATUS = General.Parse<int>(ddlstatus.SelectedValue.Trim().ToString());
        string condition = "SRNO=" + ViewState["userid"].ToString();
        if (user.Insert(false, "usertable", condition))
        {
            MessageBox("User Updated Successfully");
            FillUser();
        }
        ScriptManager.RegisterStartupScript(this, this.GetType(), "viewuser", "ShowUser();", true);
    }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     int cmpcount = 0;
     int branchcount = 0;
     foreach (ListItem aListItem in chkcmplist.Items)
     {
         if (aListItem.Selected)
         {
             cmpcount = 1;
             foreach (ListItem aListItem1 in chkbranchlist.Items)
             {
                 if (aListItem1.Selected)
                 {
                     branchcount = 1;
                     break;
                 }
             }
             break;
         }
     }
     if (cmpcount > 0 && branchcount > 0)
     {
         usertable user = new usertable(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
         user.usertable_SRNO = -1;
         user.usertable_NAME = txtname.Text;
         user.usertable_DESIGNATION = ddldesignation.SelectedItem.Text.Trim().ToString();
         user.usertable_DEPARTMENT = ddldepartment.SelectedItem.Text.Trim().ToString();
         if (rdfemale.Checked)
         {
             user.usertable_GENDER = "FEMALE";
         }
         else
         {
             user.usertable_GENDER = "MALE";
         }
         user.usertable_EMAIL = txtemail.Text;
         user.usertable_PHONE = txtphone.Text;
         user.usertable_USERID = txtuserid.Text;
         user.usertable_PASSWORD = GenerateRandomCode();
         user.usertable_STATUS = 0;
         if (user.Insert(true, "usertable"))
         {
             int i = 0;
             foreach (ListItem aListItem in chkcmplist.Items)
             {
                 if (aListItem.Selected)
                 {
                     permissionmaster permission = new permissionmaster(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
                     permission.permissionmaster_SRNO = -1;
                     permission.permissionmaster_USERID = General.Parse<int>(Session["userid"].ToString().Trim());
                     permission.permissionmaster_CMPID = General.Parse<int>(aListItem.Value.ToString().Trim());
                     if (i == 0)
                     {
                         permission.permissionmaster_PREFFERED = 1;
                     }
                     else
                     {
                         permission.permissionmaster_PREFFERED = 0;
                     }
                     permission.permissionmaster_BRANCHID = -1;
                     permission.permissionmaster_STATUS = 0;
                     if (permission.Insert(true, "permissionmaster"))
                     {
                     }
                 }
             }
             i = 0;
             foreach (ListItem aListItem in chkbranchlist.Items)
             {
                 if (aListItem.Selected)
                 {
                     permissionmaster permission = new permissionmaster(HttpContext.Current.Server.MapPath("~/XML/database.xml"));
                     permission.permissionmaster_SRNO = -1;
                     permission.permissionmaster_USERID = General.Parse<int>(Session["userid"].ToString().Trim());
                     permission.permissionmaster_BRANCHID = General.Parse<int>(aListItem.Value.ToString().Trim());
                     if (i == 0)
                     {
                         permission.permissionmaster_PREFFERED = 1;
                     }
                     else
                     {
                         permission.permissionmaster_PREFFERED = 0;
                     }
                     permission.permissionmaster_CMPID = -1;
                     permission.permissionmaster_STATUS = 0;
                     if (permission.Insert(true, "permissionmaster"))
                     {
                     }
                 }
             }
         }
         
         MessageBox("User Created Successfully");
         FillUser();
         
     }
 }