protected void ddlCargo_SelectedIndexChanged(object sender, EventArgs e) { try { if (!string.IsNullOrEmpty(ddlCargo.SelectedValue)) { int codigo = int.Parse(ddlCargo.SelectedValue); CargoBusiness business = new CargoBusiness(); List <Cargo> lista = business.ConsultarTodos(codigo); gridCargos.DataSource = lista; gridCargos.DataBind(); } else { ConsultarCargo(); } } catch (Exception ex) { lblMensagem.Text = ex.Message; lblMensagem.ForeColor = Color.Red; } }
void CarregarCombos() { try { CargoBusiness buss = new CargoBusiness(); List <CargoDTO> lista = buss.Listar(); cboDepto.ValueMember = nameof(CargoDTO.Id); cboDepto.DisplayMember = nameof(CargoDTO.Nome); cboDepto.DataSource = lista; EstadoBusiness bess = new EstadoBusiness(); List <EstadoDTO> li = bess.Listar(); cboEstado.ValueMember = nameof(EstadoDTO.IdEstado); cboEstado.DisplayMember = nameof(EstadoDTO.Estado); cboEstado.DataSource = li; } catch (Exception) { frmException tela = new frmException(); tela.LoadScreen("Ocorreu um erro.\nConsulte o administrador do sistema."); tela.ShowDialog(); } }
protected void btnCadastro_Click(object sender, EventArgs e) { if (ValidateField()) { try { CargoBusiness business = new CargoBusiness(); Cargo c = new Cargo(); c.Nome = txtNome.Text; c.Salario = decimal.Parse(txtSalario.Text); c.Descricao = txtDescricao.Text; business.Cadastrar(c); lblMensagem.Text = "Cargo " + c.Nome + " cadastrado com sucesso."; lblMensagem.ForeColor = Color.DarkBlue; txtNome.Text = string.Empty; txtSalario.Text = string.Empty; txtDescricao.Text = string.Empty; } catch (Exception ex) { lblMensagem.Text = ex.Message; lblMensagem.ForeColor = Color.Red; } } }
protected void Atualizar() { lblErroNome.Text = string.Empty; lblErroSalario.Text = string.Empty; lblErroDescricao.Text = string.Empty; lblMensagem.Text = string.Empty; if (ValidateField()) { try { CargoBusiness business = new CargoBusiness(); Cargo c = new Cargo(); c.IdCargo = int.Parse(txtCodigo.Text); c.Nome = txtNome.Text; c.Salario = decimal.Parse(txtSalario.Text); c.Descricao = txtDescricao.Text; business.Atualizar(c); lblMensagem.Text = "Cargo " + c.Nome + " atualizado com sucesso."; } catch (Exception ex) { lblMensagem.Text = ex.Message; lblMensagem.ForeColor = Color.Red; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { CargoBusiness business = new CargoBusiness(); int codigo = int.Parse(Request.QueryString["id"]); Cargo c = business.ConsultarPorId(codigo); txtCodigo.Text = c.IdCargo.ToString(); txtNome.Text = c.Nome; txtSalario.Text = c.Salario.ToString(); txtDescricao.Text = c.Descricao.ToString(); business.Atualizar(c); } catch (Exception ex) { lblMensagem.Text = ex.Message; lblMensagem.ForeColor = Color.Red; } } }
public ComisionController() { _comisionBL = new ComisionBusiness(); _cargoBL = new CargoBusiness(); _canalVentaBL = new CanalVentaBusiness(); _campaniaBL = new CampaniaBusiness(); _requisitoBL = new RequisitoBusiness(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int codigo = int.Parse(Request.QueryString["id"]); CargoBusiness business = new CargoBusiness(); Cargo c = business.ConsultarPorId(codigo); txtCodigo.Text = c.IdCargo.ToString(); txtNome.Text = c.Nome; txtDescricao.Text = c.Descricao; } }
private void ConsultarCargo() { try { CargoBusiness business = new CargoBusiness(); List <Cargo> lista = business.ConsultarTodos(); gridCargos.DataSource = lista; gridCargos.DataBind(); } catch (Exception ex) { lblMensagem.Text = ex.Message; lblMensagem.ForeColor = Color.Red; } }
public void AutoCarregar() { try { CargoBusiness buss = new CargoBusiness(); List <CargoDTO> dto = buss.Listar(); dgvDepto.AutoGenerateColumns = false; dgvDepto.DataSource = dto; } catch (Exception) { frmException tela = new frmException(); tela.LoadScreen("Ocorreu um erro.\nConsulte o administrador do sistema."); tela.ShowDialog(); } }
public ActionResult TerminarComRedirect(string IDCargo) { try { Cargo oCargo = CargoBusiness.Consulta.FirstOrDefault(p => p.IDCargo.Equals(IDCargo)); if (oCargo == null) { return(Json(new { resultado = new RetornoJSON() { Erro = "Não foi possível excluir este Cargo." } })); } else { oCargo.DataExclusao = DateTime.Now; oCargo.UsuarioExclusao = "LoginTeste"; CargoBusiness.Alterar(oCargo); TempData["MensagemSucesso"] = "O Cargo'" + oCargo.NomeDoCargo + "' foi excluido com sucesso."; return(Json(new { resultado = new RetornoJSON() { URL = Url.Action("Index", "Cargo", new { id = IDCargo }) } })); } } catch (Exception ex) { if (ex.GetBaseException() == null) { return(Json(new { resultado = new RetornoJSON() { Erro = ex.Message } })); } else { return(Json(new { resultado = new RetornoJSON() { Erro = ex.GetBaseException().Message } })); } } }
private void dgvDepto_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (e.ColumnIndex == 3) { CargoDTO dto = dgvDepto.Rows[e.RowIndex].DataBoundItem as CargoDTO; string msg = "Quer mesmo apagar o registro " + dto.Id + "?" + "\n" + "obs: Ao apagar um departamento, todos os funcionários nele vinculados serão deletados."; frmQuestion tela = new frmQuestion(); tela.LoadScreen(msg); tela.ShowDialog(); bool botaoYes = tela.BotaoYes; if (botaoYes == true) { CargoBusiness buss = new CargoBusiness(); int IdDepto = dto.Id; buss.Remover(IdDepto); string msgm = "Registo removido com sucesso!"; frmMessage message = new frmMessage(); message.LoadScreen(msgm); message.ShowDialog(); CarregarGrid(); } } } catch (Exception ex) { string msg = "Ocorreu um erro: " + ex.Message; frmException tela = new frmException(); tela.LoadScreen(msg); tela.ShowDialog(); } }
private void CarregarCargo() { try { CargoBusiness business = new CargoBusiness(); List <Cargo> lista = business.ConsultarTodos(); ddlCargo.DataSource = lista; ddlCargo.DataTextField = "Nome"; ddlCargo.DataValueField = "IdCargo"; ddlCargo.DataBind(); ddlCargo.Items.Insert(0, new ListItem("- Escolha um Cargo - ", "")); } catch (Exception ex) { lblMensagem.Text = ex.Message; lblMensagem.ForeColor = Color.Red; } }
private void btnCadastrar_Click_1(object sender, EventArgs e) { try { CargoDTO dto = new CargoDTO(); dto.Nome = txtDepto.Text; dto.Descricao = txtDecricao.Text; CargoBusiness buss = new CargoBusiness(); buss.Salvar(dto); frmMessage tela = new frmMessage(); tela.LoadScreen("Departamento cadastrado com sucesso!"); tela.ShowDialog(); } catch (Exception) { frmException tela = new frmException(); tela.LoadScreen("Ocorreu um erro.\nConsulte o administrador do sistema."); tela.ShowDialog(); } }
private void PreenchendoCadastro() { CargoBusiness business = new CargoBusiness(); List <Cargo> lista = business.ConsultarTodos(); ddlCargo.DataSource = lista; ddlCargo.DataValueField = "IdCargo"; ddlCargo.DataTextField = "Nome"; ddlCargo.DataBind(); ddlCargo.Items.Insert(0, new ListItem("- Selecione um Cargo - ", "")); PerfilBusiness pbusiness = new PerfilBusiness(); List <Perfil> todos = pbusiness.ConsultarTodos(); ddlPerfil.DataSource = todos; ddlPerfil.DataValueField = "IdPerfil"; ddlPerfil.DataTextField = "Nome"; ddlPerfil.DataBind(); ddlPerfil.Items.Insert(0, new ListItem("- Selecione um Perfil -", "")); }
public ActionResult Atualizar(Cargo oCargo) { if (ModelState.IsValid) { try { CargoBusiness.Alterar(oCargo); TempData["MensagemSucesso"] = "O Cargo '" + oCargo.NomeDoCargo + "' foi atualizado com sucesso."; return(Json(new { resultado = new RetornoJSON() { URL = Url.Action("Index", "Cargo") } })); } catch (Exception ex) { if (ex.GetBaseException() == null) { return(Json(new { resultado = new RetornoJSON() { Erro = ex.Message } })); } else { return(Json(new { resultado = new RetornoJSON() { Erro = ex.GetBaseException().Message } })); } } } else { return(Json(new { resultado = TratarRetornoValidacaoToJSON() })); } }
protected void btnExcluir_Click(object sender, EventArgs e) { try { CargoBusiness business = new CargoBusiness(); int codigo = int.Parse(txtCodigo.Text); business.Excluir(codigo); Cargo c = new Cargo(); lblMensagem.Text = "Cargo " + c.Nome + " excluído com sucesso."; lblMensagem.ForeColor = Color.DarkBlue; txtCodigo.Text = string.Empty; txtNome.Text = string.Empty; txtDescricao.Text = string.Empty; btnExcluir.Enabled = false; } catch (Exception ex) { lblMensagem.Text = ex.Message; lblMensagem.ForeColor = Color.Red; } }
public CargoController() { _CargoBusiness = new CargoBusiness(); }