SlideShare a Scribd company logo
**visual

Imports System.Data
Imports System.Data.SqlClient

Public Class Form1



    Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label2.Click

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
        Dim conexion As New SqlConnection("Data Source=MIRIAM-
HPSQLEXPRESS;Initial Catalog=bd_pelicula;Integrated Security=True")
        Dim comando As New SqlCommand()
        comando.Connection = conexion
        comando.CommandType = CommandType.StoredProcedure
        comando.CommandText = "calcular"
        comando.Parameters.Clear()

        Dim pel As Integer = CInt(TextBox1.Text)
        Dim ren As Integer = CInt(TextBox2.Text)
        Dim fecha As Date = DateTimePicker1.Value

        comando.Parameters.AddWithValue("@idrenta", ren)
        comando.Parameters.AddWithValue("@idpeli", pel)
        comando.Parameters.AddWithValue("@fechareal", fecha)

        conexion.Open()

        TextBox3.Text = comando.ExecuteScalar().ToString()
        conexion.Close()




    End Sub
End Class

**procedimiento

USE [bd_pelicula]
GO
/****** Object: StoredProcedure [dbo].[calcular]     Script Date: 12/03/2012
13:07:55 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:        <Author,,Name>
-- Create date: <Create Date,,>
-- Description:   <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[calcular]
-- Add the parameters for the stored procedure here
        @idrenta as int,
        @idpeli as int,
        @fechareal as datetime


AS
BEGIN
        -- SET NOCOUNT ON added to prevent extra result sets from
        -- interfering with SELECT statements.


        SET NOCOUNT ON;

declare @precio as money
select @precio = penalizacion from pelicula where id_pelicula = @idpeli
update pelicula set no_copias = no_copias+1 where id_pelicula= @idpeli

update Renta_detalle set fecha_real = @fechareal where id_pelicula = @idpeli and
id_renta = @idrenta

declare @diffecha as int
select @diffecha = datediff(DD, fecha_devolucion, @fechareal)from Renta_detalle
where id_renta = @idrenta

 update Renta_detalle set dias_penalizacion = @diffecha where id_pelicula =
@idpeli and id_renta = @idrenta

  update Renta_detalle set costo_penalizacion = @precio * @diffecha where
id_pelicula = @idpeli and id_renta = @idrenta

--hay que regresar un dato del procedimieto
select @precio * @diffecha as 'total'


END

**

More Related Content

What's hot

FMDB - SLC-Cocoaheads
FMDB - SLC-CocoaheadsFMDB - SLC-Cocoaheads
FMDB - SLC-Cocoaheads
Dave Stevenson
 
Database Development Replication Security Maintenance Report
Database Development Replication Security Maintenance ReportDatabase Development Replication Security Maintenance Report
Database Development Replication Security Maintenance Reportnyin27
 
Scala on Your Phone
Scala on Your PhoneScala on Your Phone
Scala on Your Phone
Michael Galpin
 
Redux Sagas - React Alicante
Redux Sagas - React AlicanteRedux Sagas - React Alicante
Redux Sagas - React Alicante
Ignacio Martín
 
2018 02-22 React, Redux & Building Applications that Scale | Redux
2018 02-22 React, Redux & Building Applications that Scale | Redux2018 02-22 React, Redux & Building Applications that Scale | Redux
2018 02-22 React, Redux & Building Applications that Scale | Redux
Codifly
 
Pymongo for the Clueless
Pymongo for the CluelessPymongo for the Clueless
Pymongo for the Clueless
Chee Leong Chow
 
Inventory aging report using oracle discoverer desktop
Inventory aging report using oracle discoverer desktopInventory aging report using oracle discoverer desktop
Inventory aging report using oracle discoverer desktop
Ahmed Elshayeb
 
Auto-GWT : Better GWT Programming with Xtend
Auto-GWT : Better GWT Programming with XtendAuto-GWT : Better GWT Programming with Xtend
Auto-GWT : Better GWT Programming with Xtend
Sven Efftinge
 
Git training cheat sheet
Git training cheat sheetGit training cheat sheet
Git training cheat sheet
Skander Hamza
 
Mozilla とブラウザゲーム
Mozilla とブラウザゲームMozilla とブラウザゲーム
Mozilla とブラウザゲーム
Noritada Shimizu
 
Gwt and Xtend
Gwt and XtendGwt and Xtend
Gwt and Xtend
Sven Efftinge
 
VISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEVISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEDarwin Durand
 
Rxjs ngvikings
Rxjs ngvikingsRxjs ngvikings
Rxjs ngvikings
Christoffer Noring
 
Seven deadly smells of Automated Tests
Seven deadly smells of Automated TestsSeven deadly smells of Automated Tests
Seven deadly smells of Automated Tests
owennell
 
Process monitoring in UNIX shell scripting
Process monitoring in UNIX shell scriptingProcess monitoring in UNIX shell scripting
Process monitoring in UNIX shell scripting
Dan Morrill
 
6. CodeIgniter copy2
6. CodeIgniter copy26. CodeIgniter copy2
6. CodeIgniter copy2
Razvan Raducanu, PhD
 
Oop assignment 02
Oop assignment 02Oop assignment 02
Oop assignment 02
MamoonKhan39
 

What's hot (20)

FMDB - SLC-Cocoaheads
FMDB - SLC-CocoaheadsFMDB - SLC-Cocoaheads
FMDB - SLC-Cocoaheads
 
Database Development Replication Security Maintenance Report
Database Development Replication Security Maintenance ReportDatabase Development Replication Security Maintenance Report
Database Development Replication Security Maintenance Report
 
Scala on Your Phone
Scala on Your PhoneScala on Your Phone
Scala on Your Phone
 
Redux Sagas - React Alicante
Redux Sagas - React AlicanteRedux Sagas - React Alicante
Redux Sagas - React Alicante
 
2018 02-22 React, Redux & Building Applications that Scale | Redux
2018 02-22 React, Redux & Building Applications that Scale | Redux2018 02-22 React, Redux & Building Applications that Scale | Redux
2018 02-22 React, Redux & Building Applications that Scale | Redux
 
Pymongo for the Clueless
Pymongo for the CluelessPymongo for the Clueless
Pymongo for the Clueless
 
Procedures
ProceduresProcedures
Procedures
 
Inventory aging report using oracle discoverer desktop
Inventory aging report using oracle discoverer desktopInventory aging report using oracle discoverer desktop
Inventory aging report using oracle discoverer desktop
 
Auto-GWT : Better GWT Programming with Xtend
Auto-GWT : Better GWT Programming with XtendAuto-GWT : Better GWT Programming with Xtend
Auto-GWT : Better GWT Programming with Xtend
 
Git training cheat sheet
Git training cheat sheetGit training cheat sheet
Git training cheat sheet
 
Mozilla とブラウザゲーム
Mozilla とブラウザゲームMozilla とブラウザゲーム
Mozilla とブラウザゲーム
 
Gwt and Xtend
Gwt and XtendGwt and Xtend
Gwt and Xtend
 
VISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEVISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLE
 
Rxjs ngvikings
Rxjs ngvikingsRxjs ngvikings
Rxjs ngvikings
 
Final_Project
Final_ProjectFinal_Project
Final_Project
 
Seven deadly smells of Automated Tests
Seven deadly smells of Automated TestsSeven deadly smells of Automated Tests
Seven deadly smells of Automated Tests
 
Process monitoring in UNIX shell scripting
Process monitoring in UNIX shell scriptingProcess monitoring in UNIX shell scripting
Process monitoring in UNIX shell scripting
 
6. CodeIgniter copy2
6. CodeIgniter copy26. CodeIgniter copy2
6. CodeIgniter copy2
 
Oop assignment 02
Oop assignment 02Oop assignment 02
Oop assignment 02
 
Functions
FunctionsFunctions
Functions
 

Viewers also liked

8
88
3
33
Case Solution for Elkay Plumbing Products Division
Case Solution for Elkay Plumbing Products DivisionCase Solution for Elkay Plumbing Products Division
Case Solution for Elkay Plumbing Products Division
casesolutions
 
Sd refrigeration
Sd refrigerationSd refrigeration
Sd refrigeration
SD REFRIGERATION
 
Andrea Monge-GCSRD Poster
Andrea Monge-GCSRD PosterAndrea Monge-GCSRD Poster
Andrea Monge-GCSRD PosterAndrea Monge
 
הצעה לאולמות אירועים
הצעה לאולמות אירועיםהצעה לאולמות אירועים
הצעה לאולמות אירועים
החוש השביעי
 
Animacion
AnimacionAnimacion
Animacion
Daniela Lopez
 
Infographic Home Insurance Markets
Infographic Home Insurance MarketsInfographic Home Insurance Markets
Infographic Home Insurance Markets
Melissa Anne Wisniewski, AIAM
 
Value Based Resume Training-Silver Level
Value Based Resume Training-Silver LevelValue Based Resume Training-Silver Level
Value Based Resume Training-Silver LevelDavia Woulard
 
Jaulia Letter of Reference2003
Jaulia Letter of Reference2003Jaulia Letter of Reference2003
Jaulia Letter of Reference2003Janet Johnson
 
Acta de constitución
Acta de constituciónActa de constitución
Acta de constitución
jhonny chile
 
The Week.March9.2014.Vandana Kohli
The Week.March9.2014.Vandana KohliThe Week.March9.2014.Vandana Kohli
The Week.March9.2014.Vandana KohliGauurikaa films
 

Viewers also liked (15)

8
88
8
 
3
33
3
 
Case Solution for Elkay Plumbing Products Division
Case Solution for Elkay Plumbing Products DivisionCase Solution for Elkay Plumbing Products Division
Case Solution for Elkay Plumbing Products Division
 
Sd refrigeration
Sd refrigerationSd refrigeration
Sd refrigeration
 
slide1.rtf
slide1.rtfslide1.rtf
slide1.rtf
 
Andrea Monge-GCSRD Poster
Andrea Monge-GCSRD PosterAndrea Monge-GCSRD Poster
Andrea Monge-GCSRD Poster
 
הצעה לאולמות אירועים
הצעה לאולמות אירועיםהצעה לאולמות אירועים
הצעה לאולמות אירועים
 
Animacion
AnimacionAnimacion
Animacion
 
Infographic Home Insurance Markets
Infographic Home Insurance MarketsInfographic Home Insurance Markets
Infographic Home Insurance Markets
 
fifth sem mrksht
fifth sem mrkshtfifth sem mrksht
fifth sem mrksht
 
Value Based Resume Training-Silver Level
Value Based Resume Training-Silver LevelValue Based Resume Training-Silver Level
Value Based Resume Training-Silver Level
 
Jaulia Letter of Reference2003
Jaulia Letter of Reference2003Jaulia Letter of Reference2003
Jaulia Letter of Reference2003
 
Acta de constitución
Acta de constituciónActa de constitución
Acta de constitución
 
entypoA5 D-O-7 - Αντίγραφο
entypoA5 D-O-7 - ΑντίγραφοentypoA5 D-O-7 - Αντίγραφο
entypoA5 D-O-7 - Αντίγραφο
 
The Week.March9.2014.Vandana Kohli
The Week.March9.2014.Vandana KohliThe Week.March9.2014.Vandana Kohli
The Week.March9.2014.Vandana Kohli
 

Similar to Uni2

Form demoinplaywithmysql
Form demoinplaywithmysqlForm demoinplaywithmysql
Form demoinplaywithmysql
Knoldus Inc.
 
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISEWINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
Hitesh Mohapatra
 
SQLite in Adobe AIR
SQLite in Adobe AIRSQLite in Adobe AIR
SQLite in Adobe AIRPeter Elst
 
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVERINSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
Darwin Durand
 
PHP tips by a MYSQL DBA
PHP tips by a MYSQL DBAPHP tips by a MYSQL DBA
PHP tips by a MYSQL DBA
Amit Kumar Singh
 
Powershell Tech Ed2009
Powershell Tech Ed2009Powershell Tech Ed2009
Powershell Tech Ed2009rsnarayanan
 
Nko workshop - node js crud & deploy
Nko workshop - node js crud & deployNko workshop - node js crud & deploy
Nko workshop - node js crud & deploySimon Su
 
Symfony2 from the Trenches
Symfony2 from the TrenchesSymfony2 from the Trenches
Symfony2 from the Trenches
Jonathan Wage
 
Dat402
Dat402Dat402
Dat402
ssa2010
 
Advanced dot net
Advanced dot netAdvanced dot net
Advanced dot net
ssa2010
 
Yves & Zed @ Developer Conference 2013
Yves & Zed @ Developer Conference 2013Yves & Zed @ Developer Conference 2013
Yves & Zed @ Developer Conference 2013
FabianWesnerBerlin
 
Oracle - Program with PL/SQL - Lession 17
Oracle - Program with PL/SQL - Lession 17Oracle - Program with PL/SQL - Lession 17
Oracle - Program with PL/SQL - Lession 17
Thuan Nguyen
 
Sql server-function
Sql server-functionSql server-function
Sql server-function
AnkushAgrawal56
 
Polymer - pleasant client-side programming with web components
Polymer - pleasant client-side programming with web componentsPolymer - pleasant client-side programming with web components
Polymer - pleasant client-side programming with web components
psstoev
 
DN 2017 | Reducing pain in data engineering | Martin Loetzsch | Project A
DN 2017 | Reducing pain in data engineering | Martin Loetzsch | Project ADN 2017 | Reducing pain in data engineering | Martin Loetzsch | Project A
DN 2017 | Reducing pain in data engineering | Martin Loetzsch | Project A
Dataconomy Media
 
Codigos
CodigosCodigos
Codigos
Brian Joseff
 
Oracle 12c Automatic Data Optimization (ADO) - ILM
Oracle 12c Automatic Data Optimization (ADO) - ILMOracle 12c Automatic Data Optimization (ADO) - ILM
Oracle 12c Automatic Data Optimization (ADO) - ILM
Monowar Mukul
 
Salesforce, APEX Concepts
Salesforce, APEX ConceptsSalesforce, APEX Concepts
Salesforce, APEX ConceptsGaurish Goel
 
Kevin Bengtson Portfolio
Kevin Bengtson PortfolioKevin Bengtson Portfolio
Kevin Bengtson PortfolioKbengt521
 
Your Second iPhone App - Code Listings
Your Second iPhone App - Code ListingsYour Second iPhone App - Code Listings
Your Second iPhone App - Code Listings
Vu Tran Lam
 

Similar to Uni2 (20)

Form demoinplaywithmysql
Form demoinplaywithmysqlForm demoinplaywithmysql
Form demoinplaywithmysql
 
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISEWINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
 
SQLite in Adobe AIR
SQLite in Adobe AIRSQLite in Adobe AIR
SQLite in Adobe AIR
 
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVERINSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
 
PHP tips by a MYSQL DBA
PHP tips by a MYSQL DBAPHP tips by a MYSQL DBA
PHP tips by a MYSQL DBA
 
Powershell Tech Ed2009
Powershell Tech Ed2009Powershell Tech Ed2009
Powershell Tech Ed2009
 
Nko workshop - node js crud & deploy
Nko workshop - node js crud & deployNko workshop - node js crud & deploy
Nko workshop - node js crud & deploy
 
Symfony2 from the Trenches
Symfony2 from the TrenchesSymfony2 from the Trenches
Symfony2 from the Trenches
 
Dat402
Dat402Dat402
Dat402
 
Advanced dot net
Advanced dot netAdvanced dot net
Advanced dot net
 
Yves & Zed @ Developer Conference 2013
Yves & Zed @ Developer Conference 2013Yves & Zed @ Developer Conference 2013
Yves & Zed @ Developer Conference 2013
 
Oracle - Program with PL/SQL - Lession 17
Oracle - Program with PL/SQL - Lession 17Oracle - Program with PL/SQL - Lession 17
Oracle - Program with PL/SQL - Lession 17
 
Sql server-function
Sql server-functionSql server-function
Sql server-function
 
Polymer - pleasant client-side programming with web components
Polymer - pleasant client-side programming with web componentsPolymer - pleasant client-side programming with web components
Polymer - pleasant client-side programming with web components
 
DN 2017 | Reducing pain in data engineering | Martin Loetzsch | Project A
DN 2017 | Reducing pain in data engineering | Martin Loetzsch | Project ADN 2017 | Reducing pain in data engineering | Martin Loetzsch | Project A
DN 2017 | Reducing pain in data engineering | Martin Loetzsch | Project A
 
Codigos
CodigosCodigos
Codigos
 
Oracle 12c Automatic Data Optimization (ADO) - ILM
Oracle 12c Automatic Data Optimization (ADO) - ILMOracle 12c Automatic Data Optimization (ADO) - ILM
Oracle 12c Automatic Data Optimization (ADO) - ILM
 
Salesforce, APEX Concepts
Salesforce, APEX ConceptsSalesforce, APEX Concepts
Salesforce, APEX Concepts
 
Kevin Bengtson Portfolio
Kevin Bengtson PortfolioKevin Bengtson Portfolio
Kevin Bengtson Portfolio
 
Your Second iPhone App - Code Listings
Your Second iPhone App - Code ListingsYour Second iPhone App - Code Listings
Your Second iPhone App - Code Listings
 

Uni2

  • 1. **visual Imports System.Data Imports System.Data.SqlClient Public Class Form1 Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim conexion As New SqlConnection("Data Source=MIRIAM- HPSQLEXPRESS;Initial Catalog=bd_pelicula;Integrated Security=True") Dim comando As New SqlCommand() comando.Connection = conexion comando.CommandType = CommandType.StoredProcedure comando.CommandText = "calcular" comando.Parameters.Clear() Dim pel As Integer = CInt(TextBox1.Text) Dim ren As Integer = CInt(TextBox2.Text) Dim fecha As Date = DateTimePicker1.Value comando.Parameters.AddWithValue("@idrenta", ren) comando.Parameters.AddWithValue("@idpeli", pel) comando.Parameters.AddWithValue("@fechareal", fecha) conexion.Open() TextBox3.Text = comando.ExecuteScalar().ToString() conexion.Close() End Sub End Class **procedimiento USE [bd_pelicula] GO /****** Object: StoredProcedure [dbo].[calcular] Script Date: 12/03/2012 13:07:55 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <Description,,> -- ============================================= ALTER PROCEDURE [dbo].[calcular]
  • 2. -- Add the parameters for the stored procedure here @idrenta as int, @idpeli as int, @fechareal as datetime AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; declare @precio as money select @precio = penalizacion from pelicula where id_pelicula = @idpeli update pelicula set no_copias = no_copias+1 where id_pelicula= @idpeli update Renta_detalle set fecha_real = @fechareal where id_pelicula = @idpeli and id_renta = @idrenta declare @diffecha as int select @diffecha = datediff(DD, fecha_devolucion, @fechareal)from Renta_detalle where id_renta = @idrenta update Renta_detalle set dias_penalizacion = @diffecha where id_pelicula = @idpeli and id_renta = @idrenta update Renta_detalle set costo_penalizacion = @precio * @diffecha where id_pelicula = @idpeli and id_renta = @idrenta --hay que regresar un dato del procedimieto select @precio * @diffecha as 'total' END **