private void b_Add_Click(object sender, EventArgs e) { if (tid.Text == string.Empty || tname.Text == string.Empty || tpay.Text == string.Empty || tsalary.Text == string.Empty) { MessageBox.Show("Please Fillup all the text fields!!"); } else { if (Double.Parse(tpay.Text) <= Double.Parse(tsalary.Text)) { double x = Double.Parse(tsalary.Text) - Double.Parse(tpay.Text); lAmount.Text = x.ToString(); SalaryService sal = new SalaryService(); int result = sal.Insert(new Salary() { Eid = Convert.ToInt16(tid.Text), Name = tname.Text, Month = dateTimePicker1.Value.Month.ToString(), Pay = Double.Parse(tpay.Text), Total_Salary = Double.Parse(tsalary.Text), Remain_salary = x, Year = tyear.Value.Year.ToString() }); if (result > 0) { MessageBox.Show("Salary added."); } else { MessageBox.Show("Error"); } } else { MessageBox.Show("Payment is greater than total salary "); } } }