Beispiel #1
0
        public InboxDomain getInbox(string to, string from)
        {
            InboxDomain inbox = null;

            sqlConnection.Open();
            sqlCommand = new SqlCommand(inboxQuery.getInboxQueryOneUser(from, to), sqlConnection);
            try{
                sqlDataReader = sqlCommand.ExecuteReader();

                while (sqlDataReader.Read())
                {
                    DateTime date = sqlDataReader.GetDateTime(0);
                    inbox = new InboxDomain(to, from, sqlDataReader.GetString(1), sqlDataReader.GetString(2), date);
                }
                sqlDataReader.Close();
            }catch (InvalidCastException invalid) {
                Console.WriteLine(invalid.Message);
            }catch (SqlException sql) {
                Console.WriteLine(sql.Message);
            }catch (InvalidOperationException invalid) {
                Console.WriteLine(invalid.Message);
            }
            sqlConnection.Close();
            return(inbox);
        }
Beispiel #2
0
 static void InboxOperationFull()
 {
     Inbox.Inbox inbox = new Inbox.Inbox();
     // date is already create with the date of today
     // Inbox.InboxDomain inboxDomain = new Inbox.InboxDomain("*****@*****.**", "*****@*****.**", "test", "test" , new DateTime()); // this work but i make it auto create with date of today
     Inbox.InboxDomain inboxDomain = new Inbox.InboxDomain("*****@*****.**", "*****@*****.**", "test", "test");
     if (inbox.insert(inboxDomain))
     {
         Console.WriteLine("******************* Done ADD *******************");
     }
     inboxDomain = null;
     inboxDomain = inbox.getInbox("*****@*****.**", "*****@*****.**");
     if (inboxDomain != null)
     {
         Console.WriteLine("******************* Done Get *******************");
     }
     if (inbox.delete("*****@*****.**", "*****@*****.**"))
     {
         Console.WriteLine("******************* Done delete *******************");
     }
 }
Beispiel #3
0
 public bool insert(InboxDomain inbox)
 {
     sqlConnection.Open();
     sqlCommand = new SqlCommand(inboxQuery.insertInboxQuery(inbox), sqlConnection);
     try
     {
         sqlCommand.ExecuteNonQuery();
     }
     catch (InvalidCastException invalid)
     {
         Console.WriteLine(invalid.Message);
     }
     catch (SqlException sql)
     {
         Console.WriteLine(sql.Message);
     }
     catch (InvalidOperationException invalid)
     {
         Console.WriteLine(invalid.Message);
     }
     sqlConnection.Close();
     return(true);
 }
Beispiel #4
0
 public string insertInboxQuery(InboxDomain inbox)
 {
     return("INSERT INTO [dbo].[Inbox] ([toInbox] ,[fromInbox] ,[Date],[subject],[detail])" +
            "VALUES ('" + inbox.to + "','" + inbox.from + "','" + inbox.date + "','" + inbox.subject + "','" + inbox.detail + "')");
 }