private void btnAppointment_Click(object sender, EventArgs e) { objSQLDB = new SQLDB(); objHrInfo = new HRInfo(); try { string sRet = ""; string sAppint = "SELECT COUNT(*) FROM dbo.HR_APPL_APPOINTMENT A INNER JOIN HR_APPL_MASTER_HEAD B ON A.HRAP_APPL_NUMBER=B.HAMH_APPL_NUMBER WHERE HRAP_APPL_NUMBER=" + iApplNo; DataTable dt = objSQLDB.ExecuteDataSet(sAppint, CommandType.Text).Tables[0]; if (dt.Rows[0][0].ToString() == "0") { string strAppoint = CompanyCode + "," + BranchCode + "," + iApplNo + "," + EoraOCde + "," + txtApplNo.Text + "," + dtpRefDt.Value + "," + dtpEffectedDt.Value + "," + txtReportto.Text.Split('-')[0].ToString() + "," + cmbBranch.SelectedValue + "," + txtBasic_num.Text + "," + txtHRA_num.Text + "," + txtCCA_num.Text + "," + txtConv_num.Text + "," + txtSpl_num.Text + "," + txtUnif_num.Text + "," + txtChild_num.Text + "," + txtMedical_num.Text + "," + CommonData.LogUserId; sRet = objHrInfo.SaveAppointment(101, strAppoint.Split(',')); } else { string SReportto = ""; if (txtReportto.Text.Contains('-')) SReportto = txtReportto.Text.Split('-')[0].ToString(); else SReportto = txtReportto.Text; string strAppoint = CompanyCode + "," + BranchCode + "," + iApplNo + "," + EoraOCde + "," + txtApplNo.Text + "," + dtpRefDt.Value + "," + dtpEffectedDt.Value + "," + SReportto + "," + cmbBranch.SelectedValue + "," + txtBasic_num.Text + "," + txtHRA_num.Text + "," + txtCCA_num.Text + "," + txtConv_num.Text + "," + txtSpl_num.Text + "," + txtUnif_num.Text + "," + txtChild_num.Text + "," + txtMedical_num.Text + "," + CommonData.LogUserId; objHrInfo = new HRInfo(); sRet = objHrInfo.SaveAppointment(102, strAppoint.Split(',')); } if (sRet == "Saved") MessageBox.Show("This record inserted successfully.", "SSCRM Application", MessageBoxButtons.OK, MessageBoxIcon.Information); else if (sRet == "Update") MessageBox.Show("This record Updated successfully.", "SSCRM Application", MessageBoxButtons.OK, MessageBoxIcon.Information); else { MessageBox.Show(sRet, "SSCRM Application", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } DialogResult dlgResult = MessageBox.Show("Do you want print Appointment letter?", "Confirm?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dlgResult == DialogResult.Yes) { ReportViewer childForm = new ReportViewer(iApplNo); CommonData.ViewReport = "AppointmentLetter"; childForm.Show(); } ResetFields(this); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { objHrInfo = null; objSQLDB = null; } }