/// <summary> /// Agrega una instancia de bonds_types /// </summary> /// <param name="entidad"></param> /// <returns></returns> public string Agregar(bons_automatic_types entidad) { try { string mess = ""; if (Exist(entidad.NameBonds)) { mess = "Ya existe un estatus llamado: " + entidad.NameBonds; } else { bons_automatic_types bono = new bons_automatic_types { NameBonds = entidad.NameBonds, Created = DateTime.Now, Create_by = entidad.Create_by.ToUpper(), Enabled = true, }; SICOEMEntities sicoem = new SICOEMEntities(); sicoem.bons_automatic_types.Add(bono); sicoem.SaveChanges(); } return(mess); } catch (DbEntityValidationException ex) { var errorMessages = ex.EntityValidationErrors .SelectMany(x => x.ValidationErrors) .Select(x => x.ErrorMessage); var fullErrorMessage = string.Join("; ", errorMessages); return(fullErrorMessage.ToString()); } }
private string Editar(bons_automatic_types id_bond_type) { TipoBonosAutomaticosCOM bono = new TipoBonosAutomaticosCOM(); string vmensaje = bono.Editar(id_bond_type); return(vmensaje); }
private bons_automatic_types Gettipobonos(int id_bond_type) { bons_automatic_types dt = new bons_automatic_types(); try { TipoBonosAutomaticosCOM getbt = new TipoBonosAutomaticosCOM(); dt = getbt.bono(id_bond_type); } catch (Exception) { dt = null; } return(dt); }
/// <summary> /// Devuelve una instancia de la clase riesgos_estatus /// </summary> /// <param name="idbonds"></param> /// <returns></returns> public bons_automatic_types bono(int id_bond_type) { try { SICOEMEntities sicoem = new SICOEMEntities(); bons_automatic_types bono = sicoem.bons_automatic_types .First(i => i.IdBonds == id_bond_type); return(bono); } catch (DbEntityValidationException ex) { var errorMessages = ex.EntityValidationErrors .SelectMany(x => x.ValidationErrors) .Select(x => x.ErrorMessage); var fullErrorMessage = string.Join("; ", errorMessages); return(null); } }
protected void lnkguardar_Click(object sender, EventArgs e) { try { string vmensaje = string.Empty; int id_bond_type = Convert.ToInt32(hdfid_bond_type.Value == "" ? "0" : hdfid_bond_type.Value); bons_automatic_types bono = new bons_automatic_types(); if (id_bond_type > 0) { bono.IdBonds = id_bond_type; } bono.NameBonds = txtbono.Text; bono.Create_by = Session["usuario"] as string; bono.Created = DateTime.Now; if (bono.NameBonds == "") { ModalShow("#ModalTipoBonos"); Toast.Error("Error al procesar bono : Ingrese un titulo", this); } else { vmensaje = id_bond_type > 0 ? Editar(bono) : Agregar(bono); if (vmensaje == "") { txtbono.Text = ""; hdfid_bond_type.Value = ""; CargarCatalogo(); Toast.Success("Estatus agregado correctamente.", "Mensaje del sistema", this); } else { ModalShow("#ModalTipoBonos"); Toast.Error("Error al procesar estatus : " + vmensaje, this); } } } catch (Exception ex) { ModalShow("#ModalTipoBonos"); Toast.Error("Error al procesar estatus : " + ex.Message, this); } }
protected void btneventgrid_Click(object sender, EventArgs e) { try { int id_bond_type = Convert.ToInt32(hdfid_bond_type.Value == "" ? "0" : hdfid_bond_type.Value); if (id_bond_type > 0) { bons_automatic_types bono = Gettipobonos(id_bond_type); if (bono != null) { txtbono.Text = bono.NameBonds; ModalShow("#ModalTipoBonos"); } } } catch (Exception ex) { Toast.Error("Error al cargar bono : " + ex.Message, this); } }
/// <summary> /// Elimina una instancia de riesgos_estatus /// </summary> /// <param name="entidad"></param> /// <returns></returns> public string Eliminar(int id_bond_type) { try { SICOEMEntities sicoem = new SICOEMEntities(); bons_automatic_types bono = sicoem.bons_automatic_types .First(i => i.IdBonds == id_bond_type); bono.Enabled = false; sicoem.SaveChanges(); return(""); } catch (DbEntityValidationException ex) { var errorMessages = ex.EntityValidationErrors .SelectMany(x => x.ValidationErrors) .Select(x => x.ErrorMessage); var fullErrorMessage = string.Join("; ", errorMessages); return(fullErrorMessage.ToString()); } }
/// <summary> /// Edita una instancia de proyectos estatus /// </summary> /// <param name="entidad"></param> /// <returns></returns> public string Editar(bons_automatic_types entidad) { try { SICOEMEntities sicoem = new SICOEMEntities(); bons_automatic_types bono = sicoem.bons_automatic_types .First(i => i.IdBonds == entidad.IdBonds); bono.NameBonds = entidad.NameBonds; sicoem.SaveChanges(); return(""); } catch (DbEntityValidationException ex) { var errorMessages = ex.EntityValidationErrors .SelectMany(x => x.ValidationErrors) .Select(x => x.ErrorMessage); var fullErrorMessage = string.Join("; ", errorMessages); return(fullErrorMessage.ToString()); } }
protected void btneliminar_Click(object sender, EventArgs e) { try { int id_bond_type = Convert.ToInt32(hdfid_bond_type.Value == "" ? "0" : hdfid_bond_type.Value); bons_automatic_types bono = new bons_automatic_types(); bono.IdBonds = id_bond_type; string vmensaje = Eliminar(id_bond_type); if (vmensaje == "") { CargarCatalogo(); Toast.Success("Bono eliminado correctamente.", "Mensaje del sistema", this); } else { Toast.Error("Error al eliminar bono: " + vmensaje, this); } } catch (Exception ex) { Toast.Error("Error al eliminar bono: " + ex.Message, this); } }