private void gcActualizaciones_DoubleClick(object sender, EventArgs e) { try { Modelos.Actualizacion entAct = new Modelos.Actualizacion(); foreach (int i in this.gridView1.GetSelectedRows()) { var dr1 = this.gridView1.GetRow(i); entAct = (Modelos.Actualizacion)dr1; } Modelos.ActualizacionDet res = this._consultasMySQLNegocio.obtieneDetalle(entAct.idActualizacion); frmVerPrecios form = new frmVerPrecios(entAct.nombreArticulo, res.precLista, res.precMinimo, res.precMayoreo, res.precFilial, res.precIMSS, res.medioMayoreo); form.ShowDialog(); } catch (Exception Ex) { MessageBox.Show(Ex.Message, "Descarga Información", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
// regresa toda la informacion sobre los articulos a actualizar public List <Actualizacion> obtieneInformacion(string fechaIni, string fechaFin, int bloque, bool pendiente, bool realizado) { List <Actualizacion> result = new List <Actualizacion>(); Actualizacion ent; // string sql = "select idusuario, usuario from activos_usuarios where usuario = @usuario and clave = @clave"; string sql = "select ac.id_actualizacion, ac.num_bloque, ac.fecha, ac.clave_articulo, a.nombre, " + "if(ac.fidel = 'P' , 'PENDIENTE', 'REALIZADO') as fidel, " + "if(ac.heroico = 'P' , 'PENDIENTE', 'REALIZADO') as heroico, " + "if(ac.libertad = 'P' , 'PENDIENTE', 'REALIZADO') as libertad, " + "if(ac.status = 'P' , 'PENDIENTE', 'REALIZADO') as status " + "from actualizacion ac " + "left join articulos a on (ac.clave_articulo = a.clave) " + "where ac.fecha between @fechaIni and @fechaFin "; if (bloque > 0) { sql += "and ac.num_bloque = @bloque "; } if (pendiente) { if (realizado) { sql += "and (ac.status = 'R' or ac.status = 'P')"; } else { sql += "and (ac.status = 'P')"; } } else if (realizado) { sql += "and (ac.status = 'R')"; } sql += " order by ac.num_bloque asc"; // define conexion con la cadena de conexion using (var conn = this._conexionMySQL.getConexionMySQL()) { // abre la conexion conn.Open(); using (var cmd = new MySqlCommand()) { cmd.Connection = conn; // define parametros cmd.Parameters.AddWithValue("@fechaIni", fechaIni); cmd.Parameters.AddWithValue("@fechaFin", fechaFin); if (bloque > 0) { cmd.Parameters.AddWithValue("@bloque", bloque); } ManejoSql_My res = Utilerias.EjecutaSQL(sql, cmd); if (res.ok) { while (res.reader.Read()) { ent = new Modelos.Actualizacion(); ent.idActualizacion = Convert.ToInt16(res.reader["id_actualizacion"]); ent.claveArticulo = Convert.ToString(res.reader["clave_articulo"]); ent.numBloque = Convert.ToInt16(res.reader["num_bloque"]); ent.fecha = Convert.ToString(res.reader["fecha"]); ent.fidel = Convert.ToString(res.reader["fidel"]); ent.heroico = Convert.ToString(res.reader["heroico"]); ent.libertad = Convert.ToString(res.reader["libertad"]); ent.status = Convert.ToString(res.reader["status"]); ent.nombreArticulo = Convert.ToString(res.reader["nombre"]); result.Add(ent); } } else { throw new Exception(res.numErr + ": " + res.descErr); } // cerrar el reader res.reader.Close(); } } return(result); }