private void obtenerLista() { MySqlConnection con = MyCon.ObtenerConexion(); MySqlCommand cmd = new MySqlCommand("select * from reportes", con); DataTable dt = new DataTable(); dt.Load(cmd.ExecuteReader()); con.Close(); dtGrid.DataContext = dt; }
public static int Agregar(Reportar pReporte) { int retorno = 0; string pFecha = DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString() + "/" + DateTime.Now.Day.ToString(); string pUser = "******"; string pHora = DateTime.Now.TimeOfDay.Hours.ToString() + ":" + DateTime.Now.TimeOfDay.Minutes.ToString(); MySqlCommand comando = new MySqlCommand(string.Format("Insert into reportes(userid,fecha,hora,serial,makat,paka) values('{0}','{1}','{2}','{3}','{4}','{5}')", pUser, pFecha, pHora, pReporte.serial, pReporte.makat, pReporte.Paka), MyCon.ObtenerConexion()); try { retorno = comando.ExecuteNonQuery(); } catch (Exception) { throw; } return(retorno); }