private void guna2Button4_Click(object sender, EventArgs e) { if (name.Text.Trim() == string.Empty) { MessageBox.Show("Empty UserName Field!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (nic.Text.Trim() == string.Empty) { MessageBox.Show("Empty NIC Field!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (contact.Text.Trim() == string.Empty) { MessageBox.Show("Empty Contact Field!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (address.Text.Trim() == string.Empty) { MessageBox.Show("Empty Address Field!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (!male.Checked && !female.Checked && !other.Checked) { MessageBox.Show("Select Gender!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (paidAmount.Text.Trim() == string.Empty) { MessageBox.Show("Empty Paid Amount Field!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { DialogResult answer; answer = MessageBox.Show("Are you sure want to Confirm Payment?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (answer == DialogResult.Yes) { try { //******patient database*****// DBconnection connection = new DBconnection(); string selectedGender = ""; if (male.Checked) { selectedGender = "Male"; } else if (female.Checked) { selectedGender = "Female"; } else { selectedGender = "Other"; } var dateOf = dob.Value; bill patientDetails = new bill(nic.Text, name.Text, dateOf.Date.ToString(), selectedGender, address.Text, Convert.ToInt32(contact.Text)); if (!connection.searchPatient(nic.Text)) { connection.addPatient(patientDetails); } //******bill database******// string billNumber = "B" + DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture); string date = DateTime.UtcNow.Date.ToString(); string requiredDate = rDate.Value.ToShortDateString(); double total1 = Convert.ToDouble(total.Text); bill billDetails = new bill(billNumber, date, requiredDate, global.UserID, nic.Text, total1, des.Text); connection.addInvoice(billDetails); //******report database******// foreach (global.reportStruct i in reportList) { report patientReport = new report(nic.Text, i.stReportNumber, i.stTest, i.stRequiredDate); DBconnection connection1 = new DBconnection(); connection1.Report(patientReport); } displayAvailableReports(); reportList.Clear(); clear(); } catch (Exception ex) { MessageBox.Show("Error:\n" + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Console.WriteLine("Error:\n" + ex); } } } }
private void guna2Button1_Click(object sender, EventArgs e) { try { string patientNic = nic.Text; DBconnection connection2 = new DBconnection(); if (connection2.searchPatient(patientNic)) { int counter = 0; ArrayList patientDetailsArray = new ArrayList(); //MessageBox.Show("Patient Found?", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); patientDetailsArray = connection2.getPatientDetails(patientNic); foreach (string i in patientDetailsArray) { Console.WriteLine("\n console: " + i + " counter: " + counter); if (counter == 0) { name.Text = i; } if (counter == 1) { dob.Value = DateTime.Parse(i); } //if (counter == 0) //{ // name.Text = i; //} if (counter == 2) { if (i.Equals("Male")) { male.Checked = true; } else if (i.Equals("Female")) { female.Checked = true; } else { other.Checked = true; } } if (counter == 4) { contact.Text = i; } else { address.Text = i; } counter++; } } else { MessageBox.Show("No Patient Found?", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show("No Patient Found ?", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Console.WriteLine("error search: " + ex); } }