private void btnOK_Click(object sender, EventArgs e)
 {
     DataTable table = LoadData();
     rptSOReport r = new rptSOReport(LoadData(), SelectReport());
     r.txtDate = "ข้อมูลวันที่ " + dps.Value.ToString("dd/MM/yyyy") + " ถึงวันที่ " + dpe.Value.ToString("dd/MM/yyyy");
     r.ShowDialog();
 }
        private void ใบSALEORDERToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string sql = "SELECT " +
            "soh.OrderId,soh.OrderRef,soh.OrderDate " +
            ",p.ProductName " +
            ", " +
            "( " +
            "	SELECT COUNT(*) FROM dbo.SALE_ORDER_QTY soq WHERE soq.OrderId = soh.OrderId AND soq.ProductId = sod.ProductId " +
            ") Pack " +
            ",sod.DetailQuantity,sod.DateSend " +
            ",c.CustomerName,c.CustomerAddress " +
            ",u.UnitSaleName UnitPackName " +
            "FROM " +
            "dbo.SALE_ORDER_HEAD soh "+
            "INNER JOIN dbo.SALE_ORDER_DETAIL sod ON sod.OrderId = soh.OrderId " +
            "INNER JOIN dbo.PRODUCT p ON p.ProductId = sod.ProductId " +
            "INNER JOIN dbo.CUSTOMER c ON c.CustomerId = soh.CustomerId " +
            "LEFT JOIN dbo.UNITSALE u ON u.UnitSaleId = p.UnitSaleId " +
            "WHERE soh.OrderId = 'XXX' ";

            string OrderId = DgvHead.CurrentRow.Cells["OrderId"].Value.ToString();
            sql = sql.Replace("XXX", OrderId);

            DataTable tb = Class.DBConnString.clsDB.QueryDataTable(sql);
            tb.TableName = "DT_SaleOrderReceip";

            rptSOReport rpt = new rptSOReport(tb, SOSelectReport.SALE_ORDER_BILL);
            rpt.ShowDialog();
        }