示例#1
0
        public static ObservableCollection <Account> GetDeletedAccounts()
        {
            ObservableCollection <Account> result = null;

            try
            {
                var reader = DataConnector.ExecuteQuery(
                    @"select tk.mataikhoan, tk.email, tk.matkhau, tk.hoten, tk.maphanquyen " +
                    "from taikhoan tk " +
                    "where tk.bixoa = 'true'");
                if (reader != null)
                {
                    result = new ObservableCollection <Account>();
                    while (reader.Read())
                    {
                        var item = new Account(reader.GetInt32(0));
                        item.BeginInit();
                        item.Email         = (string)reader.GetValueDefault(1, null);
                        item.Password      = (string)reader.GetValueDefault(2, null);
                        item.Name          = (string)reader.GetValueDefault(3, null);
                        item.AccessLevel   = AccessLevelAdapter.GetAcessLevelById(reader.GetInt32(4));
                        item.IsDeleted     = true;
                        item.IsDeletedItem = item.IsDeleted;
                        item.EndInit();
                        result.Add(item);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorManager.Current.DataCantBeRead.Call(ex.Message);
            }
            return(result);
        }
示例#2
0
        public static Account GetAccount(int id, bool findDeletedToo = false)
        {
            Account result = null;

            try
            {
                var reader = DataConnector.ExecuteQuery(
                    string.Format(@"select tk.mataikhoan, tk.email, tk.matkhau, tk.hoten, tk.maphanquyen, tk.bixoa " +
                                  "from taikhoan tk " +
                                  "where tk.mataikhoan = {0} {1} and tk.maphanquyen = pq.maphanquyen", id, findDeletedToo ? "" : "and tk.bixoa = 'false'"));
                if (reader != null)
                {
                    while (reader.Read())
                    {
                        var item = new Account(reader.GetInt32(0));
                        item.BeginInit();
                        item.Email         = (string)reader.GetValueDefault(1, null);
                        item.Password      = (string)reader.GetValueDefault(2, null);
                        item.Name          = (string)reader.GetValueDefault(3, null);
                        item.AccessLevel   = AccessLevelAdapter.GetAcessLevelById(reader.GetInt32(4));
                        item.IsDeleted     = (bool)reader.GetValueDefault(5, false);
                        item.IsDeletedItem = item.IsDeleted;
                        item.EndInit();
                        result = item;
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorManager.Current.DataCantBeRead.Call(ex.Message);
            }
            return(result);
        }
示例#3
0
        public static bool IsExists(string username, string password, out Account result, bool findDeletedToo = false)
        {
            result = null;
            try
            {
                password = crypto.encodeMD5(crypto.encodeSHA1(password));

                var reader = DataConnector.ExecuteQuery(
                    string.Format(@"select tk.mataikhoan, tk.email, tk.matkhau, tk.hoten, tk.maphanquyen, tk.bixoa " +
                                  "from taikhoan tk " +
                                  "where tk.email = '{0}' and tk.matkhau = '{1}' {2}", username, password, findDeletedToo ? "" : "and tk.bixoa = 'false'"));
                if (reader != null)
                {
                    while (reader.Read())
                    {
                        var item = new Account(reader.GetInt32(0));
                        item.BeginInit();
                        item.Email         = (string)reader.GetValueDefault(1, null);
                        item.Password      = (string)reader.GetValueDefault(2, null);
                        item.Name          = (string)reader.GetValueDefault(3, null);
                        item.AccessLevel   = AccessLevelAdapter.GetAcessLevelById(reader.GetInt32(4));
                        item.IsDeleted     = (bool)reader.GetValueDefault(5, false);
                        item.IsDeletedItem = item.IsDeleted;
                        item.EndInit();
                        result = item;
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorManager.Current.DataCantBeRead.Call(ex.Message);
            }
            return(result != null);
        }