Esempio n. 1
0
        private void LoadStudent()
        {
            StudentAdap studentAdap = new StudentAdap();

            dgStudents.DataSource         = studentAdap.GetAll();
            dgStudents.Columns[0].Visible = false;
        }
Esempio n. 2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            int id = 0;

            //eğer DataGridView 'den herhangi bir kayıt seçilmeden Sil butonuna basıldığında
            //programın kırılmasını engelleyip, kullanıcıyı uyarmak için try - catch kullandık.
            try
            {
                id = Convert.ToInt32(dgStudents.CurrentRow.Cells[0].Value);
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("Lütfen silmek istediğiniz kaydı seçiniz!!", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            StudentAdap studentAdap = new StudentAdap();
            int         i           = studentAdap.Delete(id);

            if (i > 0)
            {
                MessageBox.Show("İşlem başarılı olmuştur.", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Information);
                LoadStudent();
            }
            else
            {
                MessageBox.Show("Kayıt silinememiştir!", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            //gerekli alanlar ve dogru bir tc girilmişmi kontrolü
            if (AnyMissingEntries().Count > 0)
            {
                string message = String.Join(",", AnyMissingEntries());
                MessageBox.Show(message, "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            StudentDto  student     = new StudentDto();
            StudentAdap studentAdap = new StudentAdap();

            student.Tc      = txtTc.Text;
            student.Name    = txtName.Text;
            student.Surname = txtSurname.Text;

            student.Bolum = cbDepartment.Text;
            student.City  = cbCity.Text;
            int i = studentAdap.Add(student);

            if (i > 0)
            {
                MessageBox.Show("Kayıt başarı ile eklendi.", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Information);
                LoadStudent();
            }
            else if (i == -1)
            {
                MessageBox.Show("Bu Tc daha önce eklenmiş!", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                MessageBox.Show("İşlem başarısız oldu!", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Esempio n. 4
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            ////zorunlu alanlar ve dogru bir tc girilmişmi kontrolü
            if (AnyMissingEntries().Count > 0)
            {
                string message = String.Join(",", AnyMissingEntries());
                MessageBox.Show(message, "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            StudentDto  student     = new StudentDto();
            StudentAdap studentAdap = new StudentAdap();

            //eğer DataGridView 'den herhangi bir kayıt seçilmeden Update butonuna basıldığında
            //programın kırılmasını engelleyip, kullanıcıyı uyarmak için try - catch kullandık.
            try
            {
                student.Id = Convert.ToInt32(dgStudents.CurrentRow.Cells[0].Value);
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("Lütfen güncellemek istediğiniz kaydı seçiniz!!", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            student.Id      = Convert.ToInt32(dgStudents.CurrentRow.Cells[0].Value);
            student.Tc      = txtTc.Text;
            student.Name    = txtName.Text;
            student.Surname = txtSurname.Text;
            student.Bolum   = cbDepartment.Text;
            student.City    = cbCity.Text;

            int i = studentAdap.Update(student);

            if (i > 0)
            {
                MessageBox.Show("Kayıt başarıyle güncellendi.", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Information);
                LoadStudent();
            }
            else
            {
                MessageBox.Show("İşlem başarısız olmuştur!", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }