using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.IO;
using DataOper;
public partial class admin_change_password : System.Web.UI.Page
{
    DataOperation dOper = new DataOperation();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnChangePassword_Click(object sender, EventArgs e)
    {
        if (txtoldPass.Text.Trim() == "" || txtNewPass.Text.Trim() == "" || txtConfirmPass.Text.Trim() == "")
        {
            lblMsg.Text = "All fields are mandatory!";
        }
        DataTable dtAdmin = dOper.return_dt("select * from tbl_users where u_id='" + Convert.ToString(Session["User_ID"]) + "'");
        if (dtAdmin.Rows.Count == 1)
        {
            if (txtoldPass.Text.Replace("'", "`").ToLower().Trim() == Convert.ToString(dtAdmin.Rows[0]["pass"]).ToLower().Trim())
            {
                if (txtNewPass.Text.Trim() == txtConfirmPass.Text.Trim())
                {
                    dOper.sqlExec("update tbl_users set pass='" + txtNewPass.Text.Replace("'", "`").Trim() + "' where u_id='" + Convert.ToString(Session["User_ID"]) + "'");
                    lblMsg.Text = "Password changed successfully";
                }
                else
                {
                    lblMsg.Text = "New password is not matching with confirm password.";
                }
            }
            else
            {
                lblMsg.Text = "Old password is incorrect!";
                txtoldPass.Text = "";
                txtNewPass.Text = "";
                txtConfirmPass.Text = "";

            }
        }
    }
}