protected void grillaUsuarios_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridEditableItem && e.Item.IsInEditMode) { if (e.Item.OwnerTableView.IsItemInserted) { var emp = (from c in Contexto.Empresa select new { c.IdEmpresa, c.RazonSocial }).Distinct().ToList().OrderBy(w => w.RazonSocial); (e.Item.FindControl("cboEmpresa") as RadComboBox).DataSource = emp; (e.Item.FindControl("cboEmpresa") as RadComboBox).DataBind(); } } if (e.Item.ItemType == GridItemType.EditFormItem) { if (e.Item.FindControl("cboEmpresa") != null) { if (e.Item.DataItem is SegUsuario) { SegUsuario clasif = (SegUsuario)e.Item.DataItem; var emp = (from c in Contexto.Empresa select new { c.IdEmpresa, c.RazonSocial }).Distinct().ToList().OrderBy(w => w.RazonSocial); (e.Item.FindControl("cboEmpresa") as RadComboBox).DataSource = emp; (e.Item.FindControl("cboEmpresa") as RadComboBox).DataBind(); if (clasif.IdEmpresa != null) { (e.Item.FindControl("cboEmpresa") as RadComboBox).SelectedValue = clasif.IdEmpresa.ToString(); } } } } }
protected void InsertUsuario(GridEditableItem editedItem) { long idPlanilla = Convert.ToInt64(ViewState["idsel"]); #region Recupero los Datos Ingresado por el usuario GridEditManager editMan = editedItem.EditManager; string Login_Ingresado = ((TextBox)editedItem.FindControl("LoginTextBox")).Text; string password_Ingresado = ((TextBox)editedItem.FindControl("PasswordTextBox")).Text; string IdEmpres_Ingresado = ((RadComboBox)editedItem.FindControl("cboEmpresa")).SelectedValue; #endregion try { SegUsuario _ItemUsuario = new SegUsuario(); _ItemUsuario.Login = Login_Ingresado; _ItemUsuario.Password = password_Ingresado; if (IdEmpres_Ingresado.Trim() != "") { _ItemUsuario.IdEmpresa = long.Parse(IdEmpres_Ingresado); } Contexto.AddToSegUsuario(_ItemUsuario); Contexto.SaveChanges(); this.grillaUsuarios.Rebind(); } catch (Exception e) { ScriptManager.RegisterStartupScript(UpdPnlGrilla, typeof(UpdatePanel), "Error Grabacion", "alert(" + e.Message + ")", true); } }
protected void DeleteUsuario() { long idUsuario = Convert.ToInt64(ViewState["idsel"]); SegUsuario _ItemUsuario = (from c in Contexto.SegUsuario where c.IdSegUsuario == idUsuario select c).FirstOrDefault(); if (_ItemUsuario != null) { try { List <SegUsuarioRol> roles = _ItemUsuario.SegUsuarioRol.ToList(); foreach (var item in roles) { Contexto.DeleteObject(item); } Contexto.DeleteObject(_ItemUsuario); Contexto.SaveChanges(); this.grillaUsuarios.Rebind(); } catch (Exception e) { ScriptManager.RegisterStartupScript(UpdPnlGrilla, typeof(UpdatePanel), "Error Grabacion", "alert(" + e.Message + ")", true); } } }
public async Task <CobGeneralCobranza> InsertGeneralCobranza(CobGeneralCobranza generalCobranza) { SegUsuario user = await _unitOfWork.SegUsuarioRepository.GetUser(generalCobranza.UsuarioRegistro); if (user == null) { throw new Exception("usuario no existe"); } CobGeneralCobranza existenDocumentosPendientes = await _unitOfWork.GeneralCobranzaRepository.ExisteCobranzaPendienteEnviar(generalCobranza); if (existenDocumentosPendientes != null) { throw new BusinessException("Este cliente ya tiene un RC abierto pendiente por enviar N° " + existenDocumentosPendientes.Documento.ToString() + ".Agregue la cobranza a este RC.Si es necesario grabar otro RC a este cliente, envíe el que está pendiente a la administradora."); } MtrCliente cliente = await _mtrClienteService.GetByIdAsync(generalCobranza.IdCliente); MtrVendedor vendedor = await _mtrVendedorService.GetByIdAsync(cliente.Vendedor1); string vIn = cliente.OficinaVenta; short vOut = Convert.ToInt16(vIn); MtrOficina mtrOficina = await _mtrOficinaService.GetOficina(vOut); generalCobranza.SearchText = generalCobranza.IdCliente + "-" + cliente.Nombre + "-" + vendedor.Nombre + "-" + generalCobranza.Documento.ToString() + "-" + mtrOficina.NomOficina.Trim(); generalCobranza.OficinaVenta = cliente.OficinaVenta; await _unitOfWork.GeneralCobranzaRepository.Add(generalCobranza); await _unitOfWork.SaveChangesAsync(); CobGeneralCobranza result = await UpdateGeneralCobranza(generalCobranza); return(result); }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { if (this.CboRoles.SelectedValue != null && this.GridView1.SelectedValue != null) { ConosudDataContext dc = new ConosudDataContext(); if ((from ur in dc.SegUsuarioRols where ur.Rol == long.Parse(this.CboRoles.SelectedValue) && ur.Usuario == long.Parse(this.GridView1.SelectedValue.ToString()) select ur).Count() == 0) { SegRol rol = (from u in dc.SegRols where u.IdSegRol == long.Parse(this.CboRoles.SelectedValue) select u).First(); SegUsuario usu = (from u in dc.SegUsuarios where u.IdSegUsuario == long.Parse(this.GridView1.SelectedValue.ToString()) select u).First(); SegUsuarioRol ConfRol = new SegUsuarioRol(); ConfRol.ObjSegRol = rol; ConfRol.ObjSegUsuario = usu; dc.SegUsuarioRols.InsertOnSubmit(ConfRol); dc.SubmitChanges(); this.GridView2.DataBind(); } else { string alert = "alert('Ya existe este rol para este usuario');"; System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "click", alert, true); } } }
public void PutUsuarioData(UsuarioModel usuario) { SegUsuario SegUser = (from su in entity.SegUsuario where su.IdUsuario == usuario.IdUsuario select su).FirstOrDefault(); SegUser.UsuarioModificacion = usuario.UsuarioModificacion; SegUser.FechaModificacion = Convert.ToDateTime(usuario.FechaModificacion); if (usuario.Estado == "A") { SegUser.Estado = true; } else if (usuario.Estado == "D") { SegUser.Estado = false; } USUARIO user = (from u in entity.USUARIO where u.USUARIO1 == SegUser.Usuario select u).FirstOrDefault(); user.CONTRASENIA = usuario.Contraseña; user.ESTADO = usuario.Estado; entity.SaveChanges(); }
public async Task <Metadata> ValidaInsertCobranza(CobGeneralCobranza generalCobranza) { Metadata metadata = new Metadata(); SegUsuario user = await _unitOfWork.SegUsuarioRepository.GetUser(generalCobranza.UsuarioRegistro); if (user == null) { metadata.IsValid = false; metadata.Message = "usuario no existe"; } CobGeneralCobranza existenDocumentosPendientes = await _unitOfWork.GeneralCobranzaRepository.ExisteCobranzaPendienteEnviar(generalCobranza); if (existenDocumentosPendientes != null) { //throw new BusinessException("Este cliente ya tiene un RC abierto pendiente por enviar N° " + existenDocumentosPendientes.Documento.ToString() + ".Agregue la cobranza a este RC.Si es necesario grabar otro RC a este cliente, envíe el que está pendiente a la administradora."); metadata.IsValid = false; metadata.Message = "Este cliente ya tiene un RC abierto pendiente por enviar N° " + existenDocumentosPendientes.Documento.ToString() + ".Agregue la cobranza a este RC.Si es necesario grabar otro RC a este cliente, envíe el que está pendiente a la administradora."; } else { metadata.IsValid = true; metadata.Message = ""; } return(metadata); }
private bool createSegUsuario(UsuarioModel usuario) { try { SegUsuario user = new SegUsuario() { Usuario = usuario.Usuario, NombreUsuario = usuario.NombreUsuario, FechaCreacion = Convert.ToDateTime(usuario.FechaCreacion), UsuarioCreacion = usuario.UsuarioCreacion, FechaModificacion = Convert.ToDateTime(usuario.FechaModificacion), UsuarioModificacion = usuario.UsuarioModificacion, Estado = true }; entity.SegUsuario.Add(user); entity.SaveChanges(); return(true); } catch (Exception e) { Console.WriteLine(e); return(false); } }
public void DeleteUsuarioData(int Id) { SegUsuario SegUser = (from su in entity.SegUsuario where su.IdUsuario == Id select su).FirstOrDefault(); USUARIO user = (from u in entity.USUARIO where u.USUARIO1 == SegUser.Usuario select u).FirstOrDefault(); entity.USUARIO.Remove(user); entity.SegUsuario.Remove(SegUser); entity.SaveChanges(); }
public ActionResult About() { var context = new ItauEntities(); var newUsuario = new SegUsuario(); newUsuario.Nombre = "test"; newUsuario.Password = "******"; context.SegUsuarios.Add(newUsuario); context.SaveChanges(); ViewBag.Message = "Your application description page."; return(View()); }
public ActionResult Contact(SegUsuario usuario) { ViewBag.Message = "Your contact page."; return(View()); }
public string insertarCliente(SegUsuario cliente) { throw new NotImplementedException(); }