Exemplo n.º 1
0
        private static distancias Loaddistancias(IDataReader reader)
        {
            distancias item = new distancias();

            item.tip1 = Convert.ToString(reader["tip1"]);
            item.lug1 = Convert.ToString(reader["lug1"]);
            item.tip2 = Convert.ToString(reader["tip2"]);
            item.lug2 = Convert.ToString(reader["lug2"]);
            item.cant = Convert.ToDecimal(reader["dist"]);
            return(item);
        }
Exemplo n.º 2
0
        public static int accion(distancias c, int op)
        {
            int rowsAffected = 0;

            try
            {
                using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["default"].ToString()))
                {
                    con.Open();

                    MySqlCommand command = new MySqlCommand("SP_distancias", con);
                    command.CommandType = CommandType.StoredProcedure;

                    MySqlParameter paramId = new MySqlParameter("msj", MySqlDbType.Int32);
                    paramId.Direction = ParameterDirection.Output;
                    command.Parameters.Add(paramId);

                    command.Parameters.AddWithValue("tipt1", c.tip1);
                    command.Parameters.AddWithValue("lugt1", c.lug1);
                    command.Parameters.AddWithValue("tipt2", c.tip2);
                    command.Parameters.AddWithValue("lugt2", c.lug2);
                    command.Parameters.AddWithValue("distt", c.cant);


                    command.Parameters.AddWithValue("opc", op);
                    command.ExecuteNonQuery();
                    rowsAffected = int.Parse(command.Parameters["msj"].Value.ToString());
                }
            }
            catch (MySqlException ex)
            {
                MessageBox.Show("Error de acceso a datos: " + ex.Message.ToString(), Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex1)
            {
                MessageBox.Show("Error: " + ex1.Message.ToString(), Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(rowsAffected);
        }