private void Guardarbutton_Click(object sender, EventArgs e) { bool paso = false; Talleres talleres = new Talleres(); if (Validar(2)) { MessageBox.Show("llenar los campo Marcados"); } GeneralErrorProvider.Clear(); if (TallerIDNumericUpDown.Value == 0) { paso = BLL.TalleresBLL.Guardar(LlenarClase()); } else { paso = BLL.TalleresBLL.Modificar(LlenarClase()); } if (paso) { MessageBox.Show("Guardado", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("No se pudo guardar", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static bool Eliminar(int id) { bool paso = false; Contexto contexto = new Contexto(); try { Talleres taller = contexto.Tallere.Find(id); contexto.Tallere.Remove(taller); if (contexto.SaveChanges() > 0) { paso = true; } contexto.Dispose(); } catch (Exception) { throw; } return(paso); }
private void Guardarbutton_Click_1(object sender, EventArgs e) { bool paso = false; Talleres talleres = Llenaclase(); if (validar(2)) { MessageBox.Show("Favor de Llenar las Casillas"); } else { if (tallerIdNumericUpDown.Value == 0) { paso = BLL.TalleresBLL.Guardar(talleres); } else { paso = BLL.TalleresBLL.Editar(talleres); } Limpiar(); errorProvider.Clear(); if (paso) { MessageBox.Show("Guardado!", "Exitoso", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("No pudo Guardar!", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public async Task <IActionResult> Edit(int id, Talleres talleres) { if (id != talleres.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(talleres); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TalleresExists(talleres.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(talleres)); }
public int Insert(Talleres objTaller) { int done = -1; MySqlConnection conn = Connention.Conn(); try { String cmdStr = "call InsertTaller(@Direccion,@Encargado)"; MySqlCommand cmd = new MySqlCommand(cmdStr, conn); cmd.Parameters.AddWithValue("@Direccion", objTaller.Direccion); cmd.Parameters.AddWithValue("@Encargado", objTaller.Encargado); cmd.ExecuteNonQuery(); done = (int)cmd.LastInsertedId; } catch (MySqlException ex) { Console.WriteLine(ex.ToString()); done = -1; } finally { conn.Close(); conn.Dispose(); } return(done); }
public List <Talleres> Select() { MySqlConnection conn = Connention.Conn(); List <Talleres> lstTalleres = null; try { String cmdStr = "Select * from talleres"; MySqlCommand cmd = new MySqlCommand(cmdStr, conn); MySqlDataReader dr = cmd.ExecuteReader(); lstTalleres = new List <Talleres>(); while (dr.Read()) { Talleres objTaller = new Talleres(); objTaller.No_Taller = int.Parse(dr["no_taller"].ToString()); objTaller.Direccion = dr["direccion"].ToString(); objTaller.Encargado = dr["encargado"].ToString(); lstTalleres.Add(objTaller); } } catch (MySqlException ex) { Console.WriteLine(ex.ToString()); lstTalleres = null; } finally{ conn.Close(); conn.Dispose(); } return(lstTalleres); }
public bool Update(Talleres objTaller) { bool done = false; MySqlConnection conn = Connention.Conn(); try { String cmdStr = "call UpdateTaller(@PDireccion,@PEncargado,@PNo_Taller)"; MySqlCommand cmd = new MySqlCommand(cmdStr, conn); cmd.Parameters.AddWithValue("@PDireccion", objTaller.Direccion); cmd.Parameters.AddWithValue("@PEncargado", objTaller.Encargado); cmd.Parameters.AddWithValue("@PNo_Taller", objTaller.No_Taller); cmd.ExecuteNonQuery(); done = true; } catch (MySqlException ex) { Console.WriteLine(ex.ToString()); done = false; } finally { conn.Close(); conn.Dispose(); } return(done); }
public void UpdateTaller(string Nombre, string Direccion, int idlocalidad, string telefonocontacto, string Encargado, int tipotaller) { using (context = new Entities()) { taller = new Talleres(); var query = (from t in context.Talleres where t.NombreTaller == Nombre && t.Direccion == Direccion select t).ToList(); foreach (var item in query) { item.NombreTaller = Nombre; item.Direccion = Direccion; item.IDLocalidad = idlocalidad; item.TelefonoCotacto = telefonocontacto; item.NombreEncargado = Encargado; item.IdTipoTaller = tipotaller; context.Entry(item).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } } }
public static bool Eliminar(int id) { bool paso = false; Contexto contexto = new Contexto(); try { Talleres taller = contexto.taller.Find(id); if (taller != null) { contexto.Entry(taller).State = EntityState.Deleted; } if (contexto.SaveChanges() > 0) { paso = true; contexto.Dispose(); } } catch (Exception) { throw; } return(paso); }
private void GuardarButton_Click(object sender, EventArgs e) { Repositorio <Talleres> repositorio = new Repositorio <Talleres>(new Contexto()); bool paso = false; int id = (int)TallerId_numericUpDown.Value; Talleres taller = repositorio.Buscar(id); if (Validar()) { MessageBox.Show("Favor Revisar Los Campos", "Validacion", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } taller = LlenaClase(); if (taller != null) { paso = repositorio.Guardar(taller); } else { paso = repositorio.Modificar(taller); } if (paso) { MessageBox.Show("Guardado", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information); NuevoButton.PerformClick(); } else { MessageBox.Show("No Se Pudo Guardar", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Question); } }
private void Guardarbutton_Click(object sender, EventArgs e) { Talleres taller = new Talleres(); taller = LlenaClase(); bool paso = false; if (Validar()) { MessageBox.Show("Favor revisar todos los campos", "Validación", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (IdtnumericUpDown.Value == 0) { paso = BLL.TalleresBLL.Guardar(taller); } else { paso = BLL.TalleresBLL.Modificar(taller); } if (paso) { MessageBox.Show("Guardado", "Exito!!!", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("No se pudo Guardar", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private Talleres LlenarClase() { Talleres taller = new Talleres(); taller.TallerId = Convert.ToInt32(TallerIdnumericUpDown.Value); taller.Nombre = NombretextBox.Text; return(taller); }
private Talleres LlenaClase() { Talleres talleres = new Talleres(); talleres.TalleresID = Convert.ToInt32(TallerIDnumericUpDown.Value); talleres.Nombre = NombretextBox.Text; return(talleres); }
public void BuscarTest() { int id = 4; Talleres taller = new Talleres(); taller = TalleresBLL.Buscar(id); Assert.IsNotNull(taller); }
private Talleres Limpiar() { Talleres taller = new Talleres(); IdnumericUpDown.Value = 0; NombretextBox.Clear(); return(taller); }
public Talleres LlenaClase() { Talleres taller = new Talleres(); taller.TallerId = Convert.ToInt32(IdtnumericUpDown.Value); taller.Nombre = NombretextBox.Text; return(taller); }
private void Buscarbutton_Click(object sender, EventArgs e) { int id = Convert.ToInt32(TallerIDnumericUpDown.Value); Talleres talleres = BLL.TalleresBLL.Buscar(id); if (talleres != null) { NombretextBox.Text = talleres.Nombre; } }
private Talleres Llenaclase() { Talleres talleres = new Talleres(); talleres.TallerId = Convert.ToInt32(tallerIdNumericUpDown.Value); talleres.Nombre = nombreTextBox.Text; return(talleres); }
/// <summary> /// Establece los talleres a los que tiene acceso de acuerdo a la sucursal /// </summary> /// <param name="talleres">Talleres Permitidos</param> public void EstablecerTalleres(List <TallerBO> talleres) { this.Talleres = talleres; List <ListItem> lista = Talleres.Select(x => new ListItem(x.Nombre, x.Id.ToString())).ToList(); this.ddlTaller.Items.Clear(); this.ddlTaller.DataSource = lista; this.ddlTaller.DataBind(); this.ddlTaller.Items.Insert(0, new ListItem("SELECCIONE", "0")); }
public async Task <IActionResult> Create(Talleres talleres) { if (ModelState.IsValid) { _context.Add(talleres); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(talleres)); }
public void ModificarTest() { bool paso; Talleres taller = new Talleres(); taller.TallerId = 4; taller.Nombre = "Taller Los Muchachones"; paso = TalleresBLL.Modificar(taller); Assert.AreEqual(paso, true); }
public static Talleres Buscar(int id) { Talleres talleres = new Talleres(); Contexto contexto = new Contexto(); try { talleres = contexto.talleres.Find(id); contexto.Dispose(); } catch (Exception) { throw; } return(talleres); }
private void BuscarButton_Click(object sender, EventArgs e) { int id = Convert.ToInt32(TallerId_numericUpDown.Value); Repositorio <Talleres> repositorio = new Repositorio <Talleres>(new Contexto()); Talleres taller = repositorio.Buscar(id); if (taller != null) { Nombre_textBox.Text = taller.Nombre; } else { MessageBox.Show("NO SE PUDO ENCONTRAR", "FALLO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
//Programación de los Botones private void BuscarButton_Click(object sender, EventArgs e) { int id = Convert.ToInt32(TallerIdNumericUpDown.Value); Talleres talleres = TalleresBLL.Buscar(id); if (talleres != null) { NombreTextBox.Text = talleres.Nombre; } else { MessageBox.Show("No se encontró", "Falló", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static Talleres Buscar(int id) { Contexto contexto = new Contexto(); Talleres Taller = new Talleres(); try { Taller = contexto.talleres.Find(id); contexto.Dispose(); } catch (Exception) { MessageBox.Show("No encuentran talleres registrados en este ID"); } return(Taller); }
private void EliminarButton_Click(object sender, EventArgs e) { int id = Convert.ToInt32(TallerId_numericUpDown.Value); Repositorio <Talleres> repositorio = new Repositorio <Talleres>(new Contexto()); Talleres taller = repositorio.Buscar(id); if (taller != null) { repositorio.Eliminar(id); MessageBox.Show("Eliminado", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information); NuevoButton.PerformClick(); } else { MessageBox.Show("NO SE PUDO ELIMINAR", "FALLO", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public static bool Guardar(Talleres talleres) { bool paso = false; Contexto contexto = new Contexto(); try { if (contexto.talleres.Add(talleres) != null) { contexto.SaveChanges(); paso = true; } contexto.Dispose(); } catch (Exception) { throw; } return(paso); }
public static bool Editar(Talleres talleres) { bool paso = false; Contexto contexto = new Contexto(); try { contexto.Entry(talleres).State = EntityState.Modified; if (contexto.SaveChanges() > 0) { paso = true; } contexto.Dispose(); } catch (Exception) { throw; } return(paso); }
public static bool Guardar(Talleres Taller) { bool paso = false; Contexto contexto = new Contexto(); try { if (contexto.talleres.Add(Taller) != null) { contexto.SaveChanges(); paso = true; } contexto.Dispose(); } catch (Exception) { MessageBox.Show("Error al guardar"); } return(paso); }
public void InsertarTaller(string Nombre, string Direccion, int idlocalidad, string telefonocontacto, string Encargado, int tipotaller) { using (context = new Entities()) { taller = new Talleres(); taller.NombreTaller = Nombre; taller.Direccion = Direccion; taller.IDLocalidad = idlocalidad; taller.TelefonoCotacto = telefonocontacto; taller.NombreEncargado = Encargado; taller.IdTipoTaller = tipotaller; context.Talleres.Add(taller); context.SaveChanges(); } }