protected void btnAgrega_Click(object sender, EventArgs e) { try { if (Page.IsValid) { if (!string.IsNullOrEmpty(txtSinonimo.Text)) { var objClienteSinonimo = new CLIENTE_SINONIMO(); objClienteSinonimo.NOMBRE = !string.IsNullOrEmpty(txtSinonimo.Text) ? txtSinonimo.Text : string.Empty; _listaClienteSinonimo.Add(objClienteSinonimo); grdSinonimoCliente.DataSource = _listaClienteSinonimo; grdSinonimoCliente.DataBind(); txtSinonimo.Text = string.Empty; } } } catch (Exception ex) { ISException.RegisterExcepcion(ex); panelMensaje.CssClass = "MostrarMensaje"; lblMensaje.Text = ex.Message; return; } }
public int Add(int CLIENTEId, string NOMBRE) { Init(); try { using (LQCEEntities context = new LQCEEntities()) { RepositorioCLIENTE _repositorioCLIENTE = new RepositorioCLIENTE(context); CLIENTE _objCLIENTE = _repositorioCLIENTE.GetById(CLIENTEId); if(Equals(_objCLIENTE,null)) { throw new Exception(String.Concat("No se ha encontrado CLIENTE con Id =",CLIENTEId.ToString())); } CLIENTE_SINONIMO _CLIENTE_SINONIMO = new CLIENTE_SINONIMO(); //properties _CLIENTE_SINONIMO.NOMBRE = NOMBRE; _CLIENTE_SINONIMO.ACTIVO = true; //parents _CLIENTE_SINONIMO.CLIENTE = _objCLIENTE; context.AddObject("CLIENTE_SINONIMO",_CLIENTE_SINONIMO); context.SaveChanges(); return _CLIENTE_SINONIMO.ID; } } catch(Exception ex) { ISException.RegisterExcepcion(ex); Error = ex.Message; throw ex; } }