Exemplo n.º 1
0
 public static void DeleteItem(int id)
 {
     try
     {
         // Delete item.
         DLAccount.Select(id, null, null, null, null, null, "DELETE FROM item WHERE id=@Id");
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Exemplo n.º 2
0
 public static void InsertItem(int accountId, string iname)
 {
     try
     {
         // Insert item. WHERE id=@Id"
         DLAccount.Insert(accountId, null, null, iname, null, DateTime.Now.ToString("yyyy.MM.dd H:mm:ss"), "INSERT INTO item (iname, rdate, account_id) VALUES (@Fname, @Rdate, @Id)");
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Exemplo n.º 3
0
 public static int SetAccount(string email, string pword, string fname, string lname)
 {
     try
     {
         // Return inserted accountId from DL.
         return(DLAccount.Insert(0, email, pword, fname, lname, DateTime.Now.ToString("yyyy.MM.dd H:mm:ss"), "INSERT INTO account VALUES (@Id, @Email, @Pword, @Fname, @Lname, @Rdate)"));
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Exemplo n.º 4
0
        public static bool IsAccountExist(string email, string pword)
        {
            try
            {
                // Get accountId dataTable from DL.
                DataTable dataTable = DLAccount.Select(0, email, pword, null, null, null, "SELECT id FROM account WHERE email=@Email AND pword=@Pword");

                // Return bool if account exist. (Conditional operator)
                return((dataTable.Rows.Count > 0) ? true : false);
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
Exemplo n.º 5
0
        public static Account GetAccount(int id)
        {
            try
            {
                // Get account dataTable from DL.
                DataTable dataTable = DLAccount.Select(id, null, null, null, null, null, "SELECT * FROM account WHERE id=@Id");

                // Return account.
                return(new Account(dataTable.Rows[0][0].ToString(), dataTable.Rows[0][1].ToString(), dataTable.Rows[0][2].ToString(), dataTable.Rows[0][3].ToString(), dataTable.Rows[0][4].ToString(), dataTable.Rows[0][5].ToString()));
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
Exemplo n.º 6
0
        public static int GetAccountId(string email, string pword)
        {
            try
            {
                // Get accountId dataTable from DL.
                DataTable dataTable = DLAccount.Select(0, email, pword, null, null, null, "SELECT id FROM account WHERE email=@Email AND pword=@Pword");

                // Return accountId if account exist. (Conditional operator)
                return((dataTable.Rows.Count > 0) ? Convert.ToInt32(dataTable.Rows[0][0]) : 0);
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
Exemplo n.º 7
0
        public static List <Item> GetItems(int accountId)
        {
            try
            {
                List <Item> items = new List <Item>();

                // Get items dataTable from DL.
                DataTable dataTable = DLAccount.Select(accountId, null, null, null, null, null, "SELECT item.id, item.iname, account.email, item.rdate FROM item LEFT JOIN account ON account.id = item.account_id");

                foreach (DataRow dataRow in dataTable.Rows)
                {
                    items.Add(new Item(dataRow[0].ToString(), dataRow[1].ToString(), dataRow[2].ToString(), dataRow[3].ToString()));
                }

                return(items);
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }