コード例 #1
0
        public static bool EliminarFruta(this Cajon <Manzana> cajon, int id)
        {
            bool          seElimino = false;
            SqlConnection conexion  = new SqlConnection(Properties.Settings.Default.Conexion);
            SqlCommand    comando   = new SqlCommand();

            try
            {
                conexion.Open();
                comando.Connection  = conexion;
                comando.CommandType = CommandType.Text;
                comando.CommandText = "SELECT * FROM [sp_lab_II].[dbo].[frutas] WHERE id = " + id;

                SqlDataReader lector = comando.ExecuteReader();

                if (lector.Read() != false)
                {
                    lector.Close();
                    comando.CommandText = "DELETE FROM [sp_lab_II].[dbo].[frutas] WHERE id = " + id;
                    comando.ExecuteNonQuery();
                    seElimino = true;
                }
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message);
            }
            finally
            {
                conexion.Close();
            }

            return(seElimino);
        }
コード例 #2
0
        public void manejadoraPrecioTotal(Cajon <Fruta> c)
        {
            string mensaje = DateTime.Now.ToString() + " El total del precio del cajon supera los $55, con un precio de: " + c.PrecioTotal.ToString();

            MessageBox.Show(mensaje);

            StreamWriter sw = new StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\punto5.txt");

            sw.WriteLine(mensaje);

            sw.Close();
        }
コード例 #3
0
 public void Manejador(Cajon <T> cajon)
 {
     try
     {
         StreamWriter sw = new StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\incidentes.log");
         sw.WriteLine("Fecha: " + DateTime.Now.ToString());
         sw.WriteLine("Precio del cajon: " + cajon.PrecioTotal.ToString());
         sw.Close();
     }
     catch (Exception e)
     {
     }
 }
コード例 #4
0
        public static bool EliminarFruta(this Cajon <Manzana> cajon, int id)
        {
            SqlConnection conexion;
            SqlCommand    comando;

            try
            {
                conexion            = new SqlConnection(Properties.Settings.Default.Conexion);
                comando             = new SqlCommand("DELETE FROM frutas WHERE id = " + id);
                comando.CommandType = System.Data.CommandType.Text;
                comando.Connection  = conexion;
                conexion.Open();
                comando.ExecuteNonQuery();
                return(true);
            }
            catch (Exception e)
            {
                throw;
            }
        }
コード例 #5
0
        public static bool EliminarFruta(this Cajon <Manzana> cajon, int id)
        {
            bool retorno = false;
            int  filas;

            using (SqlConnection conexion = new SqlConnection(Properties.Settings.Default.conexion))
            {
                SqlCommand cmd = new SqlCommand();
                conexion.Open();
                cmd.Connection  = conexion;
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = string.Format("DELETE FROM frutas where id={0} ", id);
                filas           = cmd.ExecuteNonQuery();

                if (filas != 0)
                {
                    retorno = true;
                }
            }

            return(retorno);
        }
コード例 #6
0
 public static bool EliminarFruta(this Cajon <Manzana> c, int index)
 {
     return(true);
 }