예제 #1
0
        }//tuition form close button

        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult ans = MessageBox.Show("Are you sure you want to delete this record ", "System message", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (ans.Equals(DialogResult.Yes))
            {
                //get id
                tuitionFee.Id = Int32.Parse(dgvTuitionFees.CurrentRow.Cells[0].FormattedValue.ToString());
                tuitionFee.Delete();

                //call load record to refresh list
                this.LoadRecords();

                //reset all objects
                this.Reset();

                pnlEditVoucher.Visible = false;
                pnlNewTuition.Visible  = true;
                btnAdd.Enabled         = true;
            }
        }
예제 #2
0
        private void dgvTuitionFee_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0)
            {
                id = Convert.ToInt32(dgvTuitionFee.Rows[e.RowIndex].Cells[2].Value.ToString());//for editing criteria

                //pass value to edit mode
                txtTuitionFeeName.Text = dgvTuitionFee.Rows[e.RowIndex].Cells[3].Value.ToString(); //Name
                txtAmount.Text         = dgvTuitionFee.Rows[e.RowIndex].Cells[4].Value.ToString(); //Name
                txtDesc.Text           = dgvTuitionFee.Rows[e.RowIndex].Cells[5].Value.ToString(); //Name
                cmbStatus.Text         = dgvTuitionFee.Rows[e.RowIndex].Cells[6].Value.ToString(); //Name
                cmbDept.Text           = dgvTuitionFee.Rows[e.RowIndex].Cells[7].Value.ToString(); //Name
                txtReservation.Text    = dgvTuitionFee.Rows[e.RowIndex].Cells[8].Value.ToString(); //Name

                btnAdd.Text = "&Update";                                                           //set button to Update
            }

            else if (e.ColumnIndex == 1)
            {
                string message = "Do you want to delete this record?";
                string title   = "Enrollment System";

                MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                DialogResult      result  = MessageBox.Show(message, title, buttons, MessageBoxIcon.Warning);

                if (result == DialogResult.Yes)
                {
                    tuition.Id = Convert.ToInt32(dgvTuitionFee.Rows[e.RowIndex].Cells[2].Value.ToString());//for editing criteria
                    tuition.Delete();

                    tuition.LoadDataTable(dgvTuitionFee);
                }
                else
                {
                    return;
                }
            }
        }