Exemple #1
0
        private void categoryDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            AddCategoryUi addCategoryUi = new AddCategoryUi(this);

            addCategoryUi.ClearAllText();
            if (categoryDataGridView.Columns[e.ColumnIndex].Name == "Edit")
            {
                try
                {
                    if (e.RowIndex >= 0)
                    {
                        if (categoryDataGridView.CurrentRow != null)
                        {
                            categoryDataGridView.CurrentRow.Selected = true;
                        }

                        //_category.Id = Convert.ToInt32(categoryDataGridView.Rows[e.RowIndex].Cells[1].Value);
                        addCategoryUi.categoryId              = Convert.ToInt32(categoryDataGridView.Rows[e.RowIndex].Cells[1].Value);
                        addCategoryUi.codeTextBox.Text        = categoryDataGridView.Rows[e.RowIndex].Cells[2].Value.ToString();
                        addCategoryUi.nameTextBox.Text        = categoryDataGridView.Rows[e.RowIndex].Cells[3].Value.ToString();
                        addCategoryUi.saveOrUpdateButton.Text = @"Update";
                        addCategoryUi.ShowDialog();
                    }
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.Message);
                }
            }
        }
Exemple #2
0
        private void addCategoryButton_Click(object sender, EventArgs e)
        {
            AddCategoryUi addCategoryUi = new AddCategoryUi(this);

            addCategoryUi.ShowDialog();
        }