예제 #1
0
        private void dataGrid_Selection(object sender, EventArgs e)
        {
            if (executedFirstTime)
            {
                executedFirstTime = false;
                return;
            }
            try
            {
                int selectedIndex = dataGridViewSessions.SelectedRows[0].Index;
                if (selectedIndex != -1)
                {
                    if (dataGridViewSessions.SelectedRows[0].Cells[0].Value != null)
                    {
                        int id = int.Parse(dataGridViewSessions.SelectedRows[0].Cells[0].Value.ToString());
                        selectedParallel = new ParalleDTO();
                        selectedParallel = parallelService.GetParallel(id);

                        Console.WriteLine(id);

                        #region Set data to Fields


                        #endregion


                        btnDelete.Enabled = true;
                    }
                }
            }
            catch (ArgumentOutOfRangeException es)
            {
                Console.WriteLine(es.Message);
            }
        }
예제 #2
0
        public List <ParalleDTO> getAllParallels()
        {
            string            connectionString = @"Server=us-cdbr-east-03.cleardb.com;Database=heroku_e9719c4a59b4c8f;Uid=b9ff0a805dbcc5;Pwd=25d16e4a;";
            MySqlConnection   conn             = new MySqlConnection(connectionString);
            List <ParalleDTO> arrayParallels   = null;

            try
            {
                string query = "SELECT * FROM parallels";

                conn.Open();
                MySqlCommand    cmd = new MySqlCommand(query, conn);
                MySqlDataReader rdr = cmd.ExecuteReader();
                arrayParallels = new List <ParalleDTO>();

                while (rdr.Read())
                {
                    ParalleDTO paralleDTO = new ParalleDTO();
                    paralleDTO.Id      = rdr.GetInt32(0);
                    paralleDTO.Par1_id = rdr.GetInt32(1);
                    try
                    {
                        paralleDTO.Par2_id = rdr.GetInt32(2);
                        paralleDTO.Par3_id = rdr.GetInt32(3);
                    }
                    catch (Exception er)
                    {
                        if (er.Message == "")
                        {
                        }
                    }


                    arrayParallels.Add(paralleDTO);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                conn.Close();
            }

            return(arrayParallels);
        }
예제 #3
0
        public List <ParalleDTO> getAllParallels()
        {
            SQLiteConnection  conn           = new SQLiteConnection("Data Source=database.db;Version=3;");
            List <ParalleDTO> arrayParallels = null;

            try
            {
                string query = "SELECT * FROM parallels";

                conn.Open();
                SQLiteCommand    cmd = new SQLiteCommand(query, conn);
                SQLiteDataReader rdr = cmd.ExecuteReader();
                arrayParallels = new List <ParalleDTO>();

                while (rdr.Read())
                {
                    ParalleDTO paralleDTO = new ParalleDTO();
                    paralleDTO.Id      = rdr.GetInt32(0);
                    paralleDTO.Par1_id = rdr.GetInt32(1);
                    try
                    {
                        paralleDTO.Par2_id = rdr.GetInt32(2);
                        paralleDTO.Par3_id = rdr.GetInt32(3);
                    }
                    catch (Exception er)
                    {
                        if (er.Message == "")
                        {
                        }
                    }


                    arrayParallels.Add(paralleDTO);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                conn.Close();
            }

            return(arrayParallels);
        }
예제 #4
0
        public ParalleDTO GetParallel(int id)
        {
            string          connectionString = @"Server=us-cdbr-east-03.cleardb.com;Database=heroku_e9719c4a59b4c8f;Uid=b9ff0a805dbcc5;Pwd=25d16e4a;";
            MySqlConnection conn             = new MySqlConnection(connectionString);
            ParalleDTO      paralleDTO       = new ParalleDTO();

            try
            {
                string query = "SELECT * FROM parallels WHERE id = @id";
                conn.Open();
                MySqlCommand cmd = new MySqlCommand(query, conn);
                cmd.Parameters.AddWithValue("@id", id);
                MySqlDataReader rdr = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    paralleDTO.Id      = rdr.GetInt32(0);
                    paralleDTO.Par1_id = rdr.GetInt32(1);
                    try
                    {
                        paralleDTO.Par2_id = rdr.GetInt32(2);
                        paralleDTO.Par3_id = rdr.GetInt32(3);
                    }
                    catch (Exception er)
                    {
                        if (er.Message == "")
                        {
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                conn.Close();
            }

            return(paralleDTO);
        }
예제 #5
0
        public ParalleDTO GetParallel(int id)
        {
            SQLiteConnection conn       = new SQLiteConnection("Data Source=database.db;Version=3;");
            ParalleDTO       paralleDTO = new ParalleDTO();

            try
            {
                string query = "SELECT * FROM parallels WHERE id = @id";
                conn.Open();
                SQLiteCommand cmd = new SQLiteCommand(query, conn);
                cmd.Parameters.AddWithValue("@id", id);
                SQLiteDataReader rdr = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    paralleDTO.Id      = rdr.GetInt32(0);
                    paralleDTO.Par1_id = rdr.GetInt32(1);
                    try
                    {
                        paralleDTO.Par2_id = rdr.GetInt32(2);
                        paralleDTO.Par3_id = rdr.GetInt32(3);
                    }
                    catch (Exception er)
                    {
                        if (er.Message == "")
                        {
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                conn.Close();
            }

            return(paralleDTO);
        }
예제 #6
0
        public List <ParalleDTO> searchParallel(string key, string type)
        {
            string            connectionString = @"Server=us-cdbr-east-03.cleardb.com;Database=heroku_e9719c4a59b4c8f;Uid=b9ff0a805dbcc5;Pwd=25d16e4a;";
            MySqlConnection   conn             = new MySqlConnection(connectionString);
            List <ParalleDTO> arrayParallels   = null;

            try
            {
                string query = "SELECT * FROM parallels WHERE " + type + " LIKE '%" + key + "%'";
                conn.Open();
                MySqlCommand cmd = new MySqlCommand(query, conn);
                cmd.Parameters.AddWithValue("@type", type);
                MySqlDataReader rdr = cmd.ExecuteReader();
                arrayParallels = new List <ParalleDTO>();

                while (rdr.Read())
                {
                    ParalleDTO paralleDTO = new ParalleDTO();
                    paralleDTO.Id      = rdr.GetInt32(0);
                    paralleDTO.Par1_id = rdr.GetInt32(1);
                    paralleDTO.Par2_id = rdr.GetInt32(2);
                    paralleDTO.Par3_id = rdr.GetInt32(3);


                    arrayParallels.Add(paralleDTO);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                conn.Close();
            }

            return(arrayParallels);
        }
예제 #7
0
        public List <ParalleDTO> searchParallel(string key, string type)
        {
            SQLiteConnection  conn           = new SQLiteConnection("Data Source=database.db;Version=3;");
            List <ParalleDTO> arrayParallels = null;

            try
            {
                string query = "SELECT * FROM parallels WHERE " + type + " LIKE '%" + key + "%'";
                conn.Open();
                SQLiteCommand cmd = new SQLiteCommand(query, conn);
                cmd.Parameters.AddWithValue("@type", type);
                SQLiteDataReader rdr = cmd.ExecuteReader();
                arrayParallels = new List <ParalleDTO>();

                while (rdr.Read())
                {
                    ParalleDTO paralleDTO = new ParalleDTO();
                    paralleDTO.Id      = rdr.GetInt32(0);
                    paralleDTO.Par1_id = rdr.GetInt32(1);
                    paralleDTO.Par2_id = rdr.GetInt32(2);
                    paralleDTO.Par3_id = rdr.GetInt32(3);


                    arrayParallels.Add(paralleDTO);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                conn.Close();
            }

            return(arrayParallels);
        }
예제 #8
0
 private void btnRefresh_Click(object sender, EventArgs e)
 {
     populateData();
     selectedParallel  = new ParalleDTO();
     btnDelete.Enabled = false;
 }
예제 #9
0
 public bool updateParallel(int id, ParalleDTO parallel)
 {
     throw new NotImplementedException();
 }