private void btnFee_Click(object sender, EventArgs e) { if (cmbBoxTraineeTypes.SelectedIndex > -1 && cmbBoxCourses.SelectedIndex > -1 && txtBoxFee.Text.Length != 0) { objFees = new BAL_DesktopTrainingAPP.Fees(); int result = 0; string statusMsg = string.Empty; if (btnFee.Text.ToUpper().Contains("ADD")) { result = objFees.CreateFees(Convert.ToInt32(cmbBoxTraineeTypes.SelectedValue), Convert.ToInt32(cmbBoxCourses.SelectedValue), Convert.ToInt32(txtBoxFee.Text), Convert.ToInt32(txtBoxSTax.Text)); statusMsg = "Added new record successfully."; } else { result = objFees.UpdateFees(Convert.ToInt32(dgViewFees.CurrentRow.Cells[0].Value), Convert.ToInt32(cmbBoxTraineeTypes.SelectedValue), Convert.ToInt32(cmbBoxCourses.SelectedValue), Convert.ToDecimal(txtBoxFee.Text), Convert.ToInt32(txtBoxSTax.Text)); statusMsg = "Updated record successfully."; } if (result > 0) { LoadFeeDetails(); ClearAllControls(); MessageBox.Show(statusMsg, "Fee Creation", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
/// <summary> /// Reset the controls values /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnReset_Click(object sender, EventArgs e) { if (btnReset.Text.ToUpper().Contains("DELETE")) { if (MessageBox.Show("Do you want to delete the selected row?", string.Format("Fee Deletion Record #{0}", dgViewFees.CurrentRow.Cells[0].Value.ToString()), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { objFees = new BAL_DesktopTrainingAPP.Fees(); int result = objFees.DeleteFees((int)dgViewFees.CurrentRow.Cells[0].Value); if (result > 0) { LoadFeeDetails(); ClearAllControls(); } else { MessageBox.Show("Delete is not successfull"); } } catch (Exception ex) { MessageBox.Show("Error.... While Deletion " + ex.Message); } } } else { ClearAllControls(); } }
//private void FeeCreation_Load(object sender, EventArgs e) //{ // LoadFeeDetails(); //} private void LoadFeeDetails() { objFees = new BAL_DesktopTrainingAPP.Fees(); dgViewFees.DataSource = objFees.GetFees(); dgViewFees.Columns[0].Visible = false; }