コード例 #1
0
        //Modificar
        public Boolean ModificarMascotaVeterinario(Mascota masc)
        {
            SqlCommand update;

            masc = new Mascota();
            Boolean modificar = false;

            try
            {
                String comando = "update MASCOTA set edad_mascota=@edad, peso_mascota=@peso, estatura_mascota=@estatura, " +
                                 "raza_mascota=@raza, observacion_mascota=@otros where id_mascota=@codimascota and nombre_mascota=@nombremascot";
                update = new SqlCommand(comando, con);

                update.Parameters.Add("@edad", System.Data.SqlDbType.Int).Value                 = masc.GetEdadMascota();
                update.Parameters.Add("@peso", System.Data.SqlDbType.Float).Value               = masc.GetPesoMascota();
                update.Parameters.Add("@estatura", System.Data.SqlDbType.Float).Value           = masc.GetEstaturaMascota();
                update.Parameters.Add("@raza", System.Data.SqlDbType.VarChar, 30).Value         = masc.GetRazaMascota();
                update.Parameters.Add("@otros", System.Data.SqlDbType.VarChar, 200).Value       = masc.GetObservacionesMascota();
                update.Parameters.Add("@codimascota", System.Data.SqlDbType.Int).Value          = masc.GetIdMascota();
                update.Parameters.Add("@nombremascot", System.Data.SqlDbType.VarChar, 50).Value = masc.GetNombreMascota();

                if (update.ExecuteNonQuery() == 1)
                {
                    modificar = true;
                }
                else
                {
                    modificar = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error al intentar modificar al usuario... " + ex);
            }
            return(modificar);
        }