コード例 #1
0
        public static List <Task> GetAllTasks()
        {
            DAL.ConnectDb();

            List <Task>      data    = new List <Task> ();
            string           query   = "SELECT * FROM " + TableName;
            SQLiteCommand    command = new SQLiteCommand(query, DAL.Conn);
            SQLiteDataReader reader  = command.ExecuteReader();

            while (reader.HasRows)
            {
                while (reader.Read())
                {
                    Task t = new Task();
                    t.Id          = reader.GetInt32(0);
                    t.Owner       = UserDAL.GetUserById(reader.GetInt32(1));
                    t.Title       = reader.GetString(2);
                    t.Description = reader.GetString(3);
                    t.Status      = (TaskStatus)reader.GetInt32(4);
                    t.StartDate   = DateTime.Parse(reader.GetString(5));
                    t.EndDate     = DateTime.Parse(reader.GetString(6));
                    t.IsPrivate   = reader.GetBoolean(7);
                    t.Partners    = PartnerDAL.GetAllPartners(t);
                    data.Add(t);
                }

                reader.NextResult();
            }

            return(data);
        }
コード例 #2
0
        public static Task GetTaskById(int id)
        {
            DAL.ConnectDb();

            Task          t       = new Task();
            string        query   = "SELECT * FROM " + TableName + " WHERE Id = @TaskId";
            SQLiteCommand command = new SQLiteCommand(query, DAL.Conn);

            command.Parameters.AddWithValue("@TaskId", id);

            SQLiteDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                t.Id          = Int32.Parse(reader["Id"].ToString());
                t.Owner       = UserDAL.GetUserById(Int32.Parse(reader["OwnerId"].ToString()));
                t.Title       = reader["Title"].ToString();
                t.Description = reader["Description"].ToString();
                t.Status      = (TaskStatus)Int32.Parse(reader["Status"].ToString());
                t.StartDate   = DateTime.Parse(reader["StartDate"].ToString());
                t.EndDate     = DateTime.Parse(reader["EndDate"].ToString());
                t.IsPrivate   = Boolean.Parse(reader["IsPrivate"].ToString() == "1" ? "true" : "false");
                t.Partners    = PartnerDAL.GetAllPartners(t);
            }

            return(t);
        }
コード例 #3
0
        public static List <Comment> GetAllComments()
        {
            DAL.ConnectDb();

            List <Comment>   data    = new List <Comment> ();
            string           query   = "SELECT * FROM " + TableName;
            SQLiteCommand    command = new SQLiteCommand(query, DAL.Conn);
            SQLiteDataReader reader  = command.ExecuteReader();

            while (reader.HasRows)
            {
                while (reader.Read())
                {
                    Comment c = new Comment();
                    c.Id      = reader.GetInt32(0);
                    c.Owner   = UserDAL.GetUserById(reader.GetInt32(1));
                    c.Task    = reader.GetInt32(2);
                    c.Content = reader.GetString(3);
                    c.Date    = DateTime.Parse(reader.GetString(4));
                    data.Add(c);
                }

                reader.NextResult();
            }

            return(data);
        }
コード例 #4
0
        public static List <User> GetAllPartners(Task task)
        {
            DAL.ConnectDb();

            List <User>   data    = new List <User> ();
            string        query   = "SELECT * FROM " + TableName + " WHERE TaskId = @TaskId";
            SQLiteCommand command = new SQLiteCommand(query, DAL.Conn);

            command.Parameters.AddWithValue("@TaskId", task.Id);

            SQLiteDataReader reader = command.ExecuteReader();

            while (reader.HasRows)
            {
                while (reader.Read())
                {
                    int uId = reader.GetInt32(1);
                    data.Add(UserDAL.GetUserById(uId));
                }

                reader.NextResult();
            }

            return(data);
        }
コード例 #5
0
        static protected Bill GetBill(MySqlDataReader reader)
        {
            Bill result = new Bill();
            int  AppID, UserID, PaymentID;

            result.Bill_ID = reader.GetInt16("bill_Id");
            AppID          = reader.GetInt32("App_ID");
            Application app = ApplicationDAL.GetApplicationById(AppID);

            result.App = app;
            UserID     = reader.GetInt32("User_ID");
            User user = UserDAL.GetUserById(UserID);

            result.User       = user;
            PaymentID         = reader.GetInt32("payment_id");
            result.Payment    = PaymentDAL.GetPaymentById(PaymentID);
            result.UnitPrice  = reader.GetDouble("UnitPrice");
            result.DateCreate = reader.GetDateTime("DataCreate");

            return(result);
        }
コード例 #6
0
        public static Comment GetCommentById(int id)
        {
            DAL.ConnectDb();

            Comment       c       = new Comment();
            string        query   = "SELECT * FROM " + TableName + " WHERE Id = @CommentId";
            SQLiteCommand command = new SQLiteCommand(query, DAL.Conn);

            command.Parameters.AddWithValue("@CommentID", id);

            SQLiteDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                c.Id      = Int16.Parse(reader["Id"].ToString());
                c.Owner   = UserDAL.GetUserById(Int32.Parse(reader["UserId"].ToString()));
                c.Task    = Int32.Parse(reader["TaskId"].ToString());
                c.Content = reader["Content"].ToString();
                c.Date    = DateTime.Parse(reader["Date"].ToString());
            }

            return(c);
        }