Example #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                Departmans      departmans = new Departmans();
                DataGridViewRow selected   = dgvDepartman.SelectedRows[0];
                if (string.IsNullOrWhiteSpace(txtAciklama.Text) && string.IsNullOrWhiteSpace(txtDepartman.Text))
                {
                    MessageBox.Show("Lütfen Departman seçiniz");
                }
                else
                {
                    departmans.DepartmanID = (int)selected.Cells["DepartmanID"].Value;

                    DialogResult result = MessageBox.Show("Departmanı Silmek İstediğinize Emin Misiniz!!!", "Çıkış Onay", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        departmanBLL.Delete(departmans);
                        ListDepartman();
                        ClearBox();
                    }
                    else
                    {
                        this.Show();
                        ClearBox();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                ClearBox();
            }
        }
 public int Delete(Departmans departmans)
 {
     helper.CommandText = "Delete From Departman Where DepartmanID=@departmanID";
     helper.Parameters.Clear();
     helper.Parameters.Add("@departmanID", departmans.DepartmanID);
     return(helper.ExecuteQuery());
 }
Example #3
0
        //Departman EKLEME
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Departmans departmans = new Departmans();

            try
            {
                string departmanName = txtDepartman.Text.ToUpper();
                departmans.Departman = departmanName;
                departmans.Aciklama  = txtAciklama.Text;
                foreach (var item in departmanBLL.GetDepartmans())
                {
                    if (item.Departman == departmanName)
                    {
                        MessageBox.Show("Departman İsmi Zaten Var");
                        ClearBox();
                        return;
                    }
                }
                departmanBLL.AddDepartman(departmans);
                MessageBox.Show("Departman Başarıyla Eklenmiştir");
                ClearBox();
                ListDepartman();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                ClearBox();
            }
        }
 public int Insert(Departmans departmans)
 {
     helper.CommandText = "Insert Into Departman (Departman,Aciklama) Values (@departman,@aciklama)";
     helper.Parameters.Clear();
     helper.Parameters.Add("@departman", departmans.Departman);
     helper.Parameters.Add("@aciklama", departmans.Aciklama);
     return(helper.ExecuteQuery());
 }
        private Departmans MapDepartmanName(SqlDataReader reader)
        {
            Departmans departman = new Departmans();

            //departman.DepartmanID = (int)reader["DepartmanID"];
            //departman.Aciklama = reader["Aciklama"].ToString();
            departman.Departman = reader["Departman"].ToString();
            return(departman);
        }
 public int Update(Departmans departmans)
 {
     helper.CommandText = "Update Departman Set Departman=@departman,Aciklama=@aciklama where DepartmanID=@departmanID";
     helper.Parameters.Clear();
     helper.Parameters.Add("@departmanID", departmans.DepartmanID);
     helper.Parameters.Add("@departman", departmans.Departman);
     helper.Parameters.Add("@aciklama", departmans.Aciklama);
     return(helper.ExecuteQuery());
 }
 public bool Update(Departmans departmans)
 {
     try
     {
         CheckRequiredFields(departmans.Departman, departmans.Aciklama);
         CheckLength(departmans.Departman, departmans.Aciklama);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(departmanDAL.Update(departmans) > 0);
 }
        // Departman İsimlerini Getirir
        public List <Departmans> GetDepartmansName()
        {
            helper.CommandText = "Select Departman From Departman";
            helper.Parameters.Clear();
            List <Departmans> departmans = new List <Departmans>();
            Departmans        departman  = null;
            SqlDataReader     reader     = helper.SqlDataReader();

            while (reader.Read())
            {
                departman = MapDepartmanName(reader);
                departmans.Add(departman);
            }
            reader.Close();
            return(departmans);
        }
Example #9
0
 private void btnUpdate_Click(object sender, EventArgs e)//Merte Sor Seçili iken başka cell seçiliyken hata veriyor
 {
     try
     {
         if (string.IsNullOrWhiteSpace(txtAciklama.Text) && string.IsNullOrWhiteSpace(txtDepartman.Text))
         {
             MessageBox.Show("Lütfen Departman seçiniz");
         }
         else
         {
             Departmans departmans = new Departmans();
             departmanBLL.CheckBox(txtDepartman.Text, txtAciklama.Text);
             DataGridViewRow selected = dgvDepartman.SelectedRows[0];
             departmans.Departman = txtDepartman.Text;
             departmans.Aciklama  = txtAciklama.Text;
             //foreach (var item in departmanBLL.GetDepartmans())
             //{
             //    if (item.Departman == txtDepartman.Text)
             //    {
             //        MessageBox.Show("Departman İsmi Zaten Var");
             //        ClearBox();
             //        return;
             //    }
             //}
             departmans.DepartmanID = (int)selected.Cells["DepartmanID"].Value;
             departmanBLL.Update(departmans);
             MessageBox.Show("Güncelleme başarılı");
             ClearBox();
             ListDepartman();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         ClearBox();
     }
 }
 public bool Delete(Departmans departmans)
 {
     return(departmanDAL.Delete(departmans) > 0);
 }