示例#1
0
        private void BtnSave_Click(object sender, EventArgs e)

        {
            if (string.IsNullOrWhiteSpace(txtFirstname.Text) || string.IsNullOrWhiteSpace(txtSecondname.Text) || cmbBelief.SelectedIndex == 0 || cmbMp.SelectedIndex == 0 || cmbResidence.SelectedIndex == 0)
            {
                MessageBox.Show("All fields are required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                try
                {
                    clsModule.CreateMp(txtFirstname.Text.ToUpper(), txtSecondname.Text.ToUpper(), int.Parse(cmbBelief.SelectedValue.ToString()), int.Parse(cmbResidence.SelectedValue.ToString()),
                                       int.Parse(cmbMp.SelectedValue.ToString()));

                    if (clsModule.Status > 0)
                    {
                        MessageBox.Show("New Mp Added Successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        clear();
                    }
                    else
                    {
                        MessageBox.Show("Invalid MP Combination", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.ToString());
                }
            }
        }