Example #1
0
        public TaiKhoanConvert Convert(TaiKhoan a)
        {
            TaiKhoanConvert temp = new TaiKhoanConvert();

            temp.IdUser   = a.IdUser;
            temp.LastName = a.LastName;
            temp.Address  = a.Address;
            temp.Birth    = a.Birth.ToString("dd/MM/yyyy");
            temp.Email    = a.Email;
            temp.FirtName = a.FirtName;
            temp.PassWord = a.PassWord;
            temp.Phone    = a.Phone;
            temp.Picture  = a.Picture;
            temp.Provider = a.Provider;
            temp.Role     = a.Role;
            temp.Sex      = a.Sex;
            return(temp);
        }
Example #2
0
        public TaiKhoanConvert getTaiKhoan(string email, string provider)
        {
            connect();
            string query = "SELECT * FROM TAIKHOAN WHERE Email = '" + email + "' AND NhaCungCap = '" + provider + "'";

            adapter = new SqlDataAdapter(query, connection);
            DataSet dataset = new DataSet();

            adapter.Fill(dataset);
            ArrayList ls  = ConvertDataSetToArrayList(dataset);
            TaiKhoan  arr = new TaiKhoan();

            foreach (Object o in ls)
            {
                arr = (TaiKhoan)o;
                break;
            }

            disconnect();
            TaiKhoanConvert temp = new TaiKhoanConvert();

            temp = Convert(arr);
            return(temp);
        }
Example #3
0
        public TaiKhoanConvert getTaiKhoan(int id)
        {
            connect();
            string query = "SELECT * FROM TAIKHOAN WHERE IdUser = " + id;

            adapter = new SqlDataAdapter(query, connection);
            DataSet dataset = new DataSet();

            adapter.Fill(dataset);
            ArrayList ls  = ConvertDataSetToArrayList(dataset);
            TaiKhoan  arr = new TaiKhoan();

            foreach (Object o in ls)
            {
                arr = (TaiKhoan)o;
                break;
            }

            disconnect();
            TaiKhoanConvert temp = new TaiKhoanConvert();

            temp = Convert(arr);
            return(temp);
        }
Example #4
0
        public TaiKhoanConvert getTaiKhoan(string email, string password, string provider)
        {
            string result = "Null";

            if (string.IsNullOrEmpty(email) && string.IsNullOrEmpty(password) &&
                (HttpContext.Current.Session.Count == 0 || HttpContext.Current.Session["UserOnline"] == null))
            {
                return(null);
            }

            if (HttpContext.Current.Session.Count > 0 && HttpContext.Current.Session["UserOnline"] != null && HttpContext.Current.Session["UserOnline"].ToString() == "On")
            {
                string type = "";
                if (HttpContext.Current.Session["Auth"].ToString() == "Admin")
                {
                    type = "Admin";
                }

                else
                {
                    type = "Customer";
                }
                result = type;
            }

            connect();
            string query = "SELECT * FROM TAIKHOAN WHERE Email = '" + email + "' AND MatKhau = '" + password + "' AND NhaCungCap = '" + provider + "'";

            adapter = new SqlDataAdapter(query, connection);
            DataSet dataset = new DataSet();

            adapter.Fill(dataset);
            ArrayList ls  = ConvertDataSetToArrayList(dataset);
            TaiKhoan  arr = new TaiKhoan();

            foreach (Object o in ls)
            {
                arr = (TaiKhoan)o;
                break;
            }
            try
            {
                if (arr.Email != null)
                {
                    HttpContext.Current.Session["AccountId"]  = arr.Email;
                    HttpContext.Current.Session["UserOnline"] = "On";
                    if (arr.Role == "Admin")
                    {
                        HttpContext.Current.Session["Auth"] = "Admin";
                    }
                    else
                    {
                        HttpContext.Current.Session["Auth"] = "Customer";
                    }
                }
            }
            catch (NotImplementedException implementedException)
            {
            }

            disconnect();
            TaiKhoanConvert temp = new TaiKhoanConvert();

            temp = Convert(arr);
            return(temp);
        }