Exemplo n.º 1
0
        public IHttpActionResult Putempresa(Guid guid, empresa empresa)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (guid != empresa.guid)
            {
                return(BadRequest());
            }

            db.Entry(empresa).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!empresaExists(guid))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        public empresa recuperar()
        {
            empresaCollection ec = dm.GetempresaCollection();
            empresa           e  = ec.FindByid(1);

            return(e);
        }
        public ActionResult Edit(empresa en)
        {
            try
            {
                // TODO: Add update logic here
                if (ModelState.IsValid)
                {
                    using (sistemaviajesbusEntities db = new sistemaviajesbusEntities())
                    {
                        var oTabla = db.empresa.Find(en.codigo_emp);
                        en.perfil_emp    = oTabla.perfil_emp;
                        en.nombre_emp    = oTabla.nombre_emp;
                        en.ruck_emp      = oTabla.ruck_emp;
                        en.direccion_emp = oTabla.direccion_emp;
                        en.telefono_emp  = oTabla.telefono_emp;
                        en.valoracion    = oTabla.valoracion;


                        bd.Entry(oTabla).State = System.Data.Entity.EntityState.Modified;
                        bd.SaveChanges();
                    }
                    return(Redirect("/Empresas/ListaEmpresas"));
                }
                return(View(en));
            }

            catch (Exception ex)
            {
                //return View(cli);
                //ViewBag.mensaje = ex.Message;
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 4
0
        public static void InsertarEmpresa(Empresa empresaInsertar)
        {
            RBVDataContext contextoRBV = new RBVDataContext();

            empresa empresa = new empresa();

            empresa.nit               = empresaInsertar.Nit;
            empresa.nombreEmpresa     = empresaInsertar.NombreEmpresa;
            empresa.represetanteLegal = empresaInsertar.RepresetanteLegal;

            contextoRBV.empresa.InsertOnSubmit(empresa);

            contextoRBV.SubmitChanges();
            (from sectorC in empresaInsertar.SectoresEmpresas select sectorC.IdEmpresa = empresa.idEmpresa).ToList();

            if (empresaInsertar.SectoresEmpresas.Count > 0)
            {
                InsertarEmpresaSector(empresaInsertar.SectoresEmpresas);
            }

            empresaInsertar.EmpresasUsuarios.UserId = contextoRBV.aspnet_Users.SingleOrDefault(p => p.UserName == empresaInsertar.EmpresasUsuarios.UserName).UserId;

            empresaInsertar.EmpresasUsuarios.IdEmpresa = empresa.idEmpresa;
            InsertarEmpresaUsuario(empresaInsertar.EmpresasUsuarios);
            InsertarEscalaCalificacion(empresa.idEmpresa);
            InsertarEscalaValoracionDefault(empresa.idEmpresa);
        }
Exemplo n.º 5
0
 private void btNuevo_Click(object sender, EventArgs e)
 {
     using (var input = new FrmInput())
     {
         input.Nombre = string.Empty;
         if (input.ShowDialog() != DialogResult.OK)
         {
             return;
         }
         var name = input.Nombre.Trim();
         if (string.IsNullOrEmpty(name))
         {
             MessageBox.Show("El nombre de la empresa no puede estar vacío.");
             return;
         }
         var empresa = data.GetAllEmpresas().FirstOrDefault(x => x.nombre == name);
         if (empresa != null)
         {
             MessageBox.Show("La empresa '" + name + "' ya existe.");
             return;
         }
         empresa = new empresa {
             nombre = name
         };
         data.AddEmpresa(empresa);
         data.SubmitChanges();
         LoadEmpresas();
     }
 }
Exemplo n.º 6
0
        public void afegirEmpresa(int cif)
        {
            empresa e = new empresa(cif);

            context.empresas.Add(e);
            context.SaveChanges();
        }
Exemplo n.º 7
0
        public static void EliminarEmpresa(short IdEmpresa, string Usuario)
        {
            try
            {
                RBVDataContext            contextoRBV                = new RBVDataContext();
                empresa                   empresaEliminar            = new empresa();
                empresaUsuario            empresaUsuarioEliminar     = new empresaUsuario();
                List <escalaCalificacion> escalaCalificacionElimicar = new List <escalaCalificacion>();
                EliminarEmpresaSector(IdEmpresa);

                empresaEliminar = contextoRBV.empresa.SingleOrDefault(p => p.idEmpresa == IdEmpresa);

                Guid idUsuario = contextoRBV.aspnet_Users.SingleOrDefault(p => p.UserName == Usuario).UserId;

                empresaUsuarioEliminar = contextoRBV.empresaUsuario.SingleOrDefault(p => p.idEmpresa == IdEmpresa && p.UserId == idUsuario);

                escalaCalificacionElimicar = contextoRBV.escalaCalificacion.Where(p => p.idEmpresa == IdEmpresa).ToList();

                contextoRBV.empresaUsuario.DeleteOnSubmit(empresaUsuarioEliminar);
                if (escalaCalificacionElimicar != null)
                {
                    contextoRBV.escalaCalificacion.DeleteAllOnSubmit(escalaCalificacionElimicar);
                }
                contextoRBV.empresa.DeleteOnSubmit(empresaEliminar);
                contextoRBV.SubmitChanges();
            }
            catch (SqlException Sqlex)
            {
                throw Sqlex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 8
0
        public ActionResult Index(int?id, int?paciente)
        {
            var audiometria = db.audiometria.Include(a => a.paciente);

            if (id != null)
            {
                audiometria = audiometria.Where(a => a.aud_paciente == id);
            }
            if (paciente != null)
            {
                audiometria = audiometria.Where(a => a.aud_paciente == paciente);
            }

            //if (!String.IsNullOrEmpty(fecha))
            //    audiometria = audiometria.Where(a => a.aud_fecha == fecha);
            if (User.IsInRole("paciente"))
            {
                string   cedula    = Convert.ToString(User.Identity.Name);
                paciente paciente_ = db.paciente.Where(p => p.pac_cedula == cedula).First();
                audiometria = audiometria.Where(a => a.aud_paciente == paciente_.pac_id);
            }
            if (User.IsInRole("empresa"))
            {
                string  cedula  = Convert.ToString(User.Identity.Name);
                empresa empresa = db.empresa.Where(e => e.emp_cedula == cedula).First();
                audiometria = audiometria.Where(a => a.paciente.pac_empresa == empresa.emp_id);
            }


            if (Request.IsAjaxRequest())
            {
                return(PartialView("Index_historia", audiometria.ToList()));
            }
            return(View(audiometria.ToList()));
        }
Exemplo n.º 9
0
        private empresa ObtenerEmpresas()
        {
            empresa empresa = new empresa();

            empresa.direccion      = txtDirecc.Text;
            empresa.email          = txtEmail.Text;
            empresa.id             = Convert.ToInt32(lblId.Text);
            empresa.logo           = lblLogo.Text;
            empresa.nombre         = txtNombreEmpre.Text;
            empresa.recaudador     = txtRecaudador.Text;
            empresa.ruc            = txtRuc.Text;
            empresa.telefono_fijo  = txtTelefonoFijo.Text;
            empresa.telefono_movil = txtTelefonoCel.Text;

            if (dropFactu.Text == "FACTURA")
            {
                empresa.facturacion = "F";
            }
            else if (dropFactu.Text == "RECIBO")
            {
                empresa.facturacion = "R";
            }


            return(empresa);
        }
Exemplo n.º 10
0
 public static empresa GetEmpresaByUserId(string userId = null)
 {
     try
     {
         //rgv
         using (var db = new NtLinkLocalServiceEntities())
         {
             usuarios_empresas ue = db.usuarios_empresas.Where(p => p.UserId == userId).FirstOrDefault();
             if (ue != null)
             {
                 empresa emp = db.empresa.Where(p => p.IdEmpresa == ue.IdEmpresa).FirstOrDefault();
                 return(emp);
             }
             return(null);
         }
     }
     catch (Exception eee)
     {
         Logger.Error(eee.Message);
         if (eee.InnerException != null)
         {
             Logger.Error(eee.InnerException);
         }
         return(null);
     }
 }
Exemplo n.º 11
0
        public bool Save(empresa e, byte[] logo)
        {
            try
            {
                using (var db = new NtLinkLocalServiceEntities())
                {
                    if (Validar(e))
                    {
                        if (e.IdEmpresa == 0)
                        {
                            if (db.empresa.Any(l => l.RFC.Equals(e.RFC) && l.idSistema == e.idSistema))
                            {
                                throw new FaultException("El RFC ya ha sido dato de alta");
                            }
                            db.empresa.AddObject(e);
                        }
                        else
                        {
                            db.empresa.FirstOrDefault(p => p.IdEmpresa == e.IdEmpresa);
                            db.empresa.ApplyCurrentValues(e);
                        }
                        db.SaveChanges();
                        CreaRutas(e.RFC);

                        string path = Path.Combine(ConfigurationManager.AppSettings["Resources"], e.RFC);
                        if (logo != null)
                        {
                            File.WriteAllBytes(Path.Combine(path, "Logo.png"), logo);
                        }
                        if (e.Baja != true)
                        {
                            throw new FaultException("El RFC ha sido dato de alta");//para que retorne algo si fue exitoso
                        }
                        else
                        {
                            throw new FaultException("El RFC ha sido dato de Baja");//para que retorne algo si fue exitoso
                        }
                        return(true);
                    }
                    return(false);
                }
            }
            catch (ApplicationException ae)
            {
                throw new FaultException(ae.Message);
            }
            catch (FaultException fe)
            {
                throw;
            }
            catch (Exception ee)
            {
                Logger.Error(ee.Message);
                if (ee.InnerException != null)
                {
                    Logger.Error(ee.InnerException.Message);
                }
                return(false);
            }
        }
        public async Task <IHttpActionResult> Postempresa(empresa empresa)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.empresa.Add(empresa);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (empresaExists(empresa.id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = empresa.id }, empresa));
        }
Exemplo n.º 13
0
        // POST /empresa/token/
        public HttpResponseMessage Post(string token, [FromBody] empresa param)
        {
            // Abre nova conexão
            using (painel_taxservices_dbContext _db = new painel_taxservices_dbContext())
            {
                tbLogAcessoUsuario log = new tbLogAcessoUsuario();
                try
                {
                    log = Bibliotecas.LogAcaoUsuario.New(token, JsonConvert.SerializeObject(param), "Post", _db);

                    HttpResponseMessage retorno = new HttpResponseMessage();
                    if (Permissoes.Autenticado(token, _db))
                    {
                        string dados = GatewayEmpresa.Add(token, param, _db);
                        log.codResposta = (int)HttpStatusCode.OK;
                        Bibliotecas.LogAcaoUsuario.Save(log, _db);
                        return(Request.CreateResponse <string>(HttpStatusCode.OK, dados));
                    }
                    else
                    {
                        log.codResposta = (int)HttpStatusCode.Unauthorized;
                        Bibliotecas.LogAcaoUsuario.Save(log, _db);
                        return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                    }
                }
                catch (Exception e)
                {
                    log.codResposta = (int)HttpStatusCode.InternalServerError;
                    log.msgErro     = e.Message;
                    Bibliotecas.LogAcaoUsuario.Save(log);
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
            }
        }
Exemplo n.º 14
0
        public static bool Add_Empresa(String[] valores, FileUpload fuLogoEmpresa)
        {
            string ruta = Utilidades.GuardarImagen(fuLogoEmpresa, valores[0], Paginas.Archivos_LogosEmpresas.Value);

            if (!ruta.Contains("ERR-"))
            {
                empresa nuevo = new empresa()
                {
                    nombre        = valores[0],
                    CodEmpresa    = valores[1],
                    nit           = valores[2],
                    email         = valores[3],
                    representante = valores[4],
                    movil         = valores[5],
                    fijo          = valores[6],
                    logo_url      = ruta,
                    id_arl        = Convert.ToInt32(valores[7]),
                    jornada       = Convert.ToInt32(valores[8])
                };

                return(CRUD.Add_Fila(nuevo));
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 15
0
        //-----------------------FUNCIONES DE CONSULTAR
        public static int Get_Max_Empresas()
        {
            GrupoLiEntities contexto = new GrupoLiEntities();
            var             consulta = new empresa();

            return(contexto.empresa.Max(x => x.id_empresa));
        }
Exemplo n.º 16
0
        public ActionResult Index(int?id, int?paciente)
        {
            var espirometria = db.espirometria.Include(e => e.paciente);

            if (id != null)
            {
                espirometria = espirometria.Where(e => e.esp_paciente == id);
            }
            if (paciente != null)
            {
                espirometria = espirometria.Where(e => e.esp_paciente == paciente);
            }

            if (User.IsInRole("paciente"))
            {
                string   cedula    = Convert.ToString(User.Identity.Name);
                paciente paciente_ = db.paciente.Where(p => p.pac_cedula == cedula).First();
                espirometria = espirometria.Where(e => e.esp_paciente == paciente_.pac_id);
            }
            if (User.IsInRole("empresa"))
            {
                string  cedula  = Convert.ToString(User.Identity.Name);
                empresa empresa = db.empresa.Where(e => e.emp_cedula == cedula).First();
                espirometria = espirometria.Where(e => e.paciente.pac_empresa == empresa.emp_id);
            }

            if (Request.IsAjaxRequest())
            {
                return(PartialView("Index_historia", espirometria.ToList()));
            }
            return(View(espirometria.ToList()));
        }
Exemplo n.º 17
0
        public JsonResult Grabar(int codigo, string nombre, string ruc, DateTime fecha_registro, string direccion
                                 , string rubro, int telefono, string detalle, string estado, string clave)
        {
            empresa empre = new empresa();
            bool    exito = true;

            empre.nombre         = nombre;
            empre.ruc            = ruc;
            empre.fecha_registro = fecha_registro;
            empre.direccion      = direccion;
            empre.rubro          = rubro;
            empre.telefono       = telefono;
            empre.detalle        = detalle;
            empre.estado         = estado;
            empre.clave          = clave;

            if (codigo == -1)
            {
                exito = BLEmpresa.Registrar(empre);
            }
            else
            {
                empre.id_empresa = codigo;
                exito            = BLEmpresa.Actualizar(empre);
            }

            return(Json(new { success = exito }));
        }
        public string TimbraRetencion(string userName, string password, string comprobante)
        {
            if (!this.ValidCredentials(userName, password))
            {
                throw new UnauthorizedAccessException("Invalid Ntlink internal user and password combination");
            }
            string result;

            try
            {
                CertificadorApps.Logger.Debug(userName);
                Retenciones ret     = TimbradoUtils.DesSerializarRetenciones(comprobante);
                empresa     empresa = NtLinkUsuarios.GetEmpresaByUserId(ret.Emisor.RFCEmisor);
                result = TimbradoUtils.TimbraRetencionString(comprobante, empresa, false, false);
            }
            catch (FaultException ex)
            {
                CertificadorApps.Logger.Error(ex);
                result = ex.Message;
            }
            catch (Exception ex2)
            {
                CertificadorApps.Logger.Error("Error al abrir el comprobante:" + comprobante, ex2);
                result = "Error al abrir el comprobante";
            }
            return(result);
        }
Exemplo n.º 19
0
        //    [FindRefreshDetectFilter]
        public ActionResult Index(int?saliendo)
        {
            string urlPrevia = "";
            string urlActual = System.Web.HttpContext.Current.Request.Url.ToString();

            if (System.Web.HttpContext.Current.Request.UrlReferrer != null)
            {
                urlPrevia = System.Web.HttpContext.Current.Request.UrlReferrer.ToString();
            }

            if (!Request.IsAuthenticated && saliendo == null && !urlPrevia.Equals("") && !urlPrevia.Equals(urlActual))
            {
                loghome log = db.loghome.Find(1);
                log.Visitantes = log.Visitantes + 1;
                db.SaveChanges();
            }
            if (Session["EmpresaId"] == null)
            {
                try {
                    Request.GetOwinContext().Authentication.SignOut();
                    //var accountController = new AccountController();
                    //accountController.LogOff();
                }
                catch (Exception ex) { }
            }

            // RouteData.Values["IsRefreshed"] = false;
            ViewBag.controlador = "Home";
            ViewBag.Login       = new LoginViewModel();
            empresa e = new empresa();

            return(View(e));
        }
Exemplo n.º 20
0
        protected void btGuardar_Click(object sender, EventArgs e)
        {
            //ScriptManager.RegisterStartupScript(this, typeof(Page), "openLoader", "showLoader('Registrando Empresa...')", true);
            //Thread.Sleep(10000);
            empresa objEmpresa = new empresa();

            if (ViewState["ID"] == null)
            {
                //si es nulo es un nuevo registro
                objEmpresa.embi_empresa_id        = 1;
                objEmpresa.emvc_nombre_empresa    = txtNombreEmpresa.Text;
                objEmpresa.emvc_sucursal_empresa  = txtSucursal.Text;
                objEmpresa.emvc_nit_empresa       = txtNit.Text;
                objEmpresa.emvc_direccion_empresa = txtDireccion.Text;
                objEmpresa.emvc_telefono_empresa  = txtTelefono.Text;
                objEmpresa.emvc_cel_empresa       = txtCelular.Text;
                objEmpresa.lxvc_ciudad            = cmbCiudad.SelectedValue;
                objEmpresa.emdt_fecha_insert      = DateTime.Now;
                objEmpresa.emvc_user_insert       = "";
                objEmpresa.emdt_fecha_modif       = DateTime.Now;
                objEmpresa.emvc_user_modif        = "";
                objEmpresa.embt_is_hidden         = false;
                _cCreaEmpresa.SaveObjEmpresa(objEmpresa);
            }
            else
            {
                //si no es nulo es actualizacion
            }



            MtdLoadInicial();
            ScriptManager.RegisterStartupScript(this, typeof(Page), "closeLoader", "hideLoader()", true);
            ScriptManager.RegisterStartupScript(this, typeof(Page), "response", "toastr.success('success')", true);
        }
Exemplo n.º 21
0
        protected void EditarRegistro(object sender, EventArgs e)
        {
            int idEmpresa = 0;

            idEmpresa = objUtilidades.descifrarCadena(Request.QueryString["id"]);

            string ruta = ViewState["url"].ToString();

            if (fuLogoEmpresa.HasFile)
            {
                ruta = Utilidades.GuardarImagen(fuLogoEmpresa, txtNombreEmpresa.Text, "~/archivos/LogosEmpresas/");
            }

            GrupoLiEntities contextoEdit = new GrupoLiEntities();
            empresa         Edit         = contextoEdit.empresa.SingleOrDefault(b => b.id_empresa == idEmpresa);

            if (Edit != null)
            {
                Edit.nombre        = txtNombreEmpresa.Text;
                Edit.CodEmpresa    = txtCodigoEmpresa.Text;
                Edit.nit           = txtNit.Text;
                Edit.email         = txtEmail.Text;
                Edit.representante = txtRepresentante.Text;
                Edit.movil         = txtTelMovil.Text;
                Edit.fijo          = txtTelFijo.Text;
                Edit.logo_url      = ruta;
                Edit.id_arl        = Convert.ToInt32(ddlArp.SelectedValue);
                Edit.jornada       = Convert.ToInt32(ddlJornada.SelectedValue);
            }

            ObjUsuario.Error = CRUD.Edit_Fila(contextoEdit);

            Modal.MostrarAlertaEdit(phAlerta, divAlerta, lbAlerta, ObjUsuario.Error, txtNombreEmpresa);
        }
Exemplo n.º 22
0
        public ActionResult Create([Bind(Include = "EmpresaId,Nit,Nombre,Direccion,Telefono,Estado,CreadoPor,FechaCreacion,ModificadoPor,FechaModificacion,LogoUrl,EmpEmail")] empresa empresa,
                                   HttpPostedFileBase LogoUrl, string controlador)
        {
            if (ModelState.IsValid)
            {
                if (this.validarImagen(LogoUrl, "AlcLogo"))
                {
                    db.empresa.Add(empresa);
                    db.SaveChanges();
                    this.guardarImagen(empresa, "LogoUrl", LogoUrl);
                    if (controlador.Equals("Home"))
                    {
                        ViewBag.tipo    = "bg-primary";
                        ViewBag.mensaje = "La Empresa " + empresa.Nombre + " fue creada exisotamente. Recibira al correo electronico las credenciales de autenticación para ingresar a nuestra Plataforma";
                        return(View("../Shared/Mensaje"));
                    }


                    return(RedirectToAction("Index"));
                }
            }
            if (controlador.Equals("Home"))
            {
                return(RedirectToAction("Index", "Home"));
            }
            return(View(empresa));
        }
Exemplo n.º 23
0
        public static empresa ValidarUsuarioSinSaldo(string rfc)
        {
            NtLinkEmpresa em      = new NtLinkEmpresa();
            empresa       empresa = em.GetByRfc(rfc);
            empresa       result;

            if (empresa == null)
            {
                TimbradoUtils.Logger.Info(rfc + " No encontrado");
                result = null;
            }
            else
            {
                if (empresa.Bloqueado)
                {
                    TimbradoUtils.Logger.Info(empresa.RFC + "-> Bloqueado");
                    throw new FaultException("El RFC del emisor se encuentra bloqueado, favor de ponerse en contacto con atención al cliente");
                }
                if (empresa.Baja)
                {
                    TimbradoUtils.Logger.Info(empresa.RFC + "-> Baja");
                    throw new FaultException("El RFC del emisor se encuentra dado de baja, favor de ponerse en contacto con atención a clientes");
                }
                NtLinkSistema nls     = new NtLinkSistema();
                Sistemas      sistema = nls.GetSistema((int)empresa.idSistema.Value);
                if (sistema.Bloqueado)
                {
                    TimbradoUtils.Logger.Info(sistema.Rfc + "-> Bloqueado");
                    throw new FaultException("El RFC del emisor se encuentra dado de baja, favor de ponerse en contacto con atención a clientes");
                }
                result = empresa;
            }
            return(result);
        }
Exemplo n.º 24
0
        public void guardarImagen(empresa empresa, string campo, HttpPostedFileBase imagen)
        {
            string path = @"~\Uploads\Logos\";

            switch (campo)
            {
            case "LogoUrl":
                // alcaldia.AlcLogo = "";
                if (imagen != null)
                {
                    var fileExt = System.IO.Path.GetExtension(imagen.FileName).Substring(1);
                    imagen.SaveAs(Server.MapPath(path + "LogoUrl" + empresa.EmpresaId.ToString() + "." + fileExt));
                    empresa.LogoUrl = "LogoUrl" + empresa.EmpresaId.ToString() + "." + fileExt;
                }
                break;
                //case "AlcPieDePagina":
                //    //  alcaldia.AlcPieDePagina = "";
                //    if (imagen != null)
                //    {
                //        var fileExt = System.IO.Path.GetExtension(imagen.FileName).Substring(1);
                //        imagen.SaveAs(Server.MapPath(path + "AlcPieDePagina" + alcaldia.AlcaldiaId.ToString() + "." + fileExt));
                //        alcaldia.AlcPieDePagina = "AlcPieDePagina" + alcaldia.AlcaldiaId.ToString() + "." + fileExt;
                //    }
                //    break;
            }

            db.Entry(empresa).State = EntityState.Modified;
            db.SaveChanges();
        }
Exemplo n.º 25
0
        public string ValidaCSD(empresa e, byte[] cert, byte[] llave, string passwordLlave)
        {
            try
            {
                using (var db = new NtLinkLocalServiceEntities())
                {
                    CreaRutas(e.RFC);
                    string path = Path.Combine(ConfigurationManager.AppSettings["Resources"], e.RFC);
                    if (!ValidaRfcEmisor(e.RFC, cert))
                    {
                        return("El RFC del emisor no corresponde con el certificado");
                    }
                    if (!ValidaCSDEmisor(cert))
                    {
                        return("El Certificado no es de tipo CSD");
                    }

                    string pathCer = Path.Combine(path, "Certs", "csd.cer");
                    string pathKey = Path.Combine(path, "Certs", "csd.key");
                    File.WriteAllBytes(pathCer, cert);
                    File.WriteAllBytes(pathKey, llave);
                    //bool result = CertUtil.CreaP12l(pathKey, pathCer, passwordLlave, Path.ChangeExtension(pathCer, ".p12"));
                    //if (result != false)
                    return("El Certificado CSD  es correcto");
                }
            }
            catch (Exception ee)
            {
                Logger.Error(ee);
                return("");
            }
            return("El Password de la llave no es correcta");
        }
Exemplo n.º 26
0
        public ActionResult RegistroEmpresas(Empresitas newempresa)
        {
            DataClasses1DataContext db = new DataClasses1DataContext();

            if (ModelState.IsValid)
            {
                cliente clien = new cliente();
                empresa emp   = new empresa();
                clien.nombre    = newempresa.nombr;
                clien.telefono  = newempresa.tel;
                clien.email     = newempresa.email;
                clien.direccion = newempresa.dir;
                clien.ciudad    = newempresa.ciu;
                clien.pais      = newempresa.pa;
                clien.estado    = newempresa.est;
                clien.contacto  = newempresa.cont;
                db.clientes.InsertOnSubmit(clien);
                db.SubmitChanges();
                int idE = db.clientes.OrderByDescending(b => b.id).First().id;
                emp.idCli       = idE;
                emp.nit         = newempresa.nit;
                emp.metodo_pago = newempresa.metodo;
                db.empresas.InsertOnSubmit(emp);
                db.SubmitChanges();
            }
            ViewBag.usu = (from a in db.clientes join j in db.empresas on a.id equals j.idCli select a).ToList();
            return(Redirect("/Cliente/RegistroEmpresas"));
        }
Exemplo n.º 27
0
        public string ConsultaCFDIRelacionadosRequest(string RfcPacEnviaSolicitud, string RfcReceptor, string RfcEmisor, string Uuid)
        {
            AccesoServicios ser           = new AccesoServicios();
            IList           uuidsCancelar = new List <string>();

            uuidsCancelar.Add(Uuid.ToUpper());
            string result;

            using (new NtLinkLocalServiceEntities())
            { string        path = "";
              NtLinkEmpresa nle  = new NtLinkEmpresa();
              if (!string.IsNullOrEmpty(RfcEmisor))
              {
                  empresa empresa = nle.GetByRfc(RfcEmisor);
                  SAT.CFDI.Cliente.Procesamiento.Encabezado encLMetadata2 = new SAT.CFDI.Cliente.Procesamiento.Encabezado(RfcEmisor, this.FechaHoy(), uuidsCancelar);
                  path = Path.Combine(ConfigurationManager.AppSettings["Resources"], RfcEmisor);
                  string pathCer = Path.Combine(path, "Certs", "csd.cer");
                  string pathKey = Path.Combine(path, "Certs", "csd.key");
                  string pass    = empresa.PassKey;
                  SAT.CFDI.Cliente.Procesamiento.ServicioRelacionados.SignatureType asignature = ser.Asignature(pathKey, encLMetadata2, pass, pathCer);
                  result = ser.ConsultaCFDIRelacionadosRequest(RfcPacEnviaSolicitud, RfcReceptor, RfcEmisor, Uuid, asignature);
              }
              else
              {
                  empresa empresa = nle.GetByRfc(RfcReceptor);
                  SAT.CFDI.Cliente.Procesamiento.Encabezado encLMetadata2 = new SAT.CFDI.Cliente.Procesamiento.Encabezado(RfcReceptor, this.FechaHoy(), uuidsCancelar);
                  path = Path.Combine(ConfigurationManager.AppSettings["Resources"], RfcReceptor);
                  string pathCer = Path.Combine(path, "Certs", "csd.cer");
                  string pathKey = Path.Combine(path, "Certs", "csd.key");
                  string pass    = empresa.PassKey;
                  SAT.CFDI.Cliente.Procesamiento.ServicioRelacionados.SignatureType asignature = ser.Asignature(pathKey, encLMetadata2, pass, pathCer);
                  result = ser.ConsultaCFDIRelacionadosRequest(RfcPacEnviaSolicitud, RfcReceptor, RfcEmisor, Uuid, asignature);
              } }
            return(result);
        }
Exemplo n.º 28
0
        /// <summary>
        /// Metodo que Obtiene un Dataset
        /// </summary>
        /// <param name="sp">string con el nombre del procedimiento almacenado</param>
        /// <param name="parametros">SqlParameter[] con la lista de parametros.</param>
        /// <param name="tablas">string[] con la lista de tablas.</param>
        public DataSet ObtenerDataSet(string strProcedimientoAlmacenado, SqlParameter[] astrParametros, string[] astrTablas)
        {
            DataSet        ds         = new DataSet();
            RBVDataContext obj        = new RBVDataContext();
            empresa        objempresa = obj.empresa.Where(p => p.idEmpresa == 1).SingleOrDefault();

            //obj.aspnet_Memberships.
            using (SqlConnection objConexion = clsProveedorConexion.ObtenerConexionSql())
            {
                SqlCommand objCommand = CrearComando(objConexion, strProcedimientoAlmacenado);
                foreach (SqlParameter parametro in astrParametros)
                {
                    objCommand.Parameters.Add(parametro);
                }
                SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand             = objCommand;
                da.SelectCommand.CommandType = CommandType.StoredProcedure;
                da.SelectCommand.Connection  = objConexion;
                objConexion.Open();

                for (int i = 0; i < astrTablas.Length; i++)
                {
                    string strTablaOrigen = "Table";
                    if (i > 0)
                    {
                        strTablaOrigen = strTablaOrigen + i;
                    }
                    da.TableMappings.Add(strTablaOrigen, astrTablas[i]);
                }

                da.Fill(ds);
            }
            return(ds);
        }
Exemplo n.º 29
0
        private void btnGuardarCambios_Click(object sender, EventArgs e)
        {
            try
            {
                empresa updateEmpresa = ObtenerEmpresas();

                //llenar el cwi y cwd cuando se editan datos
                List <usuario> usuario = repository.hacerLogin(Login.user, Login.password);
                updateEmpresa.cwd = DateTime.Now;
                updateEmpresa.cwi = usuario[0].id;

                var isModfy = repository.ModificarEmpresa(updateEmpresa);

                if (isModfy)
                {
                    MessageBox.Show("Cambios realizados con éxito");
                    panelEmpresa.Visible = false;
                    Mostrar();
                }
                else
                {
                    MessageBox.Show("No se Modificarion datos");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 30
0
        static public bool Actualizar(empresa empresa)
        {
            bool exito = true;

            try
            {
                using (var data = new ViajaMasEntities())
                {
                    empresa actual = data.empresa.Where(x => x.id_empresa == empresa.id_empresa).FirstOrDefault();
                    actual.nombre         = empresa.nombre;
                    actual.ruc            = empresa.ruc;
                    actual.fecha_registro = empresa.fecha_registro;
                    actual.direccion      = empresa.direccion;
                    actual.rubro          = empresa.rubro;
                    actual.telefono       = empresa.telefono;
                    actual.detalle        = empresa.detalle;
                    actual.estado         = empresa.estado;
                    actual.clave          = empresa.clave;
                    data.SaveChanges();
                }
            }
            catch
            {
                exito = false;
            }
            return(exito);
        }
Exemplo n.º 31
0
 public List<empresa> Filtrar(empresa empresa)
 {
     return repositoryEmpresa.ObterPorFiltros(b => (
         (empresa.ID == Guid.Empty || b.ID == empresa.ID) &&
         (empresa.razaoSocial == null || b.razaoSocial.ToUpper().Contains(empresa.razaoSocial)) &&
         (empresa.nomeFantasia == null || b.nomeFantasia.ToUpper().Contains(empresa.nomeFantasia)) &&
         (empresa.CNPJ == null || b.CNPJ.ToUpper().Contains(empresa.CNPJ)) &&
         (empresa.CPF == null || b.CPF.ToUpper().Contains(empresa.CPF)) &&
         (empresa.RG == null || b.RG.ToUpper().Contains(empresa.RG)) &&
         (empresa.IE == null || b.IE.ToUpper().Contains(empresa.IE)) &&
         (empresa.IM == null || b.IM.ToUpper().Contains(empresa.IM)) &&
         (empresa.numeroWhatsApp == null || b.numeroWhatsApp == empresa.numeroWhatsApp) &&
         (empresa.nomeWhatsApp == null || b.nomeWhatsApp == empresa.nomeWhatsApp) &&
         (empresa.senhaWhatsApp == null || b.senhaWhatsApp == empresa.senhaWhatsApp) &&
         (empresa.CNAEID == Guid.Empty || b.CNAEID == empresa.CNAEID)
         )).ToList();
 }
Exemplo n.º 32
0
 /// <summary>
 /// Create a new empresa object.
 /// </summary>
 /// <param name="idEmpresa">Initial value of idEmpresa.</param>
 /// <param name="nome">Initial value of nome.</param>
 /// <param name="cnpj">Initial value of cnpj.</param>
 /// <param name="del">Initial value of del.</param>
 public static empresa Createempresa(short idEmpresa, string nome, string cnpj, bool del)
 {
     empresa empresa = new empresa();
     empresa.idEmpresa = idEmpresa;
     empresa.nome = nome;
     empresa.cnpj = cnpj;
     empresa.del = del;
     return empresa;
 }
Exemplo n.º 33
0
 /// <summary>
 /// Deprecated Method for adding a new object to the empresa EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToempresa(empresa empresa)
 {
     base.AddObject("empresa", empresa);
 }
Exemplo n.º 34
0
        public Result Salvar(empresa empresa)
        {
            Result retorno = new Result();

            try
            {
                if (empresa.ID == Guid.Empty)
                {
                    empresa.ID = Guid.NewGuid();
                    repositoryEmpresa.Adicionar(empresa);
                }
                else
                {
                    repositoryEmpresa.Alterar(empresa);
                }

                context.SaveChanges();

                retorno.Ok("Cadastro realizado com sucesso.");
            }
            catch (Exception erro)
            {
                retorno.Erro(erro.Message);
            }

            return retorno;
        }
 public Result SalvarEmpresa(empresa empresa)
 {
     Result retorno = serviceEmpresa.Salvar(empresa);
     return retorno;
 }
 public List<empresa> FiltrarEmpresa(empresa empresa)
 {
     return serviceEmpresa.Filtrar(empresa);
 }
        public ActionResult regcliente(ReservaHab reser)
        {
            DataClasses1DataContext db = new DataClasses1DataContext();
            cliente cli = new cliente();
            cli.nombre = reser.cli.Nombre;
            cli.ciudad = reser.cli.Ciudad;
            cli.estado = reser.cli.Estadoo;
            cli.pais = reser.cli.pais;
            cli.nit = reser.cli.nit;
            cli.telefono = reser.cli.telefono;
            cli.direccion = reser.cli.direccion;
            cli.email = reser.cli.email;
            cli.comentarios = reser.cli.comentarios;

            db.clientes.InsertOnSubmit(cli);
            db.SubmitChanges();

            if (reser.tipocli == 1)
            {
                persona per = new persona();
                per.id = cli.id;
                per.ci = reser.per.ci;
                per.apellido = reser.per.apellido;/*
                string d = (reser.per.cumple).ToString();
                d = d.Substring(3, 3) + d.Substring(0, 3) + d.Substring(6, 4);
                per.cumpleaños = Convert.ToDateTime(d);*/
                per.cumpleaños = reser.per.cumple;
                per.pasaporte = reser.per.pasaporte;
                db.personas.InsertOnSubmit(per);
                db.SubmitChanges();
            }
            if (reser.tipocli == 2)
            {
                empresa empp = new empresa();
                empp.id = cli.id;
                empp.contacto = reser.emp.contacto;
                empp.metodopago = reser.emp.metodoPago;
                db.empresas.InsertOnSubmit(empp);
                db.SubmitChanges();
            }
            if (reser.tipocli == 3)
            {
                agencia agenn = new agencia();
                agenn.id = cli.id;
                agenn.contacto = reser.agen.contacto;
                db.agencias.InsertOnSubmit(agenn);
                db.SubmitChanges();
            }
            return View();
        }