private void BtnUpdate_Click(object sender, EventArgs e) { if (dataGridView1.Rows.Count == 0) { MessageBox.Show("لا يوجد فئات"); } else { if (Application.OpenForms.OfType <frmCategoryCRUD>().Any()) { return; } else { new frmCategoryCRUD(this, CategoriesLogic.EditButton(dataGridView1)).Show(); } } }
//add-update button private void BtnCRUD_Click(object sender, EventArgs e) { //update if (parameters.Count > 0) { try { if (Edit(int.Parse(parameters[0]), txtName.Text, btnColorPicker.BackColor.Name.ToString())) { frmCategory.Focus(); CategoriesLogic.RefreshAfterEdit(frmCategory.dataGridView1); parameters.Clear(); parameters.TrimExcess(); this.Close(); } } catch (Exception) { throw; } } //add else { try { if (Insert(txtName.Text, btnColorPicker.BackColor.Name.ToString())) { frmCategory.Focus(); CategoriesLogic.RefreshAfterAdd(frmCategory.dataGridView1); this.Close(); } } catch (Exception) { throw; } } }
private void TxtSearch_TextChanged(object sender, EventArgs e) { CategoriesLogic.SearchButton(dataGridView1, txtSearch, true); }
private void BtnSearch_Click(object sender, EventArgs e) { CategoriesLogic.SearchButton(dataGridView1, txtSearch, false); }
private void BtnDelete_Click(object sender, EventArgs e) { CategoriesLogic.DeleteButton(dataGridView1); }