public int InsertJournal(Journal journal)
        {
            int id = 0;
            using (SqlConnection con = DBConnection.GetConnection())
            {
                SqlCommand cmd = new SqlCommand("InsertJournal", con);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@date_entered", journal.DateEntered));
                cmd.Parameters.Add(new SqlParameter("@description", journal.Description));
                cmd.Parameters.Add(new SqlParameter("@image", journal.JournalImage));
                cmd.Parameters.Add(new SqlParameter("@crop_id_fk", journal.CropId));

                con.Open();
                //cmd.ExecuteNonQuery();
                SqlDataAdapter ad = new SqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                ad.Fill(ds);
                DataTable result = ds.Tables[0];
                foreach (DataRow row in result.Rows)
                {
                    id = Int16.Parse(row[0].ToString());
                }
                con.Close();
            }
            return id;
        }
        public List<Journal> SelectJournalByCropId(int crop_id)
        {
            List<Journal> journals = new List<Journal>();
            try
            {
                using (SqlConnection con = DBConnection.GetConnection())
                {
                    SqlCommand cmd = new SqlCommand("SelectJournalByCropId", con);
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@crop_id", crop_id));
                    con.Open();

                    SqlDataAdapter ad = new SqlDataAdapter(cmd);
                    DataSet ds = new DataSet();
                    ad.Fill(ds);
                    DataTable cropsTable = ds.Tables[0];
                    if (cropsTable == null)
                    {
                        return null;
                    }
                    else
                    {
                        foreach (DataRow row in cropsTable.Rows)
                        {
                            Journal journal = new Journal();
                            journal.JournalId = Int16.Parse(row[0].ToString());
                            journal.DateEntered = DateTime.Parse(row[1].ToString());
                            journal.Description = row[2].ToString();
                            journal.JournalImage = row[3] as byte[];
                            journal.CropId = Int16.Parse(row[4].ToString());
                            journals.Add(journal);
                        }
                    }
                    con.Close();
                }

            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }

            return journals;
        }