Skip to content

Commit 314299c

Browse files
author
Shiro2550
committed
todos los mssgBox agrgados
1 parent 6aac7a9 commit 314299c

5 files changed

Lines changed: 47 additions & 15 deletions

File tree

Form1.cs

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Threading.Tasks;
1010
using System.Windows.Forms;
1111

12+
1213
namespace Lab_6
1314
{
1415
public partial class fBiblioteca : Form
@@ -43,6 +44,20 @@ private void btMostrarLibro_Click(object sender, EventArgs e)
4344

4445
private void btEliminarLibro_Click(object sender, EventArgs e)
4546
{
47+
if (dgvLibro.SelectedRows.Count == 0)
48+
{
49+
MessageBox.Show("Seleccione los libros que desea eliminar.");
50+
return;
51+
}
52+
53+
DialogResult confirmResult = MessageBox.Show("¿Está seguro de que desea eliminar los libros seleccionados?",
54+
"Confirmar eliminación",
55+
MessageBoxButtons.YesNo);
56+
if (confirmResult == DialogResult.No)
57+
{
58+
return;
59+
}
60+
4661
string connectionString = "your_connection_string_here";
4762
List<int> idsEliminar = new List<int>();
4863

@@ -52,14 +67,7 @@ private void btEliminarLibro_Click(object sender, EventArgs e)
5267
idsEliminar.Add(id);
5368
}
5469

55-
if (idsEliminar.Count == 0)
56-
{
57-
MessageBox.Show("Seleccione al menos un libro para eliminar.");
58-
return;
59-
}
60-
6170
string ids = string.Join(",", idsEliminar);
62-
6371
string query = $"DELETE FROM Libros WHERE id IN ({ids})";
6472

6573
using (SqlConnection connection = new SqlConnection(connectionString))
@@ -134,10 +142,27 @@ private void btActualizar_Click(object sender, EventArgs e)
134142

135143
private void btAgregarLibro_Click(object sender, EventArgs e)
136144
{
137-
// Datos del nuevo libro (pueden ser recogidos desde un formulario)
138-
string titulo = txtTitulo.Text; // TextBox en tu formulario
139-
string autor = txtAutor.Text;
140-
int cantidadDisponible = Convert.ToInt32(txtCantidadDisponible.Text);
145+
// Mensaje para solicitar datos del nuevo libro
146+
string titulo = Microsoft.VisualBasic.Interaction.InputBox("Ingrese el título del libro:", "Agregar libro");
147+
if (string.IsNullOrEmpty(titulo))
148+
{
149+
MessageBox.Show("Debe ingresar un título.");
150+
return;
151+
}
152+
153+
string autor = Microsoft.VisualBasic.Interaction.InputBox("Ingrese el autor del libro:", "Agregar libro");
154+
if (string.IsNullOrEmpty(autor))
155+
{
156+
MessageBox.Show("Debe ingresar un autor.");
157+
return;
158+
}
159+
160+
string cantidadStr = Microsoft.VisualBasic.Interaction.InputBox("Ingrese la cantidad disponible:", "Agregar libro");
161+
if (!int.TryParse(cantidadStr, out int cantidadDisponible))
162+
{
163+
MessageBox.Show("Debe ingresar una cantidad válida.");
164+
return;
165+
}
141166

142167
string connectionString = "your_connection_string_here";
143168
string query = "INSERT INTO Libros (Titulo, Autor, CantidadDisponible) VALUES (@Titulo, @Autor, @Cantidad)";
@@ -165,14 +190,14 @@ private void btAgregarLibro_Click(object sender, EventArgs e)
165190
}
166191
}
167192

168-
private void dgvLibro_CellContentClick(object sender, DataGridViewCellEventArgs e)
193+
private void fBiblioteca_Load(object sender, EventArgs e)
169194
{
170-
195+
// Aquí podrías cargar la lista de libros al iniciar la aplicación
171196
}
172197

173-
private void fBiblioteca_Load(object sender, EventArgs e)
198+
private void dgvLibro_CellContentClick(object sender, DataGridViewCellEventArgs e)
174199
{
175-
200+
// Evento del DataGridView, si necesitas alguna funcionalidad aquí
176201
}
177202
}
178203
}

Lab#6.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<WarningLevel>4</WarningLevel>
3434
</PropertyGroup>
3535
<ItemGroup>
36+
<Reference Include="Microsoft.VisualBasic" />
3637
<Reference Include="System" />
3738
<Reference Include="System.Core" />
3839
<Reference Include="System.Xml.Linq" />

bin/Debug/Lab#6.exe

14 KB
Binary file not shown.

bin/Debug/Lab#6.exe.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
5+
</startup>
6+
</configuration>

bin/Debug/Lab#6.pdb

35.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)