예제 #1
0
        private void btnSil_Click(object sender, EventArgs e)
        {
            Calisan silinecekCalisan = new Calisan();

            silinecekCalisan = (Calisan)dtwCalisan.CurrentRow.DataBoundItem;
            cp.Sil(silinecekCalisan);
            Listele();
        }
예제 #2
0
        private void btnCalisanEkle_Click(object sender, EventArgs e)
        {
            Calisan yeniCalisan = new Calisan();

            yeniCalisan.CalisanAd      = txtCalisanAdi.Text;
            yeniCalisan.CalisanSoyad   = txtCalisanSoyadi.Text;
            yeniCalisan.CalisanMevki   = txtCalisanMevki.Text;
            yeniCalisan.CalisanTelefon = txtCalisanTelefon.Text;
            cp.Ekle(yeniCalisan);
            Listele();
        }
예제 #3
0
        private void btnGuncelle_Click(object sender, EventArgs e)
        {
            Calisan eskicalisan = new Calisan();

            eskicalisan = (Calisan)dtwCalisan.CurrentRow.DataBoundItem;
            Calisan yenicalisan = new Calisan();

            yenicalisan.CalisanAd      = txtCalisanAdi.Text;
            yenicalisan.CalisanSoyad   = txtCalisanSoyadi.Text;
            yenicalisan.CalisanMevki   = txtCalisanMevki.Text;
            yenicalisan.CalisanTelefon = txtCalisanTelefon.Text;
            cp.Guncelle(eskicalisan, yenicalisan);
            Listele();
        }
 public void Sil(Calisan yeniCalisan)
 {
     try
     {
         komut.CommandText = "Delete From calisan Where Ad=" + yeniCalisan.CalisanAd + "";
         komut.CommandType = CommandType.Text;
         baglanti.Open();
         komut.ExecuteNonQuery();
     }
     catch (Exception)
     {
         throw;
     }
     finally
     {
         if (baglanti != null)
         {
             baglanti.Close();
         }
     }
 }
 public void Ekle(Calisan yeniCalisan)
 {
     try
     {
         komut.CommandText = "Insert Into calisan (Ad,Soyad,Mevki,Telefon) Values (" + yeniCalisan.CalisanAd
                             + ",'" + yeniCalisan.CalisanSoyad + "','" + yeniCalisan.CalisanMevki + "','" + yeniCalisan.CalisanTelefon + "')";
         komut.CommandType = CommandType.Text;
         baglanti.Open();
         komut.ExecuteNonQuery();
     }
     catch (Exception)
     {
         throw;
     }
     finally
     {
         if (baglanti != null)
         {
             baglanti.Close();
         }
     }
 }
 public void Guncelle(Calisan eskiCalisan, Calisan yeniCalisan)
 {
     try
     {
         komut.CommandText = "Update calisan SET Ad='" + yeniCalisan.CalisanAd +
                             "',Soyad='" + yeniCalisan.CalisanSoyad + "',Mevki='" + yeniCalisan.CalisanMevki + "',Telefon='"
                             + yeniCalisan.CalisanTelefon + "' Where id=" + eskiCalisan.id + "";
         komut.CommandType = CommandType.Text;
         baglanti.Open();
         komut.ExecuteNonQuery();
     }
     catch (Exception)
     {
         throw;
     }
     finally
     {
         if (baglanti != null)
         {
             baglanti.Close();
         }
     }
 }
        public List <Calisan> Listele()
        {
            try
            {
                List <Calisan> calisanListesi = new List <Calisan>();
                komut.CommandText = "Select *From calisan";
                komut.CommandType = CommandType.Text;
                baglanti.Open();
                SqlDataReader reader = komut.ExecuteReader();
                while (reader.Read())
                {
                    Calisan yeniCalisan = new Calisan();
                    yeniCalisan.CalisanAd      = reader[1].ToString();
                    yeniCalisan.CalisanSoyad   = reader[2].ToString();
                    yeniCalisan.CalisanMevki   = reader[3].ToString();
                    yeniCalisan.CalisanTelefon = reader[4].ToString();



                    calisanListesi.Add(yeniCalisan);
                }

                return(calisanListesi);
            }
            catch
            {
                throw;
            }
            finally
            {
                if (baglanti != null)
                {
                    baglanti.Close();
                }
            }
        }