Esempio n. 1
0
        private void Btnguardar_Click(object sender, EventArgs e)
        {
            try
            {
                clases.Aplicaciones objeto = new clases.Aplicaciones();
                objeto.Descripcion  = txtnombre.Text.ToUpper().Trim();
                objeto.IdPlataforma = Convert.ToInt32(cmbplataforma.SelectedValue);
                objeto.Start        = txtstart.Text.ToUpper().Trim();
                objeto.Stop         = txtkill.Text.ToUpper().Trim();

                if (txtnombre.Text != "" && clases.Aplicaciones.Insertar(objeto, opcion, pidapp) > 0)
                {
                    MessageBox.Show("Operacion Correcta", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ClearScreen();
                }
                else
                {
                    MessageBox.Show("Operacion Incorrecta", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: " + error);
            }
        }
Esempio n. 2
0
        public static int Insertar(clases.Aplicaciones objeto, int opcion, int id)
        {
            clases.Conexion conexion = new clases.Conexion();
            int             retorno;
            MySqlCommand    cmd;

            try
            {
                if (opcion == 0)
                {
                    conexion.AbrirConexion();
                    cmd = new MySqlCommand("PROC_INSERTAR_APP(@NOMBRE,@PLATAFORMA,@START,@STOP)", conexion.conexion);
                    cmd.Parameters.AddWithValue("@NOMBRE", objeto.Descripcion);
                    cmd.Parameters.AddWithValue("@PLATAFORMA", objeto.IdPlataforma);
                    cmd.Parameters.AddWithValue("@START", objeto.Start);
                    cmd.Parameters.AddWithValue("@STOP", objeto.Stop);
                }
                else
                {
                    conexion.AbrirConexion();
                    cmd = new MySqlCommand("PROC_MODIFICAR_APP(@NOMBRE,@PLATAFORMA,@START,@STOP,@ID)", conexion.conexion);
                    cmd.Parameters.AddWithValue("@NOMBRE", objeto.Descripcion);
                    cmd.Parameters.AddWithValue("@PLATAFORMA", objeto.IdPlataforma);
                    cmd.Parameters.AddWithValue("@START", objeto.Start);
                    cmd.Parameters.AddWithValue("@STOP", objeto.Stop);
                    cmd.Parameters.AddWithValue("@ID", id);
                }
                retorno = cmd.ExecuteNonQuery();
                conexion.CerrarConexion();
                return(retorno);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                conexion.CerrarConexion();
                return(0);
            }
        }