Esempio n. 1
0
        private void SaveBill()
        {
            try
            {
                if (lblGrandTotal.Text == "0.00")
                {
                    MessageBox.Show("Please add atleast one service for patient and retry again!", "Information Required", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                if (txtName.Text == "")
                {
                    MessageBox.Show("Please enter the patient id and retry again!", "Information Required", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                Conn          obCon = new Conn();
                SqlConnection ob    = new SqlConnection(obCon.strCon);
                SqlCommand    cmd   = new SqlCommand("SP_SAVE_tblOPBill", ob);

                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add("@BillID", SqlDbType.VarChar, 50);
                cmd.Parameters.Add("@BillDate", SqlDbType.VarChar, 50);
                cmd.Parameters.Add("@SubTotal", SqlDbType.Float);
                cmd.Parameters.Add("@Discount", SqlDbType.Float);
                cmd.Parameters.Add("@Recieved", SqlDbType.Float);
                cmd.Parameters.Add("@Exchanged", SqlDbType.Float);
                cmd.Parameters.Add("@GrandTotal", SqlDbType.Float);
                cmd.Parameters.Add("@PatientName", SqlDbType.VarChar, 50);
                cmd.Parameters.Add("@Age", SqlDbType.VarChar, 50);
                cmd.Parameters.Add("@Sex", SqlDbType.VarChar, 50);

                cmd.Parameters[0].Value = txtBillNo.Text;
                cmd.Parameters[1].Value = dateTimePicker1.Text;
                cmd.Parameters[2].Value = txtSubTotal.Text;
                cmd.Parameters[3].Value = txtDiscount.Text;
                cmd.Parameters[4].Value = txtRecieved.Text;
                cmd.Parameters[5].Value = txtExchanged.Text;
                cmd.Parameters[6].Value = lblGrandTotal.Text;
                cmd.Parameters[7].Value = txtName.Text;
                cmd.Parameters[8].Value = txtAge.Text;
                if (optMale.Checked == true)
                {
                    cmd.Parameters[9].Value = "Male";
                }
                else if (optFemale.Checked == true)
                {
                    cmd.Parameters[9].Value = "Female";
                }

                ob.Open();
                cmd.ExecuteNonQuery();
                ob.Close();

                SaveService();
                SavePatient();

                DialogResult dr = MessageBox.Show("Bill created successfully! Do you want to print it?", "Print", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dr == DialogResult.Yes)
                {
                    ReportViewer.ViewReport frm = new GHospital_Care.ReportViewer.ViewReport("OPBill", txtBillNo.Text);
                    frm.Show();
                }
                SetNew();
            }
            catch (Exception error)
            {
                MessageBox.Show("Failed to save bill! " + error.Message.ToString(), "Failed", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 2
0
 private void btnPrint_Click(object sender, EventArgs e)
 {
     ReportViewer.ViewReport frm = new GHospital_Care.ReportViewer.ViewReport("OPBill", txtBillNo.Text);
     frm.Show();
 }