Exemplo n.º 1
0
        public static Student GetByUserNameAndPassword(string userName, string pass)
        {
            DataTable dt     = DBLayer.ExecuteQuery(string.Format("select * from Student where st_userName = '******' and st_password = '******'", userName, pass));
            Student   result = null;

            if (dt.Rows.Count > 0)
            {
                int        id      = int.Parse(dt.Rows[0]["id"].ToString());
                string     name    = dt.Rows[0]["st_Name"].ToString();
                int        age     = int.Parse(dt.Rows[0]["st_age"].ToString());
                string     address = dt.Rows[0]["st_address"].ToString();
                string     phone   = dt.Rows[0]["st_phone"].ToString();
                string     email   = dt.Rows[0]["st_email"].ToString();
                int        adID    = int.Parse(dt.Rows[0]["FK_AdminID"].ToString());
                Admin      ad      = AdminDAL.GetById(adID);
                int        deptID  = int.Parse(dt.Rows[0]["FK_DeptID"].ToString());
                Department dp      = DepartmentDAL.GetById(deptID);
                result    = new Student(userName, name, age, address, phone, email, pass, ad, dp);
                result.Id = id;
            }
            return(result);
        }
Exemplo n.º 2
0
        public static Instructor GetByUserNameAndPassword(string userName, string pass)
        {
            DataTable  dt     = DBLayer.ExecuteQuery(string.Format("select * from Instructor where ins_userName = '******' and ins_password = '******'", userName, pass));
            Instructor result = null;

            if (dt.Rows.Count > 0)
            {
                string name    = dt.Rows[0]["ins_Name"].ToString();
                int    id      = int.Parse(dt.Rows[0]["id"].ToString());
                int    age     = int.Parse(dt.Rows[0]["ins_age"].ToString());
                string address = dt.Rows[0]["ins_address"].ToString();
                string phone   = dt.Rows[0]["ins_phone"].ToString();
                string email   = dt.Rows[0]["ins_email"].ToString();
                //bool isout = dt.Rows[0]["isout"].ToString();
                int        adID   = int.Parse(dt.Rows[0]["FK_AdminID"].ToString());
                Admin      ad     = AdminDAL.GetById(adID);
                int        deptID = int.Parse(dt.Rows[0]["FK_DeptID"].ToString());
                Department dp     = DepartmentDAL.GetById(deptID);
                result = new Instructor(userName, name, age, phone, address, email, ad, dp, pass);
            }
            return(result);
        }