Exemple #1
0
        private void AccountAction(object sender, EventArgs e)
        {
            if (DGV_invoice.Rows[DGV_invoice.CurrentRow.Index].Cells[0].Value != null)
            {
                string tag = ((ToolStripMenuItem)sender).Tag.ToString();//получили тип действия пользователя
                var    act = tag == "change" ? UserAction.change : UserAction.delete;

                switch (act)
                {
                case UserAction.change:
                    using (var accForm = new AccountForm(new AccountFormParams()
                    {
                        action = act,
                        id = Convert.ToInt32(DGV_invoice.Rows[DGV_invoice.CurrentRow.Index].Tag),
                        user_info = DGV_invoice.Rows[DGV_invoice.CurrentRow.Index]
                    }))
                    {
                        accForm.ShowDialog();
                    }

                    LoadGrid();
                    break;

                case UserAction.delete:
                    if (MessageBox.Show("Вы уверены, что хотите удалить запись?", "Удаление записи", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        if ((bool)Functions.AccountAction(new AccountActionParams()
                        {
                            action = act,
                            id = Convert.ToInt32(DGV_invoice.Rows[DGV_invoice.CurrentRow.Index].Tag
                                                 )
                        }))
                        {
                            MessageBox.Show("Информация успешно удалена", "Удаление записи", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            LoadGrid();
                        }
                        else
                        {
                            MessageBox.Show("Ошибка при удалении информации", "Удаление записи", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    break;

                default:
                    using (var accForm = new AccountForm(new AccountFormParams()
                    {
                        action = UserAction.change,
                    }))
                    {
                        accForm.ShowDialog();
                    }

                    LoadGrid();

                    break;
                }
            }
        }
Exemple #2
0
        private void BT_add_Click(object sender, EventArgs e)
        {
            using (var accForm = new AccountForm(new AccountFormParams()
            {
                action = UserAction.add
            }))
            {
                accForm.ShowDialog();
            }

            LoadGrid();
        }