private void FeePayForm_Load(object sender, EventArgs e) { if (string.IsNullOrEmpty(id)) { MessageBox.Show("Something went wrong!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } typetxt.SelectedIndex = 0; datetxt.MaxDate = DateTime.Today; datetxt.Text = DateTime.Today.ToShortDateString(); if (formtype.Equals("trainee")) { fee = new Fee(); balancetxt.Text = fee.CheckLastBalance(id).ToString(); lastBal = int.Parse(balancetxt.Text); if (lastBal == 0) { MessageBox.Show("No Fee Remaining", "Fee Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (lastBal == -1) { MessageBox.Show("Something went wrong!"); this.Close(); } } else if (formtype.Equals("admission")) { balancetxt.Text = lastBal.ToString(); } }