private void btnBaoCao_Click(object sender, EventArgs e)
        {
            // dung showthanhtoandl
            frmShowThanhToanDL a = new frmShowThanhToanDL();
            string sql = "",err = "";
            string dieukien = "";

            a.type = "Khu vuc";
            dieukien = PrepareDK();
            sql = "select c.merchant_number,d.company_name merchant_name,b.terminal_id,nvl(sum(to_char(a.transaction_amount)),0) as Doanhso,"+
                        "d.date_create,d.account1 account " +
                  "from  " + Businessbp.executedb.owner + "merchant_stmt_txn_details a,  " + Businessbp.executedb.owner + "transaction_hist b,  " + Businessbp.executedb.owner + "merchant_stmt_details c,"+
                        " " + Businessbp.executedb.owner + "merchant d ,  " + Businessbp.executedb.owner + "city e "+
                  "where a.outlet_number = b.outlet_number "+
                        "and a.microfilm_ref_number = b.microfilm_ref_number "+
                        "and a.sequence_number = b.sequence_number "+
                        "and a.transaction_code = b.transaction_code "+
                        "and a.statement_no = c.statement_no "+
                        "and c.merchant_number = d.merchant_number "+
                        "and d.city_code = e.city_code "+
                        "and trunc(a.date_create) >= to_date('" + dtFrom.Text.Trim() + "','mm/dd/yyyy') "+
                        "and trunc(a.date_create) <= to_date('" + dtTo.Text.Trim() + "','mm/dd/yyyy') "+
                        dieukien +
                  "group by c.merchant_number,d.company_name,d.account1,b.terminal_id,d.date_create";

            DataTable dtt = Businessbp.executedb.getTable(sql, ref err);
            if (err != "")
            {
                MessageBox.Show(err);
                return;
            }
            a.dt = dtt;
            a.fromtime = dtFrom.Text;
            a.totime = dtTo.Text;
            a.thoiGian = DateTime.Now.ToShortDateString();
            a.ShowDialog();
        }
        private void btnChiTiet_Click(object sender, EventArgs e)
        {
            frmShowThanhToanDL a = new frmShowThanhToanDL();
            string sql = "", err = "";
            a.type = "Dai ly";
            if (merchantno == "")
            {
                MessageBox.Show("Please choose merchant number before.");
                return;
            }
            else
            {
                sql = "select b.transaction_date trans_date,b.authorization_number auth_number,b.trace_audit_number trace_number,a.transaction_amount trans_amount,a.net_amount,a.discount_amount discount_amount,"+
                             "decode(substr(lpad(b.processing_code,6,'0'),1,2),'00','Sale/Purchase','01','Cash Advance','02',decode(b.function_code,'401','Adjustment','200','Void'),'20','Refund','31','Balance Inquiry') trans_type," +
                             "a.transaction_currency currency " +
                      "from  " + Businessbp.executedb.owner + "merchant_stmt_txn_details a,  " + Businessbp.executedb.owner + "transaction_hist b,  " + Businessbp.executedb.owner + "merchant_stmt_details c,  " + Businessbp.executedb.owner + "merchant d " +
                      "where a.outlet_number = b.outlet_number " +
                            "and a.microfilm_ref_number = b.microfilm_ref_number " +
                            "and a.sequence_number = b.sequence_number " +
                            "and a.transaction_code = b.transaction_code " +
                            "and a.statement_no = c.statement_no " +
                            "and c.merchant_number = d.merchant_number " +
                            "and trunc(a.date_create) >= to_date('" + dtFrom.Text.Trim() + "','mm/dd/yyyy') " +
                            "and trunc(a.date_create) <= to_date('" + dtTo.Text.Trim() + "','mm/dd/yyyy') " +
                            "and c.merchant_number = '" + merchantno + "'";

                DataTable dtt = Businessbp.executedb.getTable(sql, ref err);
                if (err != "")
                {
                    MessageBox.Show(err);
                    return;
                }
                a.dt = dtt;
                a.fromtime = dtFrom.Text;
                a.totime = dtTo.Text;
                a.thoiGian = DateTime.Now.ToShortDateString();
                a.merchantno = merchantno;
                a.merchantname = merchantname;
                a.ShowDialog();
            }
        }