コード例 #1
0
        //****add report details to the database****//
        public void Report(report obj)
        {
            string query = "IF OBJECT_ID('dbo.Report', 'U') IS NULL ";

            query += "BEGIN ";
            query += "CREATE TABLE [dbo].[Report](";
            query += "[ReportNumber] VARCHAR(1000)  NOT NULL ,";
            query += "[PatientNic] VARCHAR(25) NOT NULL,";
            query += "[ReportName] VARCHAR(100) NOT NULL,";
            query += "[RequiredDate] VARCHAR(100) ,";
            query += "[FinishedDate] VARCHAR(100) ,";
            query += "[ReportDocument] varbinary(MAX) ,";
            query += "CONSTRAINT pkreport PRIMARY KEY (ReportNumber,PatientNic)";
            query += ")";
            query += " END";

            String sqlQuery = "INSERT INTO dbo.Report(ReportNumber,PatientNic,ReportName,RequiredDate) " +
                              "VALUES ('" + obj.ReportNumber + "','" + obj.PatientNic + "','" + obj.ReportName + "','" + obj.RequiredDate + "')";

            //Console.WriteLine("\nokay: " + obj.Reportnumber + "', '" + obj.PatientNic + "', '" + obj.Reportname + "', '" + obj.Requireddate);


            getConnection();
            SqlCommand cmd = new SqlCommand(query, getConnection());

            cmd.ExecuteNonQuery();
            SqlCommand cmd1 = new SqlCommand(sqlQuery, getConnection());

            cmd1.ExecuteNonQuery();
            getConnection().Close();
        }
コード例 #2
0
        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);
                    }
                }
            }
        }