コード例 #1
0
        private void btn_nuevo_Click(object sender, EventArgs e)
        {
            string datos = cbx_fiscalia.SelectedItem.ToString();

            reporte_compra f = new reporte_compra();

            f.label11.Text = dtp_actual.Text;
            f.label9.Text  = dateTimePicker1.Text;
            MySqlConnection cn;
            MySqlCommand    cmd;
            MySqlDataReader dr;

            try
            {
                cn = new MySqlConnection("server=localhost;user id=root; database=proyecto3; password="******"select nombre_c, apellido_c, cedula_c, nombre_i, nombre_g, monto, gastos from pr_compra where hidden =0 and actual >='" + dtp_actual.Text + "' and actual <='" + dateTimePicker1.Text + "' and nombre_c ='" + datos + "'", cn);
                dr  = cmd.ExecuteReader();

                while (dr.Read())
                {
                    f.dataGridView1.Rows.Add(dr.GetValue(0), dr.GetValue(1), dr.GetValue(2), dr.GetValue(3), dr.GetValue(4), dr.GetValue(5), dr.GetValue(6));
                }
                cn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error" + ex.Message);
            }
            f.Show();
        }
コード例 #2
0
        private void btn_nuevo_Click(object sender, EventArgs e)
        {
            string datos = cbx_fiscalia.SelectedItem.ToString();

            reporte_compra f = new reporte_compra();
            f.label11.Text = dtp_actual.Text;
            f.label9.Text = dateTimePicker1.Text;
            MySqlConnection cn;
            MySqlCommand cmd;
            MySqlDataReader dr;

            try
            {
                cn = new MySqlConnection("server=localhost;user id=root; database=proyecto3; password="******"select nombre_c, apellido_c, cedula_c, nombre_i, nombre_g, monto, gastos from pr_compra where hidden =0 and actual >='" + dtp_actual.Text + "' and actual <='" + dateTimePicker1.Text + "' and nombre_c ='"+ datos +"'", cn);
                dr = cmd.ExecuteReader();

                while (dr.Read())
                {
                    f.dataGridView1.Rows.Add(dr.GetValue(0), dr.GetValue(1), dr.GetValue(2), dr.GetValue(3), dr.GetValue(4), dr.GetValue(5), dr.GetValue(6));
                }
                cn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error" + ex.Message);
            }
            f.Show();
        }