public bool Delete(tb_empresa BE) { using (SqlConnection cnx = new SqlConnection(conex.AdmConexion())) { using (SqlCommand cmd = new SqlCommand("gspTbEmpresa_DELETE", cnx)) { { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@empresaid", SqlDbType.Char, 2).Value = BE.empresaid; } try { cnx.Open(); if (cmd.ExecuteNonQuery() > 0) { return true; } else { return false; } } catch (Exception ex) { throw new Exception(ex.Message); } } } }
public IEnumerable <tb_prodbco> BuscarProdutoBancario(int cod_empresa, int cod_prodbco, IDaoTransacao transacao = null) { _log.TraceMethodStart(); var dao = _factory.GetDaoCorporativo <tb_prodbco>(); if (cod_empresa == null || cod_empresa <= 0) { throw new ApplicationException("Código da empresa inválido"); } if (cod_prodbco == null || cod_prodbco <= 0) { throw new ApplicationException("Código de produto inválido"); } tb_empresa empresa = _empresaService.BuscarEmpresaPorCodigo(cod_empresa, transacao); if (empresa == null) { throw new ApplicationException("Empresa informada não cadastrada"); } string where = $" cod_empresa = {cod_empresa} and cod_prodbco = {cod_prodbco} "; var retorno = dao.Obter(where); _log.TraceMethodEnd(); return(retorno); }
public DataSet GetAll(tb_empresa BE) { using (SqlConnection cnx = new SqlConnection(conex.AdmConexion())) { using (SqlCommand cmd = new SqlCommand("gspTbEmpresa_SEARCH", cnx)) { DataSet ds = new DataSet(); { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@empresaid", SqlDbType.Char, 2).Value = BE.empresaid; cmd.Parameters.Add("@empresaname", SqlDbType.VarChar, 60).Value = BE.empresaname; cmd.Parameters.Add("@empresaperiodo", SqlDbType.Char, 4).Value = BE.empresaperiodo; //cmd.Parameters.Add("@visible", SqlDbType.Bit).Value = true; } try { cnx.Open(); using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { da.Fill(ds); } return ds; } catch (Exception ex) { throw new Exception(ex.Message); } } } }
public tb_empresa ValidarLogin(string cnpj, string senha) { banco banco = new banco(); tb_empresa empresa = banco.tb_empresa.FirstOrDefault(p => p.cnpj_empresa == cnpj && p.senha_empresa == senha); return(empresa); }
public void InserirEmpresa(tb_empresa objEmpresa) { banco objBanco = new banco(); objBanco.AddTotb_empresa(objEmpresa); objBanco.SaveChanges(); }
public ActionResult DeleteConfirmed(int id) { tb_empresa tb_empresa = db.tb_empresa.Find(id); db.tb_empresa.Remove(tb_empresa); db.SaveChanges(); return(RedirectToAction("Index")); }
public void ExcluirOperadorDependencia(int emp_cod, int oper_cod, int dep_cod, IDaoTransacao transacao = null) { _log.TraceMethodStart(); if (emp_cod == null || emp_cod <= 0) { throw new ApplicationException("Código da empresa inválido"); } if (oper_cod == null || oper_cod <= 0) { throw new ApplicationException("Código do operador inválido"); } if (dep_cod == null || dep_cod <= 0) { throw new ApplicationException("Código da dependencia inválido"); } tb_empresa empresa = _empresaService.BuscarEmpresaPorCodigo(emp_cod, transacao); if (empresa == null) { throw new ApplicationException("Empresa informada não cadastrada"); } tb_operador operador = _operadorService.BuscarOperadorPorCodigo(emp_cod, oper_cod, transacao); if (operador == null) { throw new ApplicationException("Operador informado não cadastrado"); } tb_dependencia dependencia = _dependenciaService.BuscarDependenciaPorCodigo(emp_cod, oper_cod, transacao); if (operador == null) { throw new ApplicationException("Dependência informado não cadastrado"); } var dao = _factory.GetDaoCorporativo <tb_depope>(); string where = $" emp_cod = {emp_cod} and oper_cod = {oper_cod} and depend_cod = {dep_cod} "; var entityBanco = dao.Obter(where); if (entityBanco == null || !entityBanco.Any()) { throw new ApplicationException($"Dados informados não estão cadastrados - empresa: {emp_cod}, operador: {oper_cod} e dependencia: {dep_cod}"); } var entity = entityBanco.FirstOrDefault(); dao.Remover(entity, where); _log.TraceMethodEnd(); }
public void EditarProdutoBancario(tb_prodbco entity, IDaoTransacao transacao = null) { _log.TraceMethodStart(); var dao = _factory.GetDaoCorporativo <tb_prodbco>(); if (entity.cod_empresa == null || entity.cod_empresa.Value <= 0) { throw new ApplicationException("Código da empresa inválido"); } if (entity.cod_grproduto == null || entity.cod_grproduto.Value <= 0) { throw new ApplicationException("Código do grupo do produto inválido"); } if (entity.cod_prodbco == null || entity.cod_prodbco.Value <= 0) { throw new ApplicationException("Código do produto inválido"); } tb_empresa empresa = _empresaService.BuscarEmpresaPorCodigo(entity.cod_empresa.Value, transacao); if (empresa == null) { throw new ApplicationException("Empresa informada não cadastrada"); } tb_grproduto grproduto = _grprodutoService.BuscarGrupoProdutoPorCodigo(entity.cod_empresa.Value, entity.cod_grproduto.Value, transacao); if (grproduto == null) { throw new ApplicationException("Grupo do produto informado não cadastrado"); } string where = $" cod_empresa = {entity.cod_empresa} and cod_prodbco = {entity.cod_prodbco} "; var listaEntityBanco = dao.Obter(where); if (listaEntityBanco == null || !listaEntityBanco.Any()) { throw new ApplicationException($"Dados informados não foram cadastrados - empresa: {entity.cod_empresa} e produto bancário: {entity.cod_prodbco} "); } var entityBanco = listaEntityBanco.First(); entityBanco.abv_prodbco = entity.abv_prodbco; entityBanco.des_prodbco = entity.des_prodbco; entityBanco.cod_grproduto = entity.cod_grproduto; entityBanco.idc_replica = entity.idc_replica; entityBanco.tip_produto = entity.tip_produto; dao.Atualizar(entityBanco, where); _log.TraceMethodEnd(); }
public ActionResult Edit([Bind(Include = "id,nome,qtdfuncionarios,endereço")] tb_empresa tb_empresa) { if (ModelState.IsValid) { db.Entry(tb_empresa).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tb_empresa)); }
public ActionResult Edit([Bind(Include = "ID_empresa,nome_abreviado,razao_social,cnpj,ie,logradouro,numero,compl,cep,bairro,municipio,uf,regiao,telefone,celular,contato,email,observacao")] tb_empresa tb_empresa) { if (ModelState.IsValid) { db.Entry(tb_empresa).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tb_empresa)); }
public void EditarOperadorDependencia(tb_depope entity, IDaoTransacao transacao = null) { _log.TraceMethodStart(); var dao = transacao == null?_factory.GetDaoCorporativo <tb_depope>() : _factory.GetDaoCorporativo <tb_depope>(transacao); if (entity.emp_cod == null || entity.emp_cod.Value <= 0) { throw new ApplicationException("Código da empresa inválido"); } if (entity.oper_cod == null || entity.oper_cod.Value <= 0) { throw new ApplicationException("Código do operador inválido"); } if (entity.depend_cod == null || entity.depend_cod.Value <= 0) { throw new ApplicationException("Código de dependencia inválido"); } tb_empresa empresa = _empresaService.BuscarEmpresaPorCodigo(entity.emp_cod.Value, transacao); if (empresa == null) { throw new ApplicationException("Empresa informada não cadastrada"); } tb_dependencia dependencia = _dependenciaService.BuscarDependenciaPorCodigo(entity.emp_cod.Value, entity.depend_cod.Value, transacao); if (dependencia == null) { throw new ApplicationException("Dependencia informada não cadastrada"); } tb_operador operador = _operadorService.BuscarOperadorPorCodigo(entity.emp_cod.Value, entity.oper_cod.Value, transacao); if (dependencia == null) { throw new ApplicationException("Operador informado não cadastrado"); } string where = $" emp_cod = {entity.emp_cod} and oper_cod = {entity.oper_cod} "; var entityBanco = dao.Obter(where); if (entityBanco == null || !entityBanco.Any()) { throw new ApplicationException($"Dados informados não foram cadastrados - empresa: {entity.emp_cod} e operador dependencia: {entity.oper_cod} "); } dao.Atualizar(entity, where); _log.TraceMethodEnd(); }
public ActionResult Create([Bind(Include = "id,nome,qtdfuncionarios,endereço")] tb_empresa tb_empresa) { if (ModelState.IsValid) { db.tb_empresa.Add(tb_empresa); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tb_empresa)); }
public void InserirEmpresa(tb_empresa objEmpresa) { //Cria o Banco Banco objBanco = new Banco(); //Adciona o objeto para gravar objBanco.AddTotb_empresa(objEmpresa); //salva a operacao objBanco.SaveChanges(); }
public tb_empresa BuscarEmpresaPorCodigo(int cod_empresa, IDaoTransacao transacao = null) { _log.TraceMethodStart(); var dao = transacao == null?_factory.GetDaoCorporativo <tb_empresa>() : _factory.GetDaoCorporativo <tb_empresa>(transacao); tb_empresa retorno = dao.ObterPrimeiro($" cod_empresa = {cod_empresa} "); _log.TraceMethodEnd(); return(retorno); }
public void AlterarEmpresa(tb_empresa objEntrada) { Banco objBanco = new Banco(); tb_empresa objEmpresa = objBanco.tb_empresa.Include("tb_endereco") .FirstOrDefault(p => p.cod_empresa == objEntrada.cod_empresa); objEmpresa.nome_empresa = objEntrada.nome_empresa; objEmpresa.tb_endereco.First().endereco = objEntrada.tb_endereco.First().endereco; objEmpresa.tb_endereco.First().endereco = objEntrada.tb_endereco.First().telefone; objBanco.SaveChanges(); }
// GET: tb_empresa/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tb_empresa tb_empresa = db.tb_empresa.Find(id); if (tb_empresa == null) { return(HttpNotFound()); } return(View(tb_empresa)); }
public tb_empresa_Info get_info(int IdEmpresa) { try { tb_empresa_Info info = new tb_empresa_Info(); using (Entities_general Context = new Entities_general()) { tb_empresa Entity = Context.tb_empresa.FirstOrDefault(q => q.IdEmpresa == IdEmpresa); if (Entity == null) { return(null); } info = new tb_empresa_Info { IdEmpresa = Entity.IdEmpresa, codigo = Entity.codigo, em_nombre = Entity.em_nombre, RazonSocial = Entity.RazonSocial, NombreComercial = Entity.NombreComercial, ContribuyenteEspecial = Entity.ContribuyenteEspecial, ObligadoAllevarConta = Entity.ObligadoAllevarConta, em_ruc = Entity.em_ruc, em_gerente = Entity.em_gerente, em_contador = Entity.em_contador, em_rucContador = Entity.em_rucContador, em_telefonos = Entity.em_telefonos, em_fax = Entity.em_fax, em_notificacion = Entity.em_notificacion, em_direccion = Entity.em_direccion, em_tel_int = Entity.em_tel_int, em_logo = Entity.em_logo, em_fondo = Entity.em_fondo, em_fechaInicioContable = Entity.em_fechaInicioContable, Estado = Entity.Estado, em_fechaInicioActividad = Entity.em_fechaInicioActividad, cod_entidad_dinardap = Entity.cod_entidad_dinardap, em_Email = Entity.em_Email, ObligadoAllevarConta_bool = Entity.ObligadoAllevarConta == "S" ? true : false }; } return(info); } catch (Exception) { throw; } }
public void EditarGrupoEmpresarial(tb_grpemp entity, IDaoTransacao transacao = null) { _log.TraceMethodStart(); var dao = _factory.GetDaoCorporativo <tb_grpemp>(); if (entity.cod_empresa == null || entity.cod_empresa.Value <= 0) { throw new ApplicationException("Código da empresa inválido"); } if (entity.cod_depend == null || entity.cod_depend.Value <= 0) { throw new ApplicationException("Código de dependencia inválido"); } tb_empresa empresa = _empresaService.BuscarEmpresaPorCodigo(entity.cod_empresa.Value, transacao); if (empresa == null) { throw new ApplicationException("Empresa informada não cadastrada"); } tb_dependencia dependencia = _dependenciaService.BuscarDependenciaPorCodigo(entity.cod_depend.Value, entity.cod_depend.Value, transacao); if (dependencia == null) { throw new ApplicationException("Dependencia informada não cadastrada"); } string where = $" cod_empresa = {entity.cod_empresa} and cod_grpemp = {entity.cod_grpemp} "; var listaEntityBanco = dao.Obter(where); if (listaEntityBanco == null || !listaEntityBanco.Any()) { throw new ApplicationException($"Dados informados não foram cadastrados - empresa: {entity.cod_empresa} e grupo empresarial: {entity.cod_grpemp} "); } var entityBanco = listaEntityBanco.First(); entityBanco.abv_grpemp = entity.abv_grpemp; entityBanco.des_grpemp = entity.des_grpemp; entityBanco.cod_depend = entity.cod_depend; dao.Atualizar(entityBanco, where); _log.TraceMethodEnd(); }
public tb_prodbco GravarProdutoBancario(tb_prodbco entity, IDaoTransacao transacao = null) { _log.TraceMethodStart(); var dao = _factory.GetDaoCorporativo <tb_prodbco>(); if (entity.cod_empresa == null || entity.cod_empresa.Value <= 0) { throw new ApplicationException("Código da empresa inválido"); } if (entity.cod_grproduto == null || entity.cod_grproduto.Value <= 0) { throw new ApplicationException("Código do grupo do produto inválido"); } if (entity.cod_prodbco == null || entity.cod_prodbco.Value <= 0) { throw new ApplicationException("Código do produto inválido"); } tb_empresa empresa = _empresaService.BuscarEmpresaPorCodigo(entity.cod_empresa.Value, transacao); if (empresa == null) { throw new ApplicationException("Empresa informada não cadastrada"); } tb_grproduto grproduto = _grprodutoService.BuscarGrupoProdutoPorCodigo(entity.cod_empresa.Value, entity.cod_grproduto.Value, transacao); if (grproduto == null) { throw new ApplicationException("Grupo do produto informado não cadastrado"); } string where = $" cod_empresa = {entity.cod_empresa} and cod_prodbco = {entity.cod_prodbco} "; var entityBanco = dao.Obter(where); if (entityBanco != null && entityBanco.Any()) { throw new ApplicationException($"Dados informados já foram cadastrados - empresa: {entity.cod_empresa} e produto bancário: {entity.cod_prodbco} "); } entity = dao.Inserir(entity); _log.TraceMethodEnd(); return(entity); }
public ActionResult GravarEmpresa(string nome_empresa, string endereco, string telefone, int?cod_empresa) { if (nome_empresa.Trim() == string.Empty || endereco.Trim() == string.Empty || telefone.Trim() == string.Empty) { ViewBag.Validar = 0; } else { try { //Cria o Objeto DAO EmpresaDAO objDAO = new EmpresaDAO(); //Cria o objeto para gravar tb_empresa objEmpresa = new tb_empresa(); tb_endereco objEndereco = new tb_endereco(); objEmpresa.cod_usuario = CodigoUsuarioLogado; objEmpresa.nome_empresa = nome_empresa.Trim(); objEndereco.endereco = endereco.Trim(); objEndereco.telefone = telefone.Trim(); objEmpresa.tb_endereco.Add(objEndereco); //Verifica se é uma inserção if (cod_empresa == null) { objDAO.InserirEmpresa(objEmpresa); } else { objEmpresa.cod_empresa = Convert.ToInt32(cod_empresa); objDAO.AlterarEmpresa(objEmpresa); } ViewBag.Validar = 1; } catch { ViewBag.Validar = -1; } } ConsultarEmpresa(); return(View("Empresa")); }
//========================================================================= private void grdEmpresaCadastrada_CellClick(object sender, DataGridViewCellEventArgs e) { if (grdEmpresaCadastrada.RowCount > 0) { tb_empresa ObjLinhaClicada = (tb_empresa)grdEmpresaCadastrada.CurrentRow.DataBoundItem; txtbCod.Text = ObjLinhaClicada.id_empresa.ToString(); txtbNome.Text = ObjLinhaClicada.nome_empresa; txtbEndereco.Text = ObjLinhaClicada.endereco_empresa; txtMaskTelefone.Text = ObjLinhaClicada.tel_empresa; txtSite.Text = ObjLinhaClicada.site_empresa; Util.EstadoBotao(Util.EstadoTela.Alterar, btnSalvar, btnExcluir); } }
public tb_operador GravarOperador(tb_operador entity, IDaoTransacao transacao = null) { _log.TraceMethodStart(); var dao = transacao == null?_factory.GetDaoCorporativo <tb_operador>() : _factory.GetDaoCorporativo <tb_operador>(transacao); if (entity.cod_empresa == null || entity.cod_empresa <= 0) { throw new ApplicationException("Código da empresa inválido"); } if (entity.cod_oper == null || entity.cod_oper <= 0) { throw new ApplicationException("Código do operador inválido"); } tb_empresa empresa = _empresaService.BuscarEmpresaPorCodigo(entity.cod_empresa.Value, transacao); if (empresa == null) { throw new ApplicationException("Empresa informada não cadastrada"); } string where = $" cod_empresa = {entity.cod_empresa} and cod_oper = {entity.cod_oper} "; var entityBanco = dao.Obter(where); if (entityBanco != null && entityBanco.Any()) { throw new ApplicationException($"Dados informados já foram cadastrados - empresa: {entity.cod_empresa} e operador: {entity.cod_oper} "); } if (entity.dat_cad == null || entity.dat_cad == DateTime.MinValue) { entity.dat_cad = DateTime.Now; } if (entity.dat_atu == null || entity.dat_atu == DateTime.MinValue) { entity.dat_atu = DateTime.Now; } entity = dao.Inserir(entity); _log.TraceMethodEnd(); return(entity); }
public tb_grpemp GravarGrupoEmpresarial(tb_grpemp entity, IDaoTransacao transacao = null) { _log.TraceMethodStart(); var dao = _factory.GetDaoCorporativo <tb_grpemp>(); if (entity.cod_empresa == null || entity.cod_empresa.Value <= 0) { throw new ApplicationException("Código da empresa inválido"); } if (entity.cod_depend == null || entity.cod_depend.Value <= 0) { throw new ApplicationException("Código de dependencia inválido"); } tb_empresa empresa = _empresaService.BuscarEmpresaPorCodigo(entity.cod_empresa.Value, transacao); if (empresa == null) { throw new ApplicationException("Empresa informada não cadastrada"); } tb_dependencia dependencia = _dependenciaService.BuscarDependenciaPorCodigo(entity.cod_depend.Value, entity.cod_depend.Value, transacao); if (dependencia == null) { throw new ApplicationException("Dependencia informada não cadastrada"); } string where = $" cod_empresa = {entity.cod_empresa} and cod_grpemp = {entity.cod_grpemp} "; var entityBanco = dao.Obter(where); if (entityBanco != null && entityBanco.Any()) { throw new ApplicationException($"Dados informados já foram cadastrados - empresa: {entity.cod_empresa} e grupo empresarial: {entity.cod_grpemp} "); } entity = dao.Inserir(entity); _log.TraceMethodEnd(); return(entity); }
public bool guardarDB(tb_empresa_Info info) { try { using (Entities_general Context = new Entities_general()) { tb_empresa Entity = new tb_empresa { IdEmpresa = info.IdEmpresa = get_id(), codigo = info.codigo, em_nombre = info.em_nombre, RazonSocial = info.RazonSocial, NombreComercial = info.NombreComercial, ContribuyenteEspecial = info.ContribuyenteEspecial, ObligadoAllevarConta = info.ObligadoAllevarConta_bool == true ? "S" : "N", em_ruc = info.em_ruc, em_gerente = info.em_gerente, em_contador = info.em_contador, em_rucContador = info.em_rucContador, em_telefonos = info.em_telefonos, em_fax = info.em_fax, em_notificacion = info.em_notificacion, em_direccion = info.em_direccion, em_tel_int = info.em_tel_int, em_logo = info.em_logo, em_fondo = info.em_fondo, em_fechaInicioContable = info.em_fechaInicioContable, Estado = info.Estado = "A", em_fechaInicioActividad = info.em_fechaInicioActividad, cod_entidad_dinardap = info.cod_entidad_dinardap, em_Email = info.em_Email, }; Context.tb_empresa.Add(Entity); Context.SaveChanges(); } return(true); } catch (Exception) { throw; } }
private void btnAcessar_Click(object sender, EventArgs e) { if (ValidarCampos()) { EmpresaDAO dao = new EmpresaDAO(); tb_empresa empresa = dao.ValidarLogin(txtCnpj.Text.Trim(), txtSenha.Text.Trim()); if (empresa != null) { Util.CodigoLogado = empresa.cod_empresa; this.DialogResult = DialogResult.OK; } else { Util.ExibirMsgGeral(Util.TipoMsg.UsuarioNaoEncontrado); } } }
public bool modificarDB(tb_empresa_Info info) { try { using (Entities_general Context = new Entities_general()) { tb_empresa Entity = Context.tb_empresa.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa); if (Entity == null) { return(false); } Entity.codigo = info.codigo; Entity.em_nombre = info.em_nombre; Entity.RazonSocial = info.RazonSocial; Entity.NombreComercial = info.NombreComercial; Entity.ContribuyenteEspecial = info.ContribuyenteEspecial; Entity.ObligadoAllevarConta = info.ObligadoAllevarConta_bool == true ? "S" : "N"; Entity.em_ruc = info.em_ruc; Entity.em_gerente = info.em_gerente; Entity.em_contador = info.em_contador; Entity.em_rucContador = info.em_rucContador; Entity.em_telefonos = info.em_telefonos; Entity.em_fax = info.em_fax; Entity.em_notificacion = info.em_notificacion; Entity.em_direccion = info.em_direccion; Entity.em_tel_int = info.em_tel_int; Entity.em_logo = info.em_logo; Entity.em_fondo = info.em_fondo; Entity.em_fechaInicioContable = info.em_fechaInicioContable; Entity.em_fechaInicioActividad = info.em_fechaInicioActividad; Entity.cod_entidad_dinardap = info.cod_entidad_dinardap; Entity.em_Email = info.em_Email; Context.SaveChanges(); } return(true); } catch (Exception) { throw; } }
public bool modificarDB(tb_empresa_Info info) { try { using (Entities_general Context = new Entities_general()) { tb_empresa Entity = Context.tb_empresa.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa); if (Entity == null) { return(false); } Entity.codigo = info.codigo; Entity.em_nombre = info.em_nombre; Entity.RazonSocial = info.RazonSocial; Entity.NombreComercial = info.NombreComercial; Entity.ContribuyenteEspecial = info.ContribuyenteEspecial ?? ""; Entity.em_ruc = info.em_ruc; Entity.em_gerente = info.em_gerente; Entity.em_contador = info.em_contador; Entity.em_rucContador = info.em_rucContador; Entity.em_telefonos = info.em_telefonos; Entity.em_direccion = info.em_direccion; if (info.em_logo != null) { Entity.em_logo = info.em_logo; } Entity.em_fechaInicioContable = info.em_fechaInicioContable; Entity.em_fechaInicioActividad = Convert.ToDateTime(info.em_fechaInicioActividad); Entity.cod_entidad_dinardap = info.cod_entidad_dinardap; Entity.em_Email = info.em_Email; Context.SaveChanges(); } return(true); } catch (Exception) { throw; } }
public bool anularDB(tb_empresa_Info info) { try { using (Entities_general Context = new Entities_general()) { tb_empresa Entity = Context.tb_empresa.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa); if (Entity == null) { return(false); } Entity.Estado = info.Estado = "I"; Context.SaveChanges(); } return(true); } catch (Exception) { throw; } }
public void ExcluirProdutoBancario(int cod_empresa, int cod_prodbco, IDaoTransacao transacao = null) { _log.TraceMethodStart(); var dao = _factory.GetDaoCorporativo <tb_prodbco>(); if (cod_empresa == null || cod_empresa <= 0) { throw new ApplicationException("Código da empresa inválido"); } if (cod_prodbco == null || cod_prodbco <= 0) { throw new ApplicationException("Código de produto inválido"); } tb_empresa empresa = _empresaService.BuscarEmpresaPorCodigo(cod_empresa, transacao); if (empresa == null) { throw new ApplicationException("Empresa informada não cadastrada"); } string where = $" cod_empresa = {cod_empresa} and cod_prodbco = {cod_prodbco} "; var entityBanco = dao.Obter(where); if (entityBanco == null || !entityBanco.Any()) { throw new ApplicationException($"Dados informados não estão cadastrados - empresa: {cod_empresa} e produto bancário: {cod_prodbco} "); } var entity = entityBanco.FirstOrDefault(); dao.Remover(entity, where); _log.TraceMethodEnd(); }
//=========================================================================== private void btnSalvar_Click(object sender, EventArgs e) { if (VerificarCampos()) { EmpresaDAO objDao = new EmpresaDAO(); tb_empresa objEmpresa = new tb_empresa(); objEmpresa.nome_empresa = txtbNome.Text.Trim(); objEmpresa.tel_empresa = txtMaskTelefone.Text.Trim(); objEmpresa.endereco_empresa = txtbEndereco.Text.Trim(); objEmpresa.site_empresa = txtSite.Text.Trim(); objEmpresa.data_cadastro = DateTime.Now; objEmpresa.id_usuario = Usuario.codigoLogado; try { if (txtbCod.Text == "") { objDao.InserirEmpresaProc(objEmpresa); } else { objEmpresa.id_empresa = Convert.ToInt32(txtbCod.Text); objDao.AlterarEmpresaProc(objEmpresa); } Util.ExibirMsg(Util.TipoMsg.Sucesso); LimparCampos(); CarregarGrid(); } catch { Util.ExibirMsg(Util.TipoMsg.Erro); } } }
public bool Delete(tb_empresa BE) { return tablaDA.Delete(BE); }
public bool Update(tb_empresa BE) { return tablaDA.Update(BE); }
protected void cboEmpresalogueo_SelectedIndexChanged(object sender, EventArgs e) { try { txtusuario.Text = ""; txtusuario.Focus(); empresasWebBL BL = new empresasWebBL(); tb_empresa BE = new tb_empresa(); DataTable dt2 = new DataTable(); BE.empresaid = cboEmpresalogueo.SelectedValue; dt2 = BL.GetAll(BE).Tables[0]; Session["ssEmpresaID"] = dt2.Rows[0]["empresaid"]; Session["ssEmpresaName"] = dt2.Rows[0]["empresaname"]; Session["ssEmpresaRuc"] = dt2.Rows[0]["empresaruc"]; Session["ssGerenteGeneral"] = dt2.Rows[0]["gerentegeneral"]; Session["ssGerenteNrodni"] = dt2.Rows[0]["nrodni"]; Session["ssPartElectro"] = dt2.Rows[0]["partidaelectronica"]; if (dt2.Rows[0]["foto"].ToString().Trim().Length != 0) { Session["ssLogo"] = dt2.Rows[0]["foto"]; } else { Session["ssLogo"] = "nologoempresa.png"; } } catch (Exception ex) { ClientMessage(ex.Message); } }
public ActionResult Gravar(string nome, string tel, string end, string sit, string cod, string btn) { string pagina = ""; if (btn == "excluir") { int codEmpresa = Convert.ToInt32(cod); EmpresaDAO ObjDao = new EmpresaDAO(); try { ObjDao.ExcluirEmpresa(codEmpresa); ViewBag.Ret = 1; ViewBag.Msg = Mensagens.Msg.MensagemSucesso; } catch (Exception) { ViewBag.Ret = -1; ViewBag.Msg = Mensagens.Msg.MensagemErroExclusao; } pagina = "Consultar"; MontarTitulo(3); ConsultarEmpresas(); } else { if (nome.Trim() == "" || tel.Trim() == "" || end.Trim() == "" || sit == "") { ViewBag.Ret = 0; ViewBag.Msg = Mensagens.Msg.MesagemCampoObg; if (cod == null) { MontarTitulo(1); pagina = "Cadastrar"; } else { MontarTitulo(2); pagina = "Alterar"; } } else { EmpresaDAO objdao = new EmpresaDAO(); tb_empresa objEmpresa = new tb_empresa(); objEmpresa.nome_empresa = nome; objEmpresa.tel_empresa = tel; objEmpresa.endereco_empresa = end; objEmpresa.site_empresa = sit; objEmpresa.data_cadastro = DateTime.Now; objEmpresa.id_usuario = CodigoLogado; try { if (cod == null) { objdao.InserirEmpresa(objEmpresa); MontarTitulo(1); pagina = "Cadastrar"; } else { objdao.AlterarEmpresa(objEmpresa); MontarTitulo(2); pagina = "Alterar"; } ViewBag.ret = 1; ViewBag.Msg = Mensagens.Msg.MensagemSucesso; } catch (Exception ex) { ViewBag.ret = -1; ViewBag.Msg = Mensagens.Msg.MensagemErro; if (cod == null) { MontarTitulo(1); pagina = "Cadastrar"; } else { MontarTitulo(2); pagina = "Alterar"; } } MontarTitulo(1); } } return(View(pagina)); }
public bool Insert(tb_empresa BE) { return tablaDA.Insert(BE); }
public DataSet GetAll(tb_empresa BE) { return tablaDA.GetAll(BE); }
public void EditarOperador(tb_operador entity, IDaoTransacao transacao = null) { _log.TraceMethodStart(); var dao = transacao == null?_factory.GetDaoCorporativo <tb_operador>() : _factory.GetDaoCorporativo <tb_operador>(transacao); if (entity.cod_empresa == null || entity.cod_empresa <= 0) { throw new ApplicationException("Código da empresa inválido"); } if (entity.cod_oper == null || entity.cod_oper <= 0) { throw new ApplicationException("Código do operador inválido"); } tb_empresa empresa = _empresaService.BuscarEmpresaPorCodigo(entity.cod_empresa.Value, transacao); if (empresa == null) { throw new ApplicationException("Empresa informada não cadastrada"); } string where = $" cod_empresa = {entity.cod_empresa} and cod_oper = {entity.cod_oper} "; var listaEntityBanco = dao.Obter(where); if (listaEntityBanco == null || !listaEntityBanco.Any()) { throw new ApplicationException($"Dados informados não foram cadastrados - empresa: {entity.cod_empresa} e operador: {entity.cod_oper} "); } var entityBanco = listaEntityBanco.First(); entityBanco.cod_depend = entity.cod_depend; entityBanco.nom_oper = entity.nom_oper; entityBanco.nom_abv_oper = entity.nom_abv_oper; entityBanco.idt_oper = entity.idt_oper; entityBanco.log_oper = entity.log_oper; entityBanco.tip_oper = entity.tip_oper; entityBanco.usu_atu = entity.usu_atu; if (entity.dat_atu == null || entity.dat_atu == DateTime.MinValue) { entity.dat_atu = DateTime.Now; } entityBanco.dat_sit = entity.dat_sit; entityBanco.idc_sit = entity.idc_sit; entityBanco.cod_cargo = entity.cod_cargo; entityBanco.cpf_oper = entity.cpf_oper; entityBanco.dig_oper = entity.dig_oper; entityBanco.sex_oper = entity.sex_oper; entityBanco.ddd_oper = entity.ddd_oper; entityBanco.tel_oper = entity.tel_oper; entityBanco.ram_oper = entity.ram_oper; entityBanco.eml_oper = entity.eml_oper; entityBanco.cod_ger_origem = entity.cod_ger_origem; entityBanco.OPECODCRK = entity.OPECODCRK; dao.Atualizar(entityBanco, where); _log.TraceMethodEnd(); }
private void get_cargarComboEmpresas() { empresasWebBL empresaBL = new empresasWebBL(); tb_empresa tb_empresa = new tb_empresa(); DataTable dt = new DataTable(); try { dt = empresaBL.GetAll(tb_empresa).Tables[0]; cboEmpresalogueo.DataSource = dt; cboEmpresalogueo.DataValueField = "empresaid"; cboEmpresalogueo.DataTextField = "empresaname"; cboEmpresalogueo.DataBind(); } catch (Exception ex) { ClientMessage(ex.Message); } }
private BindingSource NewMethod() { empresasBL BL = new empresasBL(); tb_empresa BE = new tb_empresa(); DataTable table = BL.GetAll(BE).Tables[0]; DataRowCollection rows = table.Rows; object[] cell; Dictionary<string, string> dic = new Dictionary<string, string>(); BindingSource binding = new BindingSource(); foreach (DataRow item in rows) { cell = item.ItemArray; dic.Add(cell[0].ToString(), cell[0].ToString() + " - " + cell[1].ToString()); cell = null; } binding.DataSource = dic; return binding; }
private void cboEmpresa_SelectedIndexChanged(object sender, EventArgs e) { try { txtUsuar.Text = string.Empty; txtClave.Text = string.Empty; txtUsuar.Focus(); empresasBL BL = new empresasBL(); tb_empresa BE = new tb_empresa(); DataTable dt2 = new DataTable(); BE.empresaid = cboEmpresa.Text.Substring(0, 2).Trim().PadLeft(2, '0'); dt2 = BL.GetAll(BE).Tables[0]; if (dt2.Rows.Count > 0) { VariablesPublicas.EmpresaID = dt2.Rows[0]["empresaid"].ToString(); VariablesPublicas.EmpresaName = dt2.Rows[0]["empresaname"].ToString().Trim(); VariablesPublicas.EmpresaRuc = dt2.Rows[0]["empresaruc"].ToString(); VariablesPublicas.EmpresaDirecc = dt2.Rows[0]["empresadirec"].ToString(); VariablesPublicas.EmpresaTelef = dt2.Rows[0]["empresatelef"].ToString(); VariablesPublicas.EmpresaSigla = dt2.Rows[0]["empresasigla"].ToString().Trim(); if (dt2.Rows[0]["foto"].ToString().Trim().Length != 0) { VariablesPublicas.EmpresaLogo = dt2.Rows[0]["foto"].ToString(); } else { VariablesPublicas.EmpresaLogo = "nologoempresa.png"; } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Empresa() { try { txtUsuar.Text = ""; txtClave.Text = ""; txtUsuar.Focus(); empresasBL BL = new empresasBL(); tb_empresa BE = new tb_empresa(); DataTable dt2 = new DataTable(); BE.empresaid = cboEmpresa.SelectedValue.ToString(); dt2 = BL.GetAll(BE).Tables[0]; VariablesPublicas.EmpresaID = dt2.Rows[0]["empresaid"].ToString(); VariablesPublicas.EmpresaName = dt2.Rows[0]["empresaname"].ToString(); VariablesPublicas.EmpresaRuc = dt2.Rows[0]["empresaruc"].ToString(); if (dt2.Rows[0]["foto"].ToString().Trim().Length != 0) { VariablesPublicas.EmpresaLogo = dt2.Rows[0]["foto"].ToString(); } else { VariablesPublicas.EmpresaLogo = "nologoempresa.png"; } } catch (Exception ex) { MessageBoxEx.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public bool Update(tb_empresa BE) { using (SqlConnection cnx = new SqlConnection(conex.AdmConexion())) { using (SqlCommand cmd = new SqlCommand("gspTbEmpresa_UPDATE", cnx)) { { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@empresaid", SqlDbType.Char, 2).Value = BE.empresaid; cmd.Parameters.Add("@empresadirec", SqlDbType.VarChar, 60).Value = BE.empresadirec; cmd.Parameters.Add("@empresaname", SqlDbType.VarChar, 60).Value = BE.empresaname; cmd.Parameters.Add("@empresaperiodo", SqlDbType.Char, 4).Value = BE.empresaperiodo; cmd.Parameters.Add("@empresaruc", SqlDbType.Char, 11).Value = BE.empresaruc; cmd.Parameters.Add("@empresatelef", SqlDbType.VarChar, 30).Value = BE.empresatelef; cmd.Parameters.Add("@foto", SqlDbType.VarChar, 100).Value = BE.foto; cmd.Parameters.Add("@usuar", SqlDbType.Char, 15).Value = BE.usuar; cmd.Parameters.Add("@status", SqlDbType.Char, 1).Value = BE.status; } try { cnx.Open(); if (cmd.ExecuteNonQuery() > 0) { return true; } else { return false; } } catch (Exception ex) { throw new Exception(ex.Message); } } } }
private void llenar_cboEmpresas() { try { var BE = new tb_empresa(); BE.empresaid = null; BE.empresaname = null; cmbempresa.DataSource = NewMethod(); cmbempresa.DisplayMember = "Value"; cmbempresa.ValueMember = "Key"; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Cargar_Empresaid() { var BE = new tb_empresa(); var BL = new empresasBL(); var dt = new DataTable(); dt = BL.GetAll(BE).Tables[0]; cbo_empresaid.DataSource = dt; cbo_empresaid.ValueMember = "empresaid"; cbo_empresaid.DisplayMember = "empresaname"; }
void Datos_Empresa() { empresasWebBL BL = new empresasWebBL(); tb_empresa BE = new tb_empresa(); DataTable dt2 = new DataTable(); BE.empresaid = "99"; dt2 = BL.GetAll(BE).Tables[0]; Session["ssEmpresaID"] = dt2.Rows[0]["empresaid"]; Session["ssEmpresaName"] = dt2.Rows[0]["empresaname"]; Session["ssEmpresaRuc"] = dt2.Rows[0]["empresaruc"]; Session["ssGerenteGeneral"] = dt2.Rows[0]["gerentegeneral"]; Session["ssGerenteNrodni"] = dt2.Rows[0]["nrodni"]; Session["ssPartElectro"] = dt2.Rows[0]["partidaelectronica"]; }