public void modificar(ESala modsala) { try { if (modsala.IdSucursal.Nombre.Length == 0) { throw new ArgumentException("Ingrese un sucursal"); } if (modsala.nombre.Length == 0) { throw new ArgumentException("Ingrse el nombre de la sala"); } if (modsala.Capacidad.Value == 0 | modsala.Capacidad.Value < 0) { throw new ArgumentException("ingrese una cantidad valida"); } DSala datossala = new DSala(); datossala.modificar(modsala); } catch (Exception ex) { throw ex; } }
public void agregarsala(ESala nuevoSala) { try { if (nuevoSala.IdSucursal.Id_Sucursal == 0) { throw new ArgumentException("Ingrese el sucursal"); } if (nuevoSala.nombre.Length == 0) { throw new ArgumentException("Ingrse el nombre de la sala"); } if (nuevoSala.Capacidad.Value == 0 || nuevoSala.Capacidad.Value < 0) { throw new ArgumentException("Ingrese una cantidad valida"); } DSala datossala = new DSala(); datossala.agregar(nuevoSala); } catch (Exception ex) { throw ex; } }
public void eliminar(ESala eliminarsala) { try { DSala datoseliminar = new DSala(); datoseliminar.eliminar(eliminarsala); } catch (Exception ex) { throw ex; } }
private void btnguardar_Click(object sender, EventArgs e) { try { if (modificar) { ESala modsala = new ESala(); modsala.IdSala = Convert.ToInt32(txtnombre.Tag.ToString()); modsala.nombre = txtnombre.Text; modsala.IdSucursal.Id_Sucursal = Convert.ToInt32(cbsucursal.Tag); modsala.Capacidad = Convert.ToInt32(txtcapacidad.Text); modsala.IdSucursal.Nombre = cbsucursal.Text; NSala gestionsala = new NSala(); gestionsala.modificar(modsala); MessageBox.Show("Se modifico correctamente", "Sala", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { ESala newsala = new ESala(); newsala.IdSucursal.Id_Sucursal = Convert.ToInt32(cbsucursal.Tag); newsala.nombre = txtnombre.Text; newsala.Capacidad = Convert.ToInt32(txtcapacidad.Text); newsala.IdSucursal.Nombre = cbsucursal.Text; NSala datossala = new NSala(); datossala.agregarsala(newsala); MessageBox.Show("Se guardo correctamente", "Sala", MessageBoxButtons.OK, MessageBoxIcon.Information); } actualizartabla(); //dgvSala.DataSource = listasala; limpiar(); deshabilitar(); btncancelar.Enabled = false; btneliminar.Enabled = false; btnguardar.Enabled = false; btnmodificar.Enabled = false; btnnuevo.Enabled = true; btnsucursal.Enabled = false; } catch (Exception ex) { MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void eliminar(ESala eliminarsala) { try { SqlConnection conexion = new SqlConnection(Properties.Settings.Default.CadenaConexion); SqlCommand comando = new SqlCommand(); comando.CommandType = CommandType.StoredProcedure; comando.CommandText = "ELIMINAR_SALA"; comando.Parameters.AddWithValue("@Id_sala", eliminarsala.IdSala); comando.Connection = conexion; conexion.Open(); comando.ExecuteNonQuery(); conexion.Close(); } catch (Exception ex) { throw ex; } }
private void btneliminar_Click(object sender, EventArgs e) { try { if (MessageBox.Show("Seguro que deseas eliminar este registro", "Sala", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ESala eliminar = new ESala(); eliminar.IdSala = Convert.ToInt32(txtnombre.Tag); NSala datoseliminar = new NSala(); datoseliminar.eliminar(eliminar); limpiar(); actualizartabla(); //dgvSala.DataSource = listasala; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void agregar(ESala nuevosala) { try{ SqlConnection conexion = new SqlConnection(Properties.Settings.Default.CadenaConexion); SqlCommand comando = new SqlCommand(); comando.CommandType = CommandType.StoredProcedure; comando.CommandText = "INSERTAR_SALA"; comando.Parameters.AddWithValue("@nombre", nuevosala.nombre); comando.Parameters.AddWithValue("@Id_Sucursal", nuevosala.IdSucursal.Id_Sucursal); comando.Parameters.AddWithValue("@Capacidad", nuevosala.Capacidad); comando.Connection = conexion; conexion.Open(); comando.ExecuteNonQuery(); conexion.Close(); } catch (Exception ex) { throw ex; } }
public List <ESala> ObtenerSala() { try { SqlConnection conexion = new SqlConnection(Properties.Settings.Default.CadenaConexion); SqlCommand comando = new SqlCommand(); comando.CommandType = CommandType.StoredProcedure; comando.CommandText = "BUSCAR_SALA"; comando.Connection = conexion; conexion.Open(); SqlDataReader read = comando.ExecuteReader(); List <ESala> listasala = new List <ESala>(); while (read.Read()) { ESala infoSalas = new ESala(); infoSalas.IdSala = read.GetInt32(0); infoSalas.IdSucursal.Id_Sucursal = read.GetInt32(1); if (read.IsDBNull(2)) { infoSalas.nombre = null; } else { infoSalas.nombre = read.GetString(2); } if (read.IsDBNull(3)) { infoSalas.Capacidad = null; } else { infoSalas.Capacidad = read.GetInt32(3); } if (read.IsDBNull(4)) { infoSalas.IdSucursal.Nombre = null; } else { infoSalas.IdSucursal.Nombre = read.GetString(4); } if (read.IsDBNull(5)) { infoSalas.IdSucursal.Ciudad = null; } else { infoSalas.IdSucursal.Ciudad = read.GetString(5); } if (read.IsDBNull(6)) { infoSalas.IdSucursal.Telefono = null; } else { infoSalas.IdSucursal.Telefono = read.GetInt32(6); } if (read.IsDBNull(7)) { infoSalas.IdSucursal.Direccion = null; } else { infoSalas.IdSucursal.Direccion = read.GetString(7); } listasala.Add(infoSalas); } conexion.Close(); read.Close(); return(listasala); } catch (Exception ex) { throw ex; } }