protected void btnPrintInv_Click(object sender, EventArgs e)
        {
            if (txtBillingInvoice.Text != "" && txtBillingDate.Text != "")
            {
                //    txtPrintBillInvDate.Value = DateTime.Now.ToString("MM/dd/yyyy");
                //    txtPrintBillInv.Text = "";
                //    PopUpControlPrintInv.HeaderText = "Print Billing Invoice";
                //    PopUpControlPrintInv.ShowOnPageLoad = true;
                //    txtPrintBillInv.Focus();
                //} else
                //{
                HLSSOA.Print_HLS_BillInv(Convert.ToInt32(Session["CreatorKey"]), txtBillingDate.Text, txtCustCode.Text, txtCustomer.Text, txtCustomerAdd.Text, txtCustTIN.Text, txtYear.Text, txtWeekNum.Text, txtPreparedBy.Text, txtApprovedBy.Text, txtSOANumber.Text);

                Session["BillInv_PrintKey"] = HLSSOA.hlsBillInvPrintKey.ToString();
                Session["DocumentViewer"]   = "HLS_BillInv";
                Response.Redirect("hlsSOA_Print.aspx");
            }
        }
        protected void BtnPrintInvOK_Click(object sender, EventArgs e)
        {
            SqlConnection  cn     = new SqlConnection(GlobalClass.SQLConnString());
            SqlCommand     cmdIns = null;
            DataTable      dt     = new DataTable();
            SqlCommand     cmd    = null;
            SqlDataAdapter adp;
            string         qry = "";

            cn.Open();
            qry            = "SELECT tbl_HLS_StatementOfAccount.* FROM tbl_HLS_StatementOfAccount WHERE (BillingInvoiceNum = '" + txtPrintBillInv.Text + "')";
            cmd            = new SqlCommand(qry);
            cmd.Connection = cn;
            adp            = new SqlDataAdapter(cmd);
            adp.Fill(dt);
            if (dt.Rows.Count == 0)
            {
                cmdIns = new SqlCommand("UPDATE tbl_HLS_StatementOfAccount SET BillingInvoiceNum = @BillingInvoiceNum, BillingInvoiceDate = @BillingInvoiceDate WHERE (SOANum = @SOANum)", cn);
                cmdIns.Parameters.AddWithValue("@SOANum", txtSOANumber.Text);
                cmdIns.Parameters.AddWithValue("@BillingInvoiceNum", txtPrintBillInv.Text);
                cmdIns.Parameters.AddWithValue("@BillingInvoiceDate", txtPrintBillInvDate.Text);
                cmdIns.ExecuteNonQuery();

                HLSSOA.Print_HLS_BillInv(Convert.ToInt32(Session["CreatorKey"]), txtPrintBillInvDate.Text, txtCustCode.Text, txtCustomer.Text, txtCustomerAdd.Text, txtCustTIN.Text, txtYear.Text, txtWeekNum.Text, txtPreparedBy.Text, txtApprovedBy.Text, txtSOANumber.Text);

                Session["BillInv_PrintKey"] = HLSSOA.hlsBillInvPrintKey.ToString();
                Session["DocumentViewer"]   = "HLS_BillInv";
                Response.Redirect("hlsSOA_Print.aspx");
            }
            else
            {
                txtError.Text = "Found duplicate invoice number.";
                PopUpControlError.HeaderText     = "Error . . .";
                PopUpControlError.ShowOnPageLoad = true;
            }
            dt.Clear();

            cn.Close();
        }