Exemplo n.º 1
0
        private void btnRefresh_Click(object sender, EventArgs e)
        {
            DaoRepVentas daoRepVentas = new DaoRepVentas();
            DataSet      dsData       = daoRepVentas.getVentasMes(dtpFecha.Value.ToShortDateString());

            refreshData();
            dgvData.Columns.Clear();
            dgvData.Rows.Clear();
            dgvData.DataSource = dsData.Tables[0];

            DataGridViewColumn colum = new DataGridViewColumn();

            colum.HeaderText   = "FacturaEnDeuda";
            colum.CellTemplate = new DataGridViewTextBoxCell();
            dgvData.Columns.Add(colum);

            int    idFact      = 0;
            string Fact        = "";
            double totalDeudas = 0;
            int    countDeudas = 0;

            System.Collections.IList list = dgvData.Rows;
            for (int i = 0; i < list.Count; i++)
            {
                DataGridViewRow row   = (DataGridViewRow)list[i];
                string          Query = "SELECT deuda.id AS CODIGODEUDA, deuda.codeFact AS FACTURA, amount AS MONTO FROM deuda WHERE deuda.codeFact = '" + row.Cells[0].Value + "' AND deuda.active = 1;";

                MySqlCommand Cmm = new MySqlCommand(Query, ConectDB.getConection());

                MySqlDataReader reader;

                reader = Cmm.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        idFact = (int)reader["CODIGODEUDA"];
                        Fact   = (string)reader["FACTURA"];
                    }

                    if (idFact > 0)
                    {
                        row.Cells[7].Value           = "SI";
                        row.Cells[7].ReadOnly        = true;
                        row.Cells[7].Style.BackColor = Color.Red;
                    }
                    else
                    {
                        row.Cells[7].Value           = "NO";
                        row.Cells[7].ReadOnly        = true;
                        row.Cells[7].Style.BackColor = Color.Green;
                    }
                }

                Cmm.Connection.Close();
            }
            RecalcularTotales();
        }