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 DataOper;
public partial class admin_login : System.Web.UI.Page
{
    DataOperation dOPer = new DataOperation();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        if (txtUsername.Text == "" || txtPassword.Text == "")
        {
            lblMsg.Text = "* field are not blank !";
        }
        else
        {
            DataTable dt = dOPer.return_dt("select * from tbl_users where username='" + txtUsername.Text.Replace("'", "`") + "' and pass='" + txtPassword.Text.Replace("'", "`") + "'");
            if (dt.Rows.Count > 0)
            {
                Session["User_ID"] = Convert.ToString(dt.Rows[0]["u_id"]);
                HttpCookie cookieadmin_id = new HttpCookie("User_ID", Convert.ToString(dt.Rows[0]["u_id"]));
                Response.Cookies.Add(cookieadmin_id);
                Response.Redirect("dashboard.aspx");
            }
            else
            {
                lblMsg.Text = "Incorrect Username or Password !";
            }
        }
    }
}