public int Yorum(Gunluk gunluk) { try { comm.CommandText = "INSERT INTO Gunluk(Yorum,SorumluID,StajyerID,Tarih) VALUES(@Yorum, @SorumluID,@StajyerID,@Tarih)"; comm.Parameters.AddWithValue("@Yorum", gunluk.Yorum); comm.Parameters.AddWithValue("@SorumluID", gunluk.SorumluID); comm.Parameters.AddWithValue("@StajyerID", gunluk.StajyerID); comm.Parameters.AddWithValue("@Tarih", gunluk.Tarih); comm.CommandType = CommandType.Text; conn.Open(); return(comm.ExecuteNonQuery()); } catch (Exception) { throw; } finally { if (conn != null) { conn.Close(); } } }
public List <Gunluk> YorumGetir(Gunluk gunluk) { List <Gunluk> gun = new List <Gunluk>(); try { comm.CommandText = "Select * from Gunluk where StajyerID=@StajyerID "; comm.Parameters.AddWithValue("@StajyerID", gunluk.StajyerID); comm.CommandType = CommandType.Text; conn.Open(); SqlDataReader reader = comm.ExecuteReader(); while (reader.Read()) { Gunluk gunlluk1 = new Gunluk() { YorumID = Convert.ToInt32(reader[0]), Yorum = reader[1].ToString(), SorumluID = Convert.ToInt32(reader[2]), StajyerID = Convert.ToInt32(reader[3]), Tarih = reader[4].ToString().TrimEnd('0', ':'), }; gun.Add(gunlluk1); } return(gun); } catch (Exception) { throw; } finally { if (conn != null) { conn.Close(); } } }