public clsImpresionFactura(List <tbDocumento> docs, tbClientes cliente, tbEmpresa empresa, decimal saldoPend) { _docs = docs; _empresa = empresa; _cliente = cliente; _saldo = saldoPend; }
public Retorno SalvarEmpresa(tbEmpresa objEmpresa, int intFunCodigo) { var objRetorno = new Retorno(); var strValidacao = ValidaEmpresa(objEmpresa); try { if (strValidacao == string.Empty) { var objEmpresaContexto = _objCtx.tbEmpresa.FirstOrDefault(); _objCtx.Entry(objEmpresaContexto).CurrentValues.SetValues(objEmpresa); _objCtx.SaveChanges(); using (var objBll = new Auditoria(ref _objCtx, ref _objTransacao)) objBll.SalvarAuditoria(objEmpresa.emp_codigo, enOperacao.Alteracao, objEmpresa, intFunCodigo); objRetorno = RetornaEmpresa(); } else { objRetorno.intCodigoErro = 48; objRetorno.strMsgErro = strValidacao; } } catch (Exception ex) { Util.LogErro(ex); objRetorno.intCodigoErro = 16; objRetorno.strMsgErro = ex.Message; objRetorno.strExceptionToString = ex.ToString(); } return(objRetorno); }
public ActionResult CrearEmpresa(string empNombre, string empDireccion, string empTelefono, int empPais, int empMoneda, int empLenguaje, int empLicencia, int empCantidaduser) { try { if (ModelState.IsValid) { tbEmpresa tbEmpresa = new tbEmpresa(); tbEmpresa = new tbEmpresa(); tbEmpresa.empNombre = empNombre; tbEmpresa.empDireccion = empDireccion; tbEmpresa.empTelefono = empTelefono; tbEmpresa.empPais = empPais; tbEmpresa.empMoneda = empMoneda; tbEmpresa.empLenguaje = empLenguaje; tbEmpresa.empLicencia = empLicencia; tbEmpresa.empCantidadUser = empCantidaduser; tbEmpresa.empUsuarioCrea = 8; tbEmpresa.empFechaCrea = DateTime.Now; tbEmpresa.empFechaModifica = DateTime.Now; tbEmpresa.empUsuarioModifica = 8; tbEmpresa.empVenId = 1; tbEmpresa.emptuId = 1; _context.tbEmpresa.Add(tbEmpresa); _context.SaveChanges(); return(Json(true)); } return(Json(false)); } catch (Exception ex) { return(Json(false)); } }
private void frmReporteGeneracionContrasena_Load(object sender, EventArgs e) { tbEmpleado _tbEmpleado = _tbPersona.tbEmpleado; tbEmpresa _tbEmpresa = _tbEmpleado.tbEmpresa; tbCargo _tbCargo = _tbEmpleado.tbCargo; tbDepartamento _tbDepartamento = _tbCargo.tbDepartamento; tbUsuario _tbUsuario = _tbEmpleado.tbUsuario; rptGeneracionContrasena _rptGeneracionContrasena = new rptGeneracionContrasena(); _rptGeneracionContrasena.razonSocial = _tbEmpresa.razonSocial; _rptGeneracionContrasena.nombreCompleto = _tbPersona.nombreCompleto; _rptGeneracionContrasena.descripcionCargo = _tbCargo.descripcion; _rptGeneracionContrasena.descripcionDepartamento = _tbDepartamento.descripcion; _rptGeneracionContrasena.correoElectronico = _tbEmpleado.correoElectronico; _rptGeneracionContrasena.nombreUsuario = _tbUsuario.nombreUsuario; _rptGeneracionContrasena.contrasena = Util.DesencriptaValor(_tbUsuario.contrasena, _tbUsuario.idUsuario.ToString()); _rptGeneracionContrasena.numeroIdentificacion = _tbPersona.numeroIdentificacion; _rptGeneracionContrasena.usuario = Program.tbUsuario.nombreUsuario; _rptGeneracionContrasena.terminal = Program.terminal; rvwGeneracionContrasena.LocalReport.DataSources.Clear(); rvwGeneracionContrasena.LocalReport.ReportPath = Application.StartupPath + "\\Reportes\\Seguridad\\rptGeneracionContrasena.rdlc"; rvwGeneracionContrasena.LocalReport.DataSources.Add(new ReportDataSource("dtsGeneracionContrasena", new List <rptGeneracionContrasena> { _rptGeneracionContrasena })); rvwGeneracionContrasena.RefreshReport(); }
public ActionResult EditarEmpresa(int id, string empNombre, string empDireccion, string empTelefono, int empPais, int empMoneda, int empLenguaje, int empLicencia, int empCantidaduser, int empUsuariocrea) { try { tbEmpresa tbEmpresa = _context.tbEmpresa.Find(id); if (tbEmpresa != null) { tbEmpresa.empNombre = empNombre; tbEmpresa.empDireccion = empDireccion; tbEmpresa.empTelefono = empTelefono; tbEmpresa.empPais = empPais; tbEmpresa.empMoneda = empMoneda; tbEmpresa.empLenguaje = empLenguaje; tbEmpresa.empLicencia = empLicencia; tbEmpresa.empCantidadUser = empCantidaduser; tbEmpresa.empUsuarioModifica = empUsuariocrea; tbEmpresa.empFechaModifica = DateTime.Now; _context.Entry(tbEmpresa).State = EntityState.Modified; _context.SaveChanges(); } return(Json(true)); } catch (Exception ex) { return(Json(false)); } }
private void cargarForm(tbEmpresa empresa) { try { txtIdEmpresa.Text = empresa.id.Trim(); if (empresa.tipoId == (int)Enums.TipoId.Fisica) { txtNombreEmpresa.Text = empresa.tbPersona.nombre.Trim().ToUpper() + " " + empresa.tbPersona.apellido1.Trim().ToUpper() + " " + empresa.tbPersona.apellido2.Trim().ToUpper(); } else { txtNombreEmpresa.Text = empresa.tbPersona.nombre.Trim().ToUpper(); } //datos hacienda chkAmbienteDesa.Checked = (bool)!empresa.ambientePruebas; txtUsuarioHacienda.Text = empresa.usuarioApiHacienda.Trim(); txtConstrasenaHacienda.Text = empresa.claveApiHacienda.Trim(); chkRegimenSimplificado.Checked = empresa.regimenSimplificado; if (chkRegimenSimplificado.Checked) { cboTipoFactRegimenSimplificado.Text = Enum.GetName(typeof(Enums.TipoFacturacionElectRegimenSimplificado), empresa.tipoFacturacionRegimen); } else { cboTipoFactRegimenSimplificado.ResetText(); } txtCertificado.Text = empresa.certificadoInstalado.Trim(); txtPinCertificado.Text = empresa.pin.ToString().Trim(); txtRutaXML.Text = empresa.rutaCertificado.Trim(); txtXMLCompras.Text = empresa.rutaXMLCompras.Trim(); txtResolucion.Text = empresa.numeroResolucion.Trim(); txtFechaResolucion.Text = empresa.fechaResolucio.ToString().Trim(); chkImprimeDoc.Checked = (bool)empresa.imprimeDoc; if (chkImprimeDoc.Checked) { txtNombreImpresora.Text = empresa.nombreImpresora.Trim(); } foreach (var item in empresa.tbEmpresaActividades) { listaActividades.Add(item); } cargarListaActividad(listaActividades); } catch (Exception ex) { throw; } }
private static string ValidaEmpresa(tbEmpresa objEmpresa) { if (string.IsNullOrEmpty(objEmpresa.emp_nome) || string.IsNullOrWhiteSpace(objEmpresa.emp_nome)) { return("O nome deve ser informado."); } return(string.Empty); }
public clsImpresionFactura(tbDocumento doc, tbEmpresa empresa, decimal paga, decimal vuelto) { _doc = doc; _empresa = empresa; _paga = paga; _vuelto = vuelto; _canton = cantonIns.GetEntity(_empresa.tbPersona.canton, _empresa.tbPersona.provincia); }
public clsImpresionFactura(tbDocumento doc, tbEmpresa empresa, decimal paga, decimal vuelto, string cliente) { _doc = doc; _empresa = empresa; _paga = paga; _vuelto = vuelto; _canton = cantonIns.GetEntity(_empresa.tbPersona.canton, _empresa.tbPersona.provincia); _clienteSimplificada = cliente; }
private void cargarDatos() { cboTipoFactRegimenSimplificado.DataSource = Enum.GetValues(typeof(Enums.TipoFacturacionElectRegimenSimplificado)); try { empresaGlobal.id = Global.Usuario.tbEmpresa.id.Trim(); empresaGlobal.tipoId = Global.Usuario.tbEmpresa.tipoId; empresaGlobal = empresaIns.getEntity(empresaGlobal); cargarForm(empresaGlobal); } catch (Exception) { throw; } }
public void modificar() { DialogResult resp = MessageBox.Show("Esta seguro que desea modificar los datos?", "Guardar datos", MessageBoxButtons.YesNo, MessageBoxIcon.Question); try { if (resp == DialogResult.Yes) { if (validarDatos()) { bool isNuevo = false; if (empresaGlobal == null) { empresaGlobal = new tbEmpresa(); isNuevo = true; } //empresaGlobal.nombreComercial = txtNombreComercial.Text; empresaGlobal.ambientePruebas = !chkAmbienteDesa.Checked; empresaGlobal.usuarioApiHacienda = txtUsuarioHacienda.Text; empresaGlobal.claveApiHacienda = txtConstrasenaHacienda.Text; //empresaGlobal.codigoActComercial = txtActEconomica.Text; empresaGlobal.certificadoInstalado = txtCertificado.Text; empresaGlobal.pin = int.Parse(txtPinCertificado.Text); empresaGlobal.regimenSimplificado = chkRegimenSimplificado.Checked; if (empresaGlobal.regimenSimplificado) { empresaGlobal.tipoFacturacionRegimen = (int)cboTipoFactRegimenSimplificado.SelectedValue; } else { empresaGlobal.tipoFacturacionRegimen = null; } empresaGlobal.rutaCertificado = txtRutaXML.Text; empresaGlobal.rutaXMLCompras = txtXMLCompras.Text; empresaGlobal.numeroResolucion = txtResolucion.Text; empresaGlobal.fechaResolucio = DateTime.Parse(txtFechaResolucion.Text); ////correo //empresaGlobal.correoElectronicoEmpresa = txtCorreoEmpresa.Text; //empresaGlobal.contrasenaCorreo = txtContraseCorreo.Text; //empresaGlobal.subjectCorreo = txtAsuntoCorreo.Text; //empresaGlobal.cuerpoCorreo = txtCuerpoCorreo.Text; empresaGlobal.imprimeDoc = chkImprimeDoc.Checked; empresaGlobal.nombreImpresora = txtNombreImpresora.Text; try { if (isNuevo) { empresaGlobal = empresaIns.guardar(empresaGlobal); } else { empresaGlobal = empresaIns.modificar(empresaGlobal); } cargarDatos(); MessageBox.Show("Los datos han sido actualizados en la base de datos.", "Actualización.", MessageBoxButtons.OK, MessageBoxIcon.Information); Global.Usuario.tbEmpresa = empresaGlobal; } catch (Exception) { MessageBox.Show("No se pudieron guardar los datos.", "Actualización.", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } catch (UpdateEntityException ex) { MessageBox.Show("Ha ocurrido un error. Comuniquese con el administrador " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public clsImpresionFactura(tbDocumento doc, tbEmpresa empresa) { _doc = doc; _empresa = empresa; }
/*/// <summary> * /// Adiciona nova TbEmpresa * /// </summary> * /// <param name="param"></param> * /// <returns></returns> * public static string Add(string token, tbEmpresa param) * { * try * { * _db.tbEmpresas.Add(param); * _db.SaveChanges(); * return param.nrCNPJBase; * } * catch (Exception e) * { * if (e is DbEntityValidationException) * { * string erro = MensagemErro.getMensagemErro((DbEntityValidationException)e); * throw new Exception(erro.Equals("") ? "Falha ao salvar TbEmpresa" : erro); * } * throw new Exception(e.InnerException == null ? e.Message : e.InnerException.InnerException == null ? e.InnerException.Message : e.InnerException.InnerException.Message); * } * } * * * /// <summary> * /// Apaga uma TbEmpresa * /// </summary> * /// <param name="param"></param> * /// <returns></returns> * public static void Delete(string token, string nrCNPJBase) * { * try * { * _db.tbEmpresas.Remove(_db.tbEmpresas.Where(e => e.nrCNPJBase.Equals(nrCNPJBase)).First()); * _db.SaveChanges(); * } * catch (Exception e) * { * if (e is DbEntityValidationException) * { * string erro = MensagemErro.getMensagemErro((DbEntityValidationException)e); * throw new Exception(erro.Equals("") ? "Falha ao apagar TbEmpresa" : erro); * } * throw new Exception(e.InnerException == null ? e.Message : e.InnerException.InnerException == null ? e.InnerException.Message : e.InnerException.InnerException.Message); * } * }*/ /*/// <summary> * /// Altera tbEmpresa * /// </summary> * /// <param name="param"></param> * /// <returns></returns> * public static Retorno Update(string token, tbEmpresa param) * { * try * { * tbEmpresa value = _db.tbEmpresas * .Where(e => e.nrCNPJBase.Equals(param.nrCNPJBase)) * .First<tbEmpresa>(); * * Retorno retorno = new Retorno(); * * HttpRequest httpRequest = HttpContext.Current.Request; * if (httpRequest.Files.Count == 0) throw new Exception("Não foi identificado o certificado digital"); * // Obtém o arquivo * HttpPostedFile postedFile = httpRequest.Files[0]; * * // Converte para um array de bytes * MemoryStream memoryStream = postedFile.InputStream as MemoryStream; * if (memoryStream == null) * { * memoryStream = new MemoryStream(); * postedFile.InputStream.CopyTo(memoryStream); * } * byte[] data = new byte[memoryStream.ToArray().Length]; * memoryStream.Read(data, 0, data.Length); * memoryStream.Close(); * * // VERIFICAR SE EXISTE ALTERAÇÃO NOS PARAMETROS * if (data != null && (value.dsCertificadoDigital == null || !data.SequenceEqual(value.dsCertificadoDigital))) * value.dsCertificadoDigital = data; * if (param.dsCertificadoDigitalSenha != null && (value.dsCertificadoDigitalSenha == null || !param.dsCertificadoDigitalSenha.Equals(value.dsCertificadoDigitalSenha))) * value.dsCertificadoDigitalSenha = param.dsCertificadoDigitalSenha; * * Mensagem mensagem = CertificadoDigital.ValidarCertificado(value.dsCertificadoDigital, value.dsCertificadoDigitalSenha); * if (mensagem.cdMensagem == 200) * { * value.dtCadastro = DateTime.Now; * value.dtValidade = CertificadoDigital.GetDataValidade(param.dsCertificadoDigital, param.dsCertificadoDigitalSenha); * value.flSenhaValida = true; * * _db.SaveChanges(); * } * * retorno.Registros.Add(mensagem); * * return retorno; * } * catch (Exception e) * { * if (e is DbEntityValidationException) * { * string erro = MensagemErro.getMensagemErro((DbEntityValidationException)e); * throw new Exception(erro.Equals("") ? "Falha ao alterar TbEmpresa" : erro); * } * throw new Exception(e.InnerException == null ? e.Message : e.InnerException.InnerException == null ? e.InnerException.Message : e.InnerException.InnerException.Message); * } * }*/ /// <summary> /// Altera certificado e senha /// </summary> /// <param name="param"></param> /// <returns></returns> public static Mensagem Patch(string token, Dictionary <string, string> queryString, painel_taxservices_dbContext _dbContext = null) { painel_taxservices_dbContext _db; if (_dbContext == null) { _db = new painel_taxservices_dbContext(); } else { _db = _dbContext; } try { // TEM QUE TER ENVIADO VIA QUERYSTRING nrCNPJBase e dsCertificadoDigitalSenha string outValue = null; if (!queryString.TryGetValue("" + (int)GatewayTbEmpresa.CAMPOS.NRCNPJBASE, out outValue) || !queryString.TryGetValue("" + (int)GatewayTbEmpresa.CAMPOS.DSCERTIFICADODIGITALSENHA, out outValue)) { throw new Exception("CNPJ base e Senha são obrigatórios!"); } string nrCNPJBase = queryString["" + (int)GatewayTbEmpresa.CAMPOS.NRCNPJBASE]; string dsCertificadoDigitalSenha = queryString["" + (int)GatewayTbEmpresa.CAMPOS.DSCERTIFICADODIGITALSENHA]; // Obtém o objet tbEmpresa value = _db.tbEmpresas.Where(e => e.nrCNPJBase.Equals(nrCNPJBase)).FirstOrDefault(); if (value == null) { throw new Exception("CNPJ Base inexistente!"); } // TEM QUE TER ENVIADO O ARQUIVO HttpRequest httpRequest = HttpContext.Current.Request; if (httpRequest.Files.Count == 0) { throw new Exception("Não foi identificado o certificado digital"); } // Obtém o arquivo HttpPostedFile postedFile = httpRequest.Files[0]; // Valida a extensão string extensao = postedFile.FileName.Substring(postedFile.FileName.LastIndexOf(".")); if (!extensao.ToLower().Equals(".pfx")) { throw new Exception("Formato do arquivo deve ser PFX!"); } // Converte para um array de bytes BinaryReader binaryReader = new BinaryReader(postedFile.InputStream); byte[] data = binaryReader.ReadBytes(postedFile.ContentLength); // VERIFICAR SE EXISTE ALTERAÇÃO NOS PARAMETROS if (value.dsCertificadoDigital == null || !data.SequenceEqual(value.dsCertificadoDigital)) { value.dsCertificadoDigital = data; } if (value.dsCertificadoDigitalSenha == null || !dsCertificadoDigitalSenha.Equals(value.dsCertificadoDigitalSenha)) { value.dsCertificadoDigitalSenha = dsCertificadoDigitalSenha; } // Decodifica a senha string senha = CertificadoDigital.DecodeFrom64(dsCertificadoDigitalSenha); Mensagem mensagem = CertificadoDigital.ValidarCertificado(data, senha);//value.dsCertificadoDigital, value.dsCertificadoDigitalSenha); if (mensagem.cdMensagem == 200) { value.dtCadastro = DateTime.Now; value.dtValidade = CertificadoDigital.GetDataValidade(data, senha);//value.dsCertificadoDigital, value.dsCertificadoDigitalSenha); value.flSenhaValida = true; _db.SaveChanges(); } return(mensagem); } catch (Exception e) { if (e is DbEntityValidationException) { string erro = MensagemErro.getMensagemErro((DbEntityValidationException)e); throw new Exception(erro.Equals("") ? "Falha ao alterar TbEmpresa" : erro); } throw new Exception(e.InnerException == null ? e.Message : e.InnerException.InnerException == null ? e.InnerException.Message : e.InnerException.InnerException.Message); } finally { if (_dbContext == null) { // Fecha conexão _db.Database.Connection.Close(); _db.Dispose(); } } }
public tbEmpresa modificar(tbEmpresa entity) { return(empresaIns.Actualizar(entity)); }
public tbEmpresa guardar(tbEmpresa entity) { return(empresaIns.Guardar(entity)); }
public tbEmpresa getEntity(tbEmpresa entity) { return(empresaIns.GetEntity(entity)); }