using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;

namespace HMI
{

    public partial class Form_detalle : Form
    {
        SqlCommand cmd;
        SqlConnection cn;
        SqlDataReader dr;
        SqlDataAdapter da;
        DataTable dt;
        string fecha_inicio_text;
        public Form_detalle(string fecha_inicio_tex)
        {
            InitializeComponent();
            cn = new SqlConnection("Data Source=.;Initial Catalog=data_hmi;Integrated Security=True");
            this.fecha_inicio_text = fecha_inicio_tex.ToString();
        }

        private void Form_detalle_Load(object sender, EventArgs e)
        {
            cn.Open();
            da = new SqlDataAdapter("select * from rollizos where fecha='"+fecha_inicio_text+"'", cn);
            dt = new DataTable() ;
            da.Fill(dt);
            data_detalle.DataSource = dt;
            cn.Close();
        }

        private void data_detalle_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            Bitmap objBmp = new Bitmap(this.data_detalle.Width, this.data_detalle.Height);
            data_detalle.DrawToBitmap(objBmp, new Rectangle(0, 0, this.data_detalle.Width, this.data_detalle.Height));
            e.Graphics.DrawImage(objBmp, 70, 90);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            printPreviewDialog1.Document = printDocument1;
            printPreviewDialog1.ShowDialog();

        }
    }


}
