Exemple #1
0
        public static BE.FeedBack[] SelectAll()
        {
            ArrayList feedBacks = new ArrayList();

            BE.FeedBack feedBack;
            string      SQLQuery = "SELECT * FROM [FeedBack]  ";
            SqlCommand  command  = new SqlCommand();

            command.CommandText = SQLQuery;
            SqlDataReader reader = SQLHelper.ExecuteReader(command);

            while (reader.Read())
            {
                feedBack = new BE.FeedBack();

                feedBack.FirstName = Convert.ToString(reader["FirstName"]);
                feedBack.LastName  = Convert.ToString(reader["LastName"]);
                feedBack.Email     = Convert.ToString(reader["Email"]);
                feedBack.Subject   = Convert.ToString(reader["Subject"]);
                feedBack.Comment   = Convert.ToString(reader["Comment"]);
                feedBack.Status    = Convert.ToString(reader["Status"]);
                feedBacks.Add(feedBack);
            }


            reader.Close();
            reader.Dispose();
            return((BE.FeedBack[])feedBacks.ToArray(typeof(BE.FeedBack)));
        }
Exemple #2
0
        public static BE.FeedBack Select(Int32 Id)
        {
            BE.FeedBack feedBack = new BE.FeedBack();
            string      SQLQuery = "SELECT * FROM [FeedBack] WHERE [Id]=@Id ";

            SqlCommand command = new SqlCommand();

            command.CommandText = SQLQuery;
            command.Parameters.AddWithValue("@Id", Id);

            SqlDataReader reader = SQLHelper.ExecuteReader(command);

            reader.Read();

            feedBack.FirstName = Convert.ToString(reader["FirstName"]);
            feedBack.LastName  = Convert.ToString(reader["LastName"]);
            feedBack.Email     = Convert.ToString(reader["Email"]);
            feedBack.Subject   = Convert.ToString(reader["Subject"]);
            feedBack.Comment   = Convert.ToString(reader["Comment"]);
            feedBack.Status    = Convert.ToString(reader["Status"]);

            reader.Close();
            reader.Dispose();
            return(feedBack);
        }
Exemple #3
0
 private static void AddParameters(SqlCommand command, BE.FeedBack feedBack)
 {
     command.Parameters.AddWithValue("@FirstName", feedBack.FirstName);
     command.Parameters.AddWithValue("@LastName", feedBack.LastName);
     command.Parameters.AddWithValue("@Email", feedBack.Email);
     command.Parameters.AddWithValue("@Subject", feedBack.Subject);
     command.Parameters.AddWithValue("@Comment", feedBack.Comment);
     command.Parameters.AddWithValue("@Status", feedBack.Status);
 }
Exemple #4
0
        public static bool Update(BE.FeedBack feedBack)
        {
            string SQLQuery = "UPDATE [FeedBack] SET FirstName = @FirstName, LastName= @LastName, Email= @Email, Subject= @Subject, Comment= @Comment, Status= @Status WHERE [Id]=@Id ";

            SqlCommand command = new SqlCommand();

            command.CommandText = SQLQuery;

            AddParameters(command, feedBack);

            return(Convert.ToBoolean(SQLHelper.ExecuteNonQuery(command)));
        }
Exemple #5
0
        public static bool Insert(BE.FeedBack feedBack)
        {
            string SQLQuery = "INSERT INTO [FeedBack] ( firstName,lastName,email,subject,comment,status ) VALUES	(@firstName, @lastName, @email, @subject, @comment, @status)";

            SqlCommand command = new SqlCommand();

            command.CommandText = SQLQuery;

            AddParameters(command, feedBack);

            return(Convert.ToBoolean(SQLHelper.ExecuteNonQuery(command)));
        }
Exemple #6
0
        public static bool Save(BE.FeedBack feedBack)
        {
            bool IsAffected = false;

            if (feedBack.State == BE.RowState.Added)
            {
                IsAffected = Insert(feedBack);
            }
            else if (feedBack.State == BE.RowState.Modified)
            {
                IsAffected = Update(feedBack);
            }
            else if (feedBack.State == BE.RowState.Deleted)
            {
                IsAffected = Delete(feedBack.Email);
            }
            return(IsAffected);
        }