Example #1
0
 //Actualizar Productos
 public static string ActualizarProduct(string nombre, decimal precio)
 {
     Productos proc = new Productos();
     proc.NombreProducto = nombre;
     proc.PrecioUnit = precio;
     return proc.ActualizarProductos(proc);
 }
Example #2
0
 //Insertra productos
 public static string InsertProductos(string nombreProducto, decimal precioUnit, int categoria)
 {
     Productos proc = new Productos();
     proc.NombreProducto = nombreProducto;
     proc.PrecioUnit = precioUnit;
     proc.CatProducto = categoria;
     return proc.InsertarProductos(proc);
 }
Example #3
0
        //Actualizar Productos
        public string ActualizarProductos(Productos ActProc)
        {
            string mensaje = "";
            SqlConnection conn = new SqlConnection();
            try
            {
                conn.ConnectionString = Conexion.cadenaconexion;
                conn.Open();
                SqlCommand sqlCmd = new SqlCommand();
                sqlCmd.Connection = conn;
                sqlCmd.CommandText = "Actualizar_Productos";
                sqlCmd.CommandType = CommandType.StoredProcedure;
                //Parámetros

                SqlParameter parCod = new SqlParameter();
                parCod.ParameterName = "@codProductos";
                parCod.SqlDbType = SqlDbType.Int;
                parCod.Value = ActProc.CodProducto;
                sqlCmd.Parameters.Add(parCod);

                SqlParameter parNom = new SqlParameter();
                parNom.ParameterName = "@nombre_producto";
                parNom.SqlDbType = SqlDbType.VarChar;
                parNom.Size = 50;
                parNom.Value = ActProc.nombreProducto;
                sqlCmd.Parameters.Add(parNom);

                SqlParameter parPre = new SqlParameter();
                parPre.ParameterName = "@precio_unitVenta";
                parPre.SqlDbType = SqlDbType.Decimal;
                parPre.Precision = 8;
                parPre.Scale = 0;
                parPre.Value = ActProc.PrecioUnit;
                sqlCmd.Parameters.Add(parPre);

                SqlParameter parCat = new SqlParameter();
                parCat.ParameterName = "@descripcionCat";
                parCat.SqlDbType = SqlDbType.Int;
                parCat.Value = ActProc.CatProducto;
                sqlCmd.Parameters.Add(parCat);

                mensaje = sqlCmd.ExecuteNonQuery() == 0 ? "OK" : "No se actualizo";
            }
            catch (Exception exc)
            {

                mensaje += exc.Message;
            }
            finally
            { if (conn.State == ConnectionState.Open) conn.Close(); }
            return mensaje;
            {

            }
        }
Example #4
0
 //Eliminar Productos
 public static string EliminarProductos(int codigo)
 {
     Productos proc = new Productos();
     proc.CodProducto = codigo;
     return proc.EliminarProductos(proc);
 }
Example #5
0
        //Actualizar Productos
        public string ActualizarProductos(Productos ActProc)
        {
            string        mensaje = "";
            SqlConnection conn    = new SqlConnection();

            try
            {
                conn.ConnectionString = Conexion.cadenaconexion;
                conn.Open();
                SqlCommand sqlCmd = new SqlCommand();
                sqlCmd.Connection  = conn;
                sqlCmd.CommandText = "Actualizar_Productos";
                sqlCmd.CommandType = CommandType.StoredProcedure;
                //Parámetros

                SqlParameter parCod = new SqlParameter();
                parCod.ParameterName = "@codProductos";
                parCod.SqlDbType     = SqlDbType.Int;
                parCod.Value         = ActProc.CodProducto;
                sqlCmd.Parameters.Add(parCod);


                SqlParameter parNom = new SqlParameter();
                parNom.ParameterName = "@nombre_producto";
                parNom.SqlDbType     = SqlDbType.VarChar;
                parNom.Size          = 50;
                parNom.Value         = ActProc.nombreProducto;
                sqlCmd.Parameters.Add(parNom);

                SqlParameter parPre = new SqlParameter();
                parPre.ParameterName = "@precio_unitVenta";
                parPre.SqlDbType     = SqlDbType.Decimal;
                parPre.Precision     = 8;
                parPre.Scale         = 0;
                parPre.Value         = ActProc.PrecioUnit;
                sqlCmd.Parameters.Add(parPre);

                SqlParameter parCat = new SqlParameter();
                parCat.ParameterName = "@descripcionCat";
                parCat.SqlDbType     = SqlDbType.Int;
                parCat.Value         = ActProc.CatProducto;
                sqlCmd.Parameters.Add(parCat);


                mensaje = sqlCmd.ExecuteNonQuery() == 0 ? "OK" : "No se actualizo";
            }
            catch (Exception exc)
            {
                mensaje += exc.Message;
            }
            finally
            { if (conn.State == ConnectionState.Open)
              {
                  conn.Close();
              }
            }
            return(mensaje);

            {
            }
        }
Example #6
0
        // insertar datos
        public string InsertarProductos(Productos Proc)
        {
            string mensaje = "";
            SqlConnection con = new SqlConnection();
            try
            {
                con.ConnectionString = Conexion.cadenaconexion;
                con.Open();
                SqlCommand sqlCo = new SqlCommand();
                sqlCo.Connection = con;
                sqlCo.CommandText = "Insertar_Productos";
                sqlCo.CommandType = CommandType.StoredProcedure;

                SqlParameter parNom = new SqlParameter();
                parNom.ParameterName = "@nombre_producto";
                parNom.SqlDbType = SqlDbType.VarChar;
                parNom.Size = 50;
                parNom.Value = Proc.nombreProducto;
                sqlCo.Parameters.Add(parNom);

                SqlParameter parPre = new SqlParameter();
                parPre.ParameterName = "@precio_unitVenta";
                parPre.SqlDbType = SqlDbType.Decimal;
                parPre.Precision = 8;
                parPre.Scale = 0;
                parPre.Value = Proc.precioUnit;
                sqlCo.Parameters.Add(parPre);

                SqlParameter parCat = new SqlParameter();
                parCat.ParameterName = "@codCategoria";
                parCat.SqlDbType = SqlDbType.Int;
                parCat.Value = Proc.catProducto;
                sqlCo.Parameters.Add(parCat);

                mensaje = sqlCo.ExecuteNonQuery() == 0 ? "OK" : "No se pudo guardar";

            }
            catch (Exception Exc)
            {
                mensaje += Exc.Message;
            }
            finally
            { if (con.State == ConnectionState.Open) con.Close(); }
            return mensaje;
        }
Example #7
0
        //Eliminar Productos
        public string EliminarProductos(Productos proc)
        {
            string mensaje = "";
            SqlConnection conn = new SqlConnection();
            try
            {
                conn.ConnectionString = Conexion.cadenaconexion;
                conn.Open();
                SqlCommand sqlCo = new SqlCommand();
                sqlCo.Connection = conn;
                sqlCo.CommandText = "Eliminar_Productos";
                sqlCo.CommandType = CommandType.StoredProcedure;

                SqlParameter parCod = new SqlParameter();
                parCod.ParameterName = "@codProductos";
                parCod.SqlDbType = SqlDbType.Int;
                parCod.Value = proc.CodProducto;
                sqlCo.Parameters.Add(parCod);

                mensaje = sqlCo.ExecuteNonQuery() == 0 ? "OK" : "No se elimino correctamente";
            }
            catch (Exception exc)
            {
                mensaje += exc.Message;
            }
            finally
            { if (conn.State == ConnectionState.Open) conn.Close(); }
            return mensaje;
        }