protected void ButtonSubmit_Click(object sender, EventArgs e)
    {
        if (uname != null)
        {
            using (dataclassDataContext Data = new dataclassDataContext())
            {
                login newrow = new login();
                string userid = Textusername.Text;
                newrow.uid = userid;
                newrow.username = Textname.Text;
                newrow.password = Textpassword.Text;
                newrow.security_question = TextBoxsecurityquestion.Text;
                newrow.security_answer = TextBoxsecurityanswer.Text;
                newrow.address = TextBoxaddress.Text;
                newrow.contact_no = TextBoxnumber.Text;
                newrow.email_id = Textemail.Text;
                Data.logins.InsertOnSubmit(newrow);
                Data.SubmitChanges();

                LoginClass.CheckLogin = userid;
                LoginClass.UserType = 0;
                LoginClass.name = Textname.Text;
                Response.Redirect("home.aspx");
            }
        }
        else
            Label1.Visible = true;
    }
    protected void Buttonsubmit1_Click(object sender, EventArgs e)
    {
        uname = Textusername.Text;
        using (dataclassDataContext Data = new dataclassDataContext())
            {
                if (uname != null)
                {
                    login check = Data.logins.SingleOrDefault(l => l.uid == uname);
                    if (check != null)
                    {
                        Labelincorrectname.Visible = false;
                        Labelquestion.Text = check.security_question;
                        answer = check.security_answer;
                        password = check.password;
                        Labelquestion.Visible = true;
                        Label1.Visible = true;
                        Label2.Visible = true;
                        Textanswer.Visible = true;
                        Buttonsubmit2.Visible = true;
                        Buttonsubmit1.Visible = false;
                    }
                    else {
                        Labelincorrectname.Text = "Username is incorrect";
                        Labelincorrectname.Visible = true;
                    }
                }
                else {
                    Response.Redirect("forgetpassword.aspx");

                }

        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (LoginClass.CheckLogin == null)
        {
            Response.Redirect("loginpage.aspx");
        }
        if (LoginClass.UserType != 0)
        {
            ButtonApproval.Visible = true;
            ButtonAdminHistory.Visible = true;
        }
        if (Page.Request.QueryString["text"] != null)
        {
            sugid = Convert.ToInt32(Page.Request.QueryString["text"]);

            using (dataclassDataContext Data = new dataclassDataContext())
            {
                Table Mytable = Data.Tables.SingleOrDefault(Table => Table.suggestionid == sugid);
                labelsubject.Text = Mytable.subject;
                labeldepartment.Text = Mytable.department;

                string original = Mytable.suggestion;
                labelsuggestionbox.Text = original;
                labelnumlikes.Text = Mytable.likes.ToString();

                admin1note.Text = Mytable.admin1note;
                admin2note.Text = Mytable.admin3note;
                admin3note.Text = Mytable.admin3note;

                if (Mytable.admin1note == null)
                    admin1note.Text = "NO COMMENTS";
                if (Mytable.admin2note == null)
                    admin2note.Text = "NO COMMENTS";
                if (Mytable.admin3note == null)
                    admin3note.Text = "NO COMMENTS";
                if (Mytable.status == 0)
                    labelstatus.Text = "to be approved by admin1";
                else if (Mytable.status == 1)
                    labelstatus.Text = "to be approved by admin2";
                else if (Mytable.status == 2)
                    labelstatus.Text = "to be approved by admin3";
                else if (Mytable.status == 3)
                    labelstatus.Text = "approved completely";
                else if (Mytable.status == -1)
                    labelstatus.Text = "rejected by admin 1";
                else if (Mytable.status == -2)
                    labelstatus.Text = "rejected by admin 2";
                else if (Mytable.status == -3)
                    labelstatus.Text = "rejected by admin 3";
            }
        }
        welcomeuser.Text = "Welcome " + LoginClass.name + " !";
    }
    protected void ButtonSubmit_Click(object sender, EventArgs e)
    {
        using (dataclassDataContext Data = new dataclassDataContext())
        {
            login Mylogin = Data.logins.SingleOrDefault(l => l.uid == uname);
            Mylogin.password = TextBox1.Text;
            Data.SubmitChanges();

            string str = "<script>alert(\"Your Password has been successfully changed\");</script>";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Script", str, false);
        }
        Reset();
    }
    protected void buttonlike_Click(object sender, EventArgs e)
    {
        using (dataclassDataContext Data = new dataclassDataContext())
        {
            int sugid = Convert.ToInt32(Page.Request.QueryString["text"]);
            Table Mytable = new Table();
            Mytable = Data.Tables.SingleOrDefault(Table => Table.suggestionid == sugid);
            if (flag == 0)
            {
                int x = Mytable.likes;
                x += 1;
                Mytable.likes = x;
                Mytable.like_list += LoginClass.CheckLogin + ",";

            }
            else
            {
                Mytable.likes -= 1;
                int len = Mytable.like_list.Length;
                int i = 0;
                string ll = Mytable.like_list;
                char[] list = ll.ToCharArray();
                string newstring = null;
                string key = LoginClass.CheckLogin;
                string temp = null;

                while (i < len)
                {
                    while (list[i] != ',')
                    {
                        temp = temp + list[i].ToString();
                        i++;
                    }
                    if (temp != key)
                    {
                        newstring = newstring + temp + ",";
                    }
                    temp = null;
                    i++;
                }
                Mytable.like_list = newstring;
            }
            Data.SubmitChanges();
            //int sugid = Convert.ToInt32(Page.Request.QueryString["text"]);
            Page.Response.Redirect("viewsuggestion.aspx?text="+sugid);
        }
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     string checkuname = Textusername.Text;
     using (dataclassDataContext Data = new dataclassDataContext())
     {
         login check = Data.logins.SingleOrDefault(l => l.uid == checkuname);
         if (check != null)
         {
             uname = null;
             Label1.Visible = true;
         }
         else
         {
             uname = "check";
             Label1.Visible = false;
         }
     }
 }
    protected void ButtonSubmit_Click(object sender, EventArgs e)
    {
        string check = TextBoxSubject.Text;
        if (check.Length >= 49)
        {
            Labelerror.Visible = true;
        }
        else
        {
            Labelerror.Visible = false;
           using (dataclassDataContext Data = new dataclassDataContext())
            {
                Table Mytable = new Table();
                Mytable.suggestionid = Data.Tables.Count() + 1;
                Mytable.department = DropDowndept.Text;
                Mytable.subject = TextBoxSubject.Text;
                Mytable.suggestion = TextBoxSuggestion.Text;
                suglen = TextBoxSuggestion.Text.Length;
                if (suglen <= 75)
                    Mytable.suggestion_temp = TextBoxSuggestion.Text;
                else
                {
                    Mytable.suggestion_temp = TextBoxSuggestion.Text.Substring(0, 72);
                    Mytable.suggestion_temp += ".....";
                }
                Mytable.date_time = DateTime.Now;
                Mytable.name = LoginClass.name;
                Mytable.username = LoginClass.CheckLogin;
                Data.Tables.InsertOnSubmit(Mytable);
                Data.SubmitChanges();

                string str = "<script>alert(\"Your suggestion has been successfully submitted\");</script>";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Script", str, false);

                TextBoxSubject.Text = null;
                TextBoxSuggestion.Text = null;
                Labelerror.Visible = false;
            }
        }
    }
    protected void ButtonSubmit_Click(object sender, EventArgs e)
    {
        string uname = TextUsername.Text;
        string pwd = TextPassword.Text;
        using (dataclassDataContext Data = new dataclassDataContext())
        {
            login MyLogin = Data.logins.SingleOrDefault(login => login.uid == uname);
            if (MyLogin != null)
            {
                string tablepass = MyLogin.password;
                int i = 0, flag = 1;
                i = pwd.Length;
                while (i < tablepass.Length)
                {
                    pwd = pwd + " ";
                    i++;
                }

                if (pwd == tablepass)
                {
                    LoginClass.CheckLogin = uname;
                    LoginClass.UserType = MyLogin.account_type;
                    LoginClass.name = MyLogin.username;
                    Response.Redirect("home.aspx");
                }
                else
                {
                    Label1.Visible = false;
                    Label2.Visible = true;
                }
            }
            else
            {
                Label1.Visible = true;
                Label2.Visible = false;
            }

        }
    }
 protected void Buttonreject_Click(object sender, EventArgs e)
 {
     using (dataclassDataContext Data = new dataclassDataContext())
     {
         Table Mytable = Data.Tables.SingleOrDefault(Table => Table.suggestionid == sugid);
         Mytable.status = (-1) * LoginClass.UserType;
         Mytable.modstatus = LoginClass.UserType - 1;
         if (LoginClass.UserType == 1)
         {
             Mytable.admin1note = Textboxadminnote.Text;
         }
         if (LoginClass.UserType == 2)
         {
             Mytable.admin2note = Textboxadminnote.Text;
         }
         if (LoginClass.UserType == 3)
         {
             Mytable.admin3note = Textboxadminnote.Text;
         }
         Data.SubmitChanges();
         Response.Redirect("approvallist.aspx");
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (LoginClass.CheckLogin == null)
        {
            Response.Redirect("loginpage.aspx");
        }

        if (LoginClass.UserType != 0)
        {
            ButtonApproval.Visible = true;
            ButtonAdminHistory.Visible = true;
        }
        welcomeuser.Text = "Welcome " + LoginClass.name + " !";
        using (dataclassDataContext Data = new dataclassDataContext())
        {
            login MyLogin = Data.logins.SingleOrDefault(login => login.uid == LoginClass.CheckLogin);
            labelname.Text = MyLogin.username;
            labelemailid.Text = MyLogin.email_id;
            labelnumber.Text = MyLogin.contact_no;
            labelusername.Text = MyLogin.uid;
            labeladdress.Text = MyLogin.address;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (LoginClass.CheckLogin == null)
        {
            Response.Redirect("loginpage.aspx");
        }

        if (LoginClass.UserType != 0)
        {
            ButtonApproval.Visible = true;
            ButtonAdminHistory.Visible = true;
        }
        welcomeuser.Text = "Welcome " + LoginClass.name + " !";

        uname = LoginClass.CheckLogin;
        pass = Textpassword.Text;
        welcomeuser.Text = "Welcome " + LoginClass.name + " !";
        using (dataclassDataContext Data = new dataclassDataContext())
        {
             login Mylogin = Data.logins.SingleOrDefault(l => l.uid == uname);
                 if (pass != "")
                    {
                        int i = 0;
                        i = pass.Length;
                        while (i < Mylogin.password.Length)
                        {
                            pass = pass + " ";
                            i++;
                        }
                    }
                    if (pass != Mylogin.password)
                    {
                        if (pass != "")
                        {
                            Label2.Visible = true;
                            pass = Textpassword.Text;
                        }
                    }
                    else
                    {
                        Label2.Visible = false;
                    }
                }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (LoginClass.CheckLogin == null)
        {
            Response.Redirect("loginpage.aspx");
        }
        if (Page.Request.QueryString["text"] != null)
        {
            int sugid = Convert.ToInt32(Page.Request.QueryString["text"]);
            using (dataclassDataContext Data = new dataclassDataContext())
            {
                Table Mytable = Data.Tables.SingleOrDefault(Table => Table.suggestionid == sugid);
                subjectbox.Text = Mytable.subject;
                string original = Mytable.suggestion;
                suggestionbox.Text = original;
                suggestorbox.Text = Mytable.name;
                labelnumlikes.Text = Mytable.likes.ToString();

                string ll = Mytable.like_list;
                if (ll != null)
                {
                    char[] list = ll.ToCharArray();
                    string key = LoginClass.CheckLogin;

                    string temp = null;
                    int len = list.Length;
                    int i = 0;
                    while (i < len)
                    {
                        while (list[i] != ',')
                        {
                            temp = temp + list[i].ToString();
                            i++;
                        }
                        if (temp == key)
                        {
                            flag = 1;
                            break;
                        }
                        temp = null;
                        i++;
                    }
                    if (flag == 1)
                        buttonlike.Text = "Unlike";
                }
            }
        }
        if (LoginClass.UserType != 0)
        {
            ButtonApproval.Visible = true;
            ButtonAdminHistory.Visible = true;
        }
        welcomeuser.Text = "Welcome " + LoginClass.name + " !";
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (LoginClass.CheckLogin == null)
     {
         Response.Redirect("loginpage.aspx");
     }
     if (LoginClass.UserType == 0)
     {
         Response.Redirect("home.aspx");
     }
     if (LoginClass.UserType != 0)
     {
         ButtonApproval.Visible = true;
         ButtonAdminHistory.Visible = true;
     }
     if (Page.Request.QueryString["text"] != null)
     {
         sugid = Convert.ToInt32(Page.Request.QueryString["text"]);
         if (LoginClass.UserType == 2)
         {
             using (dataclassDataContext Data = new dataclassDataContext())
             {
                 Table Mytable = Data.Tables.SingleOrDefault(Table => Table.suggestionid == sugid);
                 if (Mytable.admin1note != null)
                 {
                     admin1.Visible = true;
                     admin1note.Visible = true;
                 }
             }
         }
         if (LoginClass.UserType == 3)
         {
             using (dataclassDataContext Data = new dataclassDataContext())
             {
                 Table Mytable = Data.Tables.SingleOrDefault(Table => Table.suggestionid == sugid);
                 if (Mytable.admin1note != null)
                 {
                     admin1.Visible = true;
                     admin1note.Visible = true;
                 }
                 if (Mytable.admin2note != null)
                 {
                     admin2.Visible = true;
                     admin2note.Visible = true;
                 }
             }
         }
         using (dataclassDataContext Data = new dataclassDataContext())
         {
             Table Mytable = Data.Tables.SingleOrDefault(Table => Table.suggestionid == sugid);
             labelsubject.Text = Mytable.subject;
             labelsuggestion.Text = Mytable.suggestion;
             labelsuggestor.Text = Mytable.name;
             labelnumlikes.Text = Mytable.likes.ToString();
             admin1note.Text = Mytable.admin1note;
             admin2note.Text = Mytable.admin2note;
         }
     }
     welcomeuser.Text = "Welcome " + LoginClass.name + " !";
 }