private void btnSubmit_Click(object sender, EventArgs e) { try { DbHelper obj = new DbHelper(); bool i = obj.NonQuery("insert into PatientReportMaster (PatientId, ReportId) values (" + PatientId + "," + Convert.ToInt32(ddlReport.SelectedValue) + ")"); int patientReportId = Convert.ToInt32(obj.GetScaler("select max(ID) from PatientReportMaster")); bool flag; foreach (DataGridViewRow row in gridReport.Rows) { int TestId = Convert.ToInt32(row.Cells["TestId"].Value); string TestValue = Convert.ToString(row.Cells["TestValue"].Value); string TestUnit = Convert.ToString(row.Cells["Unit"].Value); flag = obj.NonQuery("insert into PatientTestReportValue (PatientReportID,ReportID, TestID, TestValue, TestUnit) values (" + patientReportId + "," + Convert.ToInt32(ddlReport.SelectedValue) + "," + TestId + ",'" + TestValue + "','" + TestUnit + "')"); if (flag == false) { string message = "Error Occurred " + obj.ExceptionInfo; MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } } frmReport objReport = new frmReport(patientReportId); objReport.MdiParent = this.MdiParent; objReport.WindowState = FormWindowState.Maximized; objReport.Show(); this.Close(); } catch (Exception ex) { string message = "Message " + ex.Message + "InnerException " + ex.InnerException + " Source " + ex.Source + " Stack Trace " + ex.StackTrace; MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnSubmit_Click(object sender, EventArgs e) { try { frmReport objReport = new frmReport(PatientReportMasterId); objReport.MdiParent = this.MdiParent; objReport.WindowState = FormWindowState.Maximized; objReport.Show(); this.Close(); } catch (Exception ex) { } }
private void button1_Click(object sender, EventArgs e) { frmReport obj = new frmReport(Convert.ToInt32(comboBox1.SelectedValue)); obj.Show(); }