示例#1
0
        public static List<Pais> ConsultaPublicado()
        {
            //Creamos un objeto SQLcommand
            SqlCommand cmdConsulta = new SqlCommand(PaisSQLHelper.CONSULTA_PAIS_ACTIVO, DBConnection.Open());
            cmdConsulta.CommandType = CommandType.StoredProcedure;

            SqlDataReader reader = cmdConsulta.ExecuteReader();

            List<Pais> itemsPais = new List<Pais>();

            Pais pais = null;

            DBConnection.Open();
            while (reader.Read())
            {
                pais = new Pais();

                pais.Nombre = reader["nombre"].ToString();
                pais.Publicado = int.Parse(reader["publicado"].ToString());
                pais.Id = int.Parse(reader["id"].ToString());

                itemsPais.Add(pais);

            }
            DBConnection.Close(cmdConsulta.Connection);

            return itemsPais;
        }
示例#2
0
 // Construtor com PK
 public Estado(int codigo , Pais Country, string Name, string Initials)
 {
     Cod_Estado = codigo;
     Nome = Name;
     Sigla = Initials;
     Pais_Estado = Country.Cod_pais1;
 }
示例#3
0
 public bool Alter(Pais country)
 {
     try
     {
         DadosdoPais.Alterar(country);
         return true;
     }
     catch (Exception e)
     {
         throw e;
     }
 }
示例#4
0
 public bool Delete(Pais country)
 {
     try
     {
         DadosdoPais.Excluir(country);
         return true;
     }
     catch (Exception e)
     {
         throw e;
     }
 }
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            Pais pais = new Pais();
            pais.Nombre = txtNombre.Text;
            if (CheckPublicado.Checked)
            {
                pais.Publicado = 1;
            }
            else
            {
                pais.Publicado = 0;
            }

            try
            {
                PaisDAO paisDao = new PaisDAO();

                if (idPais != 0)//modificacion
                {

                    pais.Id = idPais;

                    if (paisDao.ModificarPais(pais))
                    {
                        lblMensaje.Text = "Se ha modificado correctamente";

                    }
                    else
                    {
                        lblMensaje.Text = "Error al tratar de modificar";

                    }

                }
                else {//es Alta de Pais
                    paisDao.Inserta(pais);
                    this.lblMensaje.Visible = true;
                    this.lblMensaje.Text = "Se ingreso correctamente el País";
                    txtNombre.Text = "";
                    if (CheckPublicado.Checked)
                    {
                        CheckPublicado.Checked = false;
                    }

                }

            }catch(Exception exe)
            {
                lblMensaje.Visible = true;
                lblMensaje.Text = "Error Mensaje:" + exe;
            }
        }
示例#6
0
 public bool Insert(string nome, string sigla)
 {
     Pais pais = new Pais(nome, sigla);
     try
     {
         DadosdoPais.Inserir(pais);
         return true;
     }
     catch (Exception e)
     {
         throw e;
     }
 }
示例#7
0
 protected void DeletePais(int idPais)
 {
     try
     {
         var Pais = new Pais();
         Pais.IDPais = idPais;
         Pais.Delete();
         GetPaiss();
     }
     catch (Exception err)
     {
         Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('" + FormatError.FormatMessageForJAlert(err.Message) + "')</script>");
     }
 }
示例#8
0
文件: Auxiliar.cs 项目: GeraElem/AEP
        public void AddPais(Pais pais)
        {
            try
            {
                using (var context = new AEPEntities())
                {
                    context.Pais.AddObject(pais);

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException.Message.Contains("23505"))
                    throw new Exception("Error: no puede asignar dos paises con el mismo nombre.");
            }
        }
示例#9
0
 public Pais Save(Pais entity)
 {
     using (var context = new RThomazDbEntities())
     {
         if (entity.PaisId == 0)
         {
             entity.DataCriacao = DateTime.Now;
             context.Pais.AddObject(entity);
         }
         else
         {
             context.CreateObjectSet<Pais>().Attach(entity);
             context.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified);
         }
         context.SaveChanges();
     }
     return entity;
 }
示例#10
0
    protected void btnSalvar_Click(object sender, EventArgs e)
    {
        var Pais = new Pais();
        try
        {
            if (txtId.Text != "")
            {
                Pais.IDPais = int.Parse(txtId.Text);
                Pais.Get();
            }

            Pais.Nome = txtNome.Text;

            Pais.Save();
            GetPais((int)Pais.IDPais);

            Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('Registro salvo.')</script>");
        }
        catch (Exception err)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('" + FormatError.FormatMessageForJAlert(err.Message) + "')</script>");
        }
    }
示例#11
0
        public static List<Pais> ConsultaPublicado(int usuarioID)
        {
            //Creamos un objeto SQLcommand
            SqlCommand cmdConsulta = new SqlCommand(PaisSQLHelper.CONSULTA_PAIS_ACTIVO, DBConnection.Open());
            cmdConsulta.CommandType = CommandType.StoredProcedure;

            //Declarando los Parametros
            SqlParameter[] parametros = new SqlParameter[1];

            //Asignando Valores
            parametros[0] = new SqlParameter(UsuarioSQLHelper.PARAMETRO_USUARIOID, SqlDbType.Int);
            parametros[0].Value = usuarioID;

            //Agregando nuestros parametros al command
            cmdConsulta.Parameters.AddRange(parametros);

            SqlDataReader reader = cmdConsulta.ExecuteReader();

            List<Pais> itemsPais = new List<Pais>();

            Pais pais = null;

            while (reader.Read())
            {
                pais = new Pais();

                pais.Nombre = reader["nombre"].ToString();
                pais.Publicado = int.Parse(reader["publicado"].ToString());
                pais.Id = int.Parse(reader["id"].ToString());

                itemsPais.Add(pais);

            }
            DBConnection.Close(cmdConsulta.Connection);

            return itemsPais;
        }
示例#12
0
        public async Task <Response <Empresa> > CreateAsync(Empresa modelo)
        {
            var response = new Response <Empresa>();

            response.IsSuccess = false;
            try
            {
                Empresa empresa = await db.Empresas.FirstOrDefaultAsync(e => e.ID_Empresa == modelo.ID_Empresa);

                Region region = await db.Regiones.FirstOrDefaultAsync(r => r.ID_Region == modelo.Region.ID_Region);

                modelo.Region = region;
                Comuna comuna = await db.Comunas.FirstOrDefaultAsync(co => co.ID_Comuna == modelo.Comuna.ID_Comuna);

                modelo.Comuna = comuna;
                Estado estado = await db.Estados.FirstOrDefaultAsync(e => e.ID_Estado == modelo.Estado.ID_Estado);

                modelo.Estado = estado;
                Pais pais = await db.Paises.FirstOrDefaultAsync(p => p.ID_Pais == modelo.Pais.ID_Pais);

                modelo.Pais = pais;
                Ciudad ciudad = await db.Ciudades.FirstOrDefaultAsync(ci => ci.ID_Ciudad == modelo.Ciudad.ID_Ciudad);

                modelo.Ciudad = ciudad;
                Tipo_empresa tipo_Empresa = await db.Tipo_Empresa.FirstOrDefaultAsync(te => te.ID_Tipo_Empresa == modelo.Tipo_Empresa.ID_Tipo_Empresa);

                modelo.Tipo_Empresa = tipo_Empresa;
                if (empresa == null)
                {
                    response.Message = "Debe proveer la información solicitada...";
                    return(response);
                }

                if (await db.Empresas.AsNoTracking().AnyAsync(e => e.ID_Empresa == modelo.ID_Empresa))
                {
                    response.Message = "Error el identificador ya existe...";
                    return(response);
                }

                if (await db.Empresas.AsNoTracking().AnyAsync(e => e.Rut.ToLower() == modelo.Rut.ToLower()))
                {
                    response.Message = "Error el registro ya existe...";
                    return(response);
                }
                //
                db.Add(empresa);
                await db.SaveChangesAsync();

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


                //
                response.IsSuccess = true;
                response.Result    = modelo;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
            }
            //
            return(response);
        }
示例#13
0
 public void Excluir(Pais pais)
 {
     new PaisDao(contexto).Excluir(pais);
 }
示例#14
0
 public void Update(Pais pais)
 {
     _context.Pais.Update(pais);
     _context.SaveChanges();
 }
        public ActionResult CreatePais(PaisViewModel model)
        {
            if (User == null || User.GetType().ToString() == "System.Security.Principal.GenericPrincipal")
                return RedirectToAction("Index", "Home");

            ViewBag.Title = Resources.TablasResource.CreatePaisPageTitle;
            ViewBag.PageHeader = Resources.TablasResource.CreatePaisHeaderPage;

            if (!ModelState.IsValid)
            {
                return View(model);
            }

            try {
                using (SeguricelEntities db = new SeguricelEntities())
                {
                    Pais Pais = new Pais
                    {
                        IdPais = model.Id,
                        Activo = model.Activo,
                        Nombre = model.Nombre,
                        Culture = model.Culture,
                        Ubicacion = DbGeography.FromText(string.Format("POINT({0} {1})", model.Longitud, model.Latitud))
                    };

                    db.Pais.Add(Pais);
                    db.SaveChanges();

                    ClasesVarias.AddBitacoraUsuario(db,
                       "País " + model.Nombre + " en condición de " + (model.Activo ? "Activo" : "Inactivo"),
                       190000003,
                       "Agregar");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return RedirectToAction("Pais");

        }
示例#16
0
 public Task <Pais> UpdateAsync(Pais element, object IdUsuario)
 {
     throw new NotImplementedException();
 }
示例#17
0
 protected void AlterarDadosPessoa(string email, string telefone, string celular, string observacao, string logradouro, int numero, string bairro, string complemento, string cep, string cidade, string unidadeFederativa, Pais pais)
 {
     Email             = email;
     Telefone          = telefone;
     Celular           = celular;
     Observacao        = observacao;
     Logradouro        = logradouro;
     Numero            = numero;
     Bairro            = bairro;
     Complemento       = complemento;
     Cep               = cep;
     Cidade            = cidade;
     UnidadeFederativa = unidadeFederativa;
     Pais              = pais;
 }
示例#18
0
        public void AlterarDadosPessoaJuridica(string razaoSocial, string nomeFantasia, string cnpj, string inscricaoEstadual, string inscricaoMunicipal, string responsavel, string email, string telefone, string celular, string observacao, string logradouro, int numero, string bairro, string complemento, string cep, string cidade, string unidadeFederativa, Pais pais)
        {
            RazaoSocial        = razaoSocial;
            NomeFantasia       = nomeFantasia;
            Cnpj               = cnpj;
            InscricaoEstadual  = inscricaoEstadual;
            InscricaoMunicipal = inscricaoMunicipal;
            Responsavel        = responsavel;

            AlterarDadosPessoa(email, telefone, celular, observacao, logradouro, numero, bairro, complemento, cep, cidade, unidadeFederativa, pais);
        }
示例#19
0
 public PessoaJuridica(string razaoSocial, string nomeFantasia, string cnpj, string inscricaoEstadual, string inscricaoMunicipal, string responsavel, string email, string telefone, string celular, string observacao, string logradouro, int numero, string bairro, string complemento, string cep, string cidade, string unidadeFederativa, Pais pais) : base(email, telefone, celular, observacao, logradouro, numero, bairro, complemento, cep, cidade, unidadeFederativa, pais)
 {
     RazaoSocial        = razaoSocial;
     NomeFantasia       = nomeFantasia;
     Cnpj               = cnpj.Trim().Replace(".", "").Replace("-", "").Replace("/", "");
     InscricaoEstadual  = inscricaoEstadual.Trim().Replace(".", "").Replace("-", "").Replace("/", "");
     InscricaoMunicipal = inscricaoMunicipal.Trim().Replace(".", "").Replace("-", "").Replace("/", "");
     Responsavel        = responsavel;
 }
示例#20
0
    public int[] statusBase;//Status dessa unidade sem nenhum equipamento nela

    public Unidade(int id, int idDaMordenizacao, int lvl, int upgradeLvl, int exp, string nome, int raridade, int desenvolvimentoRequerido, Classe classe, Pais nacionalidade, Alvos tipoDeAlvo, SonsDeAtaque tipoDeSom, int[] status, int maximoEquipamento, List <EquipamentoTipo> proibicoes)
    {
        this.idNoBancoDeDados = id;
        this.idDaMordenizacao = idDaMordenizacao;
        this.lvl                       = lvl;
        this.upgradeLvl                = upgradeLvl;
        this.experienciaAtual          = exp;
        this.nome                      = nome;
        this.raridade                  = raridade;
        this.desenvolvimentoRequerido  = desenvolvimentoRequerido;
        this.classe                    = classe;
        this.nacionalidade             = nacionalidade;
        this.tipoDeAlvo                = tipoDeAlvo;
        this.tipoDeSom                 = tipoDeSom;
        this.status                    = status;
        this.maximoDeEquipamentos      = maximoEquipamento;
        this.equipamentosNaoPermitidos = proibicoes;
        statusBase                     = new int[status.Length];
        this.status.CopyTo(statusBase, 0);
        calcularStatusComEquipamentoELevel();
        associarIconeDaClasse();
        //associarImagensDaNacao();
    }
示例#21
0
        /// <summary>
        /// Método de pesquisa de pais, retorna uma coleçao de pais
        /// </summary>
        /// <param name="nome"></param>
        /// <param name="codigo"></param>
        /// <param name="operadorNome"></param>
        /// <param name="operadorCodigo"></param>
        /// <param name="valorEntreNome"></param>
        /// <param name="valorEntreCodigo"></param>
        /// <returns></returns>
        public PaisCollection pesquisa(string nome, string codigo, string operadorNome, string operadorCodigo, string valorEntreNome, string valorEntreCodigo)
        {
            // string s = carregaPesquisa.query();
            DataTable      dataTable      = new DataTable();
            PaisCollection paisCollection = new PaisCollection();
            string         select         = "";
            string         ukey           = "";

            //verifico se não passa parametro executo select * from
            if (nome.Equals("") && codigo.Equals(""))
            {
                select = "select ukey, descricaoPais,codigoPais from tblPais";
            }
            else
            {
                criaString.addCampo(UKEY);
                criaString.addCampo(DESCRICAO_PAIS);
                criaString.addCampo(CODIGO_PAIS);
                //verifico se os campos não esta vazio
                if (!nome.Equals(""))
                {
                    //colcoar % no nome quando for like
                    switch (operadorNome)
                    {
                    case "1":
                        nome = nome + "%";
                        break;

                    case "6":
                        nome = "%" + nome + "%";
                        break;

                    case "8":
                        nome = "%" + nome;
                        break;
                    }
                }
                if (!codigo.Equals(""))
                {
                    //colocar "%' quando for like o operador 1,6,8
                    switch (operadorCodigo)
                    {
                    //iniciado por
                    case "1":
                        codigo = codigo + "%";
                        break;

                    case "6":
                        codigo = "%" + codigo + "%";
                        break;

                    case "8":
                        codigo = "%" + codigo;
                        break;
                    }
                }
                criaString.addWhere(DESCRICAO_PAIS, DESCRICAO_PAIS, operadorNome, valorEntreNome, nome);
                criaString.addWhere(CODIGO_PAIS, CODIGO_PAIS, operadorCodigo, valorEntreCodigo, codigo);
                select = criaString.select();
            }
            acessaBanco.limpaParametros();
            //teste de nomes de parametros pode ser aqui o erro
            acessaBanco.adicionaParametros("@" + DESCRICAO_PAIS, nome);
            acessaBanco.adicionaParametros("@" + CODIGO_PAIS, codigo);

            dataTable = acessaBanco.ExecutaConsulta(CommandType.Text, select);

            foreach (DataRow linha in dataTable.Rows)
            {
                Pais pais = new Pais();
                ukey        = Convert.ToString(linha["ukey"]);
                pais.Ukey   = Guid.Parse(ukey);
                pais.Nome   = Convert.ToString(linha["descricaoPais"]);
                pais.Codigo = Convert.ToString(linha["codigoPais"]);
                paisCollection.Add(pais);
            }
            return(paisCollection);
        }
示例#22
0
 public Companhia(string nome, Pais pais)
 {
     Nome   = nome;
     IdPais = pais.Id;
 }
示例#23
0
        // GET: api/Paises/5
        public Pais Get(int id)
        {
            Pais paisSelecionado = _dataContext.Paises.Where(p => p.Id == id).FirstOrDefault();

            return(paisSelecionado);
        }
示例#24
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                if (ValidaDados())
                {
                    Pais pais = paisDAO.FindByLand(ValPais.Text.ToString());
                    if (pais == null)
                    {
                        pais = new Pais();
                    }

                    if (ValIdioma.Text != "")
                    {
                        Idioma idioma = idiomaDAO.FindByLangu(ValIdioma.Text.ToString());
                        if (idioma != null)
                        {
                            pais.Idioma = idioma;
                        }
                    }

                    pais.Land    = ValPais.Text.ToString();
                    pais.PaisIso = ValCodIso.Text.ToString();
                    pais.Nome    = ValNome.Text.ToString();

                    if (pais.Id == 0)
                    {
                        paisDAO.Persist(pais);
                    }
                    else
                    {
                        paisDAO.Merge(pais);
                    }

                    this.Cursor = Cursors.Default;
                    var message = "Pais " + pais.Nome + " salvo com sucesso...";
                    this.principal.exibirMessage(actionOK, message, "S");

                    FormUtil.GetMessage(actionOK, message);
                    this.principal.HideExecucao();

                    if (pais.Id == 0)
                    {
                        ValPais.Focus();
                    }

                    if (pais.Id > 0)
                    {
                        ValNome.Focus();
                    }

                    this.PopulaData();
                }
                else
                {
                    this.Cursor = Cursors.Default;
                }
            }
            catch (Exception ex)
            {
                this.Cursor = Cursors.Default;

                MessageBoxEx.Show(this, ex.Message, "Erro Paises",
                                  MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            Usuario usuario = new Usuario();
            usuario.Usuarios = txtUsuario.Text;
            usuario.Nombre = txtNombre.Text;
            usuario.Password = txtPassword.Text;
            usuario.RolId = int.Parse(DropDawnRol.SelectedValue);

            if (CheckHabilitado.Checked)
            {
                usuario.Habilitado = 1;
            }
            else
            {
                usuario.Habilitado = 0;
            }
            int estado = 0;

            /***************************************/
            //Obtenemos los países que haya seleccionado

            int[] listaPaisess;
            int contador = 0;
            for (int i = 0; i < checkPaises.Items.Count; i++)
            {

                if (checkPaises.Items[i].Selected)
                {
                    contador++;

                }

            }

            listaPaisess = new int[contador];
            contador = 0;
            int posicion = 0;
            for (int i = 0; i < checkPaises.Items.Count; i++)
            {

                if (checkPaises.Items[i].Selected)
                {
                    // contador++;
                    listaPaisess[posicion] = int.Parse(checkPaises.Items[i].Value);
                    posicion++;
                }

            }
            /**************************************/
            UsuarioDAO altaUsuario = new UsuarioDAO();

            if (idUsuario != 0) {//es modificación
                usuario.Id = idUsuario;

                if (altaUsuario.ModificarUsuario(usuario, listaPaisess))
                {

                    lblMensaje.Text = "El Usuario se modificó correctamente";
                }
                else {
                    lblMensaje.Text = "Ocurrió un Error al tratar de modificar";
                }

            } else {
               // estado = altaUsuario.Inserta(usuario);
                if (usuario.RolId == 1) { //Es Administrador

                    List<Pais> listaPaises = new List<Pais>();
                    Pais listcheckPais = null;
                    for (int i = 0; i < checkPaises.Items.Count; i++)
                    {

                        if (checkPaises.Items[i].Selected)
                        {

                            //lblMensaje.Text += checkPaises.Items[i].Text + "<br>";
                            listcheckPais = new Pais();
                            listcheckPais.Nombre = checkPaises.Items[i].Text;
                            listcheckPais.Id = int.Parse(checkPaises.Items[i].Value);
                            listaPaises.Add(listcheckPais);
                        }

                    }

                        estado = altaUsuario.InsertaUserPais(usuario, listaPaises);

                }

                if (usuario.RolId == 2) { //Es Super Administrador y no le llevamos la lista de países
                    estado = altaUsuario.Inserta(usuario);
                }

                if (estado != 0)
                {
                    //se inserto correctamente
                    lblMensaje.Text = "El usuario se insertó correctamente";
                    limpiar();
                }
                if (estado == 0)
                {
                    //el usuario ya existe
                    lblMensaje.Text = "El usuario ya existe en el sistema";
                }
            }
        }
示例#26
0
        private void DataPais_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                Pais pais = paisDAO.FindByLand(DataPais.Rows[e.RowIndex].Cells[0].Value.ToString());

                if (pais != null)
                {
                    ValPais.Text   = pais.Land;
                    ValCodIso.Text = pais.PaisIso;
                    ValIdioma.Text = pais.Langu;
                    ValNome.Text   = pais.Nome;
                    if (pais.Idioma != null)
                    {
                        Idioma idioma = idiomaDAO.FindByID(pais.Idioma.Id);
                        if (idioma != null)
                        {
                            ValIdioma.Text = idioma.Langu;
                        }
                    }

                    splitPais.Panel1Collapsed = true;
                    splitPais.Panel2Collapsed = false;

                    if (this.IsEdit || this.IsInsert)
                    {
                        ValPais.Enabled   = true;
                        ValCodIso.Enabled = true;
                        ValIdioma.Enabled = true;
                        ValNome.Enabled   = true;

                        if (IsEdit)
                        {
                            BtnSave.Enabled   = true;
                            ValPais.Enabled   = false;
                            ValCodIso.Enabled = false;
                            BtnSave.Enabled   = true;
                            ValNome.Focus();
                        }
                        if (IsInsert)
                        {
                            BtnSave.Enabled = true;
                            ValPais.Focus();
                        }
                    }
                    else
                    {
                        ValPais.Enabled   = false;
                        ValCodIso.Enabled = false;
                        ValIdioma.Enabled = false;
                        ValNome.Enabled   = false;
                    }

                    BtnEdit.Visible   = false;
                    BtnVoltar.Visible = true;
                    BtnDelete.Enabled = false;
                    BtnNew.Enabled    = false;
                }
            }
            catch (Exception ex)
            {
                MessageBoxEx.Show(this, ex.Message, "Erro Paises",
                                  MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#27
0
        public Empresa getDetalhes(int id)
        {
            try
            {
                SQL = string.Format("SELECT id, ativo, cnpj, razao_social, fantasia, matriz, filial, ie, im, id_crt, id_segmento, " +
                                    "cep, id_pais, id_uf, id_cidade, bairro, logradouro, numero, complemento, " +
                                    "telefone, celular, contato, email, site, dt_cadastro, dt_alteracao " +
                                    "FROM empresa " +
                                    "WHERE id = '{0}'", id);
                DataSet ds = con.ConsultaSQL(SQL);
                Empresa e  = null;

                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    e = new Empresa();
                    DAO_Endereco daoEnd = new DAO_Endereco();

                    e.Id          = int.Parse(dr["id"].ToString());
                    e.ativo       = bool.Parse(dr["ativo"].ToString());
                    e.cnpj        = dr["cnpj"].ToString();
                    e.razaoSocial = dr["razao_social"].ToString();
                    e.fantasia    = dr["fantasia"].ToString();
                    e.matriz      = bool.Parse(dr["matriz"].ToString());
                    e.filial      = bool.Parse(dr["filial"].ToString());
                    e.ie          = dr["ie"].ToString();
                    e.im          = dr["im"].ToString();
                    e.crt         = int.Parse(dr["id_crt"].ToString());
                    e.segmento    = int.Parse(dr["id_segmento"].ToString());
                    e.cep         = dr["cep"].ToString();

                    e.pais.Id = int.Parse(dr["id_pais"].ToString());
                    Pais pa = daoEnd.getPaisID(e.pais.Id);
                    e.pais = pa;

                    e.uf.Id = int.Parse(dr["id_uf"].ToString());
                    UF uf = daoEnd.getEstadoID(e.uf.Id);
                    e.uf = uf;

                    e.cidade.Id = int.Parse(dr["id_cidade"].ToString());
                    Cidade cid = daoEnd.getCidadeID(e.cidade.Id);
                    e.cidade = cid;

                    e.bairro      = dr["bairro"].ToString();
                    e.logradouro  = dr["logradouro"].ToString();
                    e.numero      = Convert.ToInt32(dr["numero"].ToString());
                    e.complemento = dr["complemento"].ToString();
                    e.telefone    = long.Parse(dr["telefone"].ToString());
                    e.celular     = long.Parse(dr["celular"].ToString());
                    e.contato     = dr["contato"].ToString();
                    e.email       = dr["email"].ToString();
                    e.site        = dr["site"].ToString();
                    e.dtCadastro  = DateTime.Parse(dr["dtcadastro"].ToString());
                    e.dtAlteracao = DateTime.Parse(dr["dtalteracao"].ToString());
                }

                return(e);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
示例#28
0
 public void ExcluirPais(Pais pais)
 {
     dao.Delete(pais);
 }
示例#29
0
        public void Inserta(Pais pais)
        {
            SqlCommand cmdAgregarPais = new SqlCommand();
            // Indicamos sus parametro de CommandTExt y la Conexion. del Objeto Command
            cmdAgregarPais.CommandText = SQLHelpers.PaisSQLHelper.INSERTA_PAIS;

            cmdAgregarPais.CommandType = CommandType.StoredProcedure;
            cmdAgregarPais.Connection = DBConnection.Open();

            //Declarando los Parametros
            SqlParameter[] parametros = new SqlParameter[2];

            //Asignando Valores
            parametros[0] = new SqlParameter(PaisSQLHelper.PARAMETRO_NOMBRE, SqlDbType.NVarChar, 100);
            parametros[0].Value = pais.Nombre;

            parametros[1] = new SqlParameter(PaisSQLHelper.PARAMETRO_PUBLICADO, SqlDbType.Int);
            parametros[1].Value = Convert.ToInt32(pais.Publicado);

            //Agregando nuestros parametros al command
            cmdAgregarPais.Parameters.AddRange(parametros);

            //Ejecutamos el NonQuery
            cmdAgregarPais.ExecuteReader();

            // Cerramos la conexion
            DBConnection.Close(cmdAgregarPais.Connection);
        }
示例#30
0
 public static void Delete(Pais pais)
 {
     Delete(pais.Id);
 }
示例#31
0
        public bool ModificarPais(Pais pais)
        {
            bool Exito = false;
            try
            {
                SqlCommand cmdModificarPais = new SqlCommand();

                cmdModificarPais.CommandText = PaisSQLHelper.UPDATE_PAIS;
                cmdModificarPais.CommandType = CommandType.StoredProcedure;
                cmdModificarPais.Connection = DBConnection.Open();

                SqlParameter[] parametros = new SqlParameter[3];

                parametros[0] = new SqlParameter(PaisSQLHelper.PARAMETRO_ID, SqlDbType.Int);
                parametros[0].Value = pais.Id;

                parametros[1] = new SqlParameter(PaisSQLHelper.PARAMETRO_NOMBRE, SqlDbType.NVarChar, 100);
                parametros[1].Value = pais.Nombre;

                parametros[2] = new SqlParameter(PaisSQLHelper.PARAMETRO_PUBLICADO, SqlDbType.Int);
                parametros[2].Value = Convert.ToInt32(pais.Publicado);

                cmdModificarPais.Parameters.AddRange(parametros);
                cmdModificarPais.ExecuteReader();

                DBConnection.Close(cmdModificarPais.Connection);
                Exito = true;
            }
            catch (Exception exc)
            {
                Console.Write(exc);
                return false;
            }

            return Exito;
        }
        public async Task <IQueryable <Recomendacoe> > GetRecomendacoesByPaisAsync(string paisId)
        {
            Pais pais = await _context.Pais.FindAsync(paisId);

            return(_context.Recomendacoe.Include(r => r.Zona).Where(c => c.IdZona == pais.Id));
        }
示例#33
0
        public Pais ConsultaUnPais(int idPais)
        {
            Pais pais = new Pais();

            try
            {
                SqlCommand cmdConsultaPais = new SqlCommand();

                cmdConsultaPais.CommandText = PaisSQLHelper.CONSULTA_UN_PAIS;
                cmdConsultaPais.CommandType = CommandType.StoredProcedure;
                cmdConsultaPais.Connection = DBConnection.Open();

                SqlParameter[] parametros = new SqlParameter[1];

                parametros[0] = new SqlParameter(PaisSQLHelper.PARAMETRO_ID, SqlDbType.Int);
                parametros[0].Value = idPais;

                cmdConsultaPais.Parameters.AddRange(parametros);

                SqlDataReader drConsulta = cmdConsultaPais.ExecuteReader();

                while (drConsulta.Read())
                {
                    pais.Id = drConsulta.GetInt32(0);
                    pais.Nombre = drConsulta.GetString(1);
                    pais.Publicado = drConsulta.GetInt32(2);

                }

                DBConnection.Close(cmdConsultaPais.Connection);
            }
            catch (Exception exc)
            {
                Console.Write(exc);

            }
            return pais;
        }
示例#34
0
 public void Add(Pais pais)
 {
     _context.Pais.Add(pais);
     _context.SaveChanges();
 }
示例#35
0
 public List <Ciudad> ListarCiudadesPais(Pais UnPais)
 {
     return(FabricaPersistencia.getPersistenciaCiudad().ListarCiudadesPais(UnPais));
 }
示例#36
0
            /// <summary>
            /// Handle
            /// </summary>
            /// <param name="request"></param>
            /// <param name="cancellationToken"></param>
            /// <returns></returns>
            public override async Task <bool> Handle(BulkLocationsRequest request, CancellationToken cancellationToken)
            {
                (string[], string[][])csv = await BulkUtils.ReadCsvAsync(request.LocationsFile, cancellationToken).ConfigureAwait(false);


                string[]   headers = csv.Item1;
                string[][] data    = csv.Item2;
                if (!data.Any())
                {
                    return(false);
                }

                Localizacion.SetPropertyIndexes(headers);
                Area.SetPropertyIndexes(headers);
                Region.SetPropertyIndexes(headers);
                Pais.SetPropertyIndexes(headers);

                List <string> existentLocations = await repository.GetAll().Select(u => u.Nombre).ToListAsync().ConfigureAwait(false);

                List <Area> existentAreas = (await areaRepository.GetAll()
                                             .Select(a => new {
                    a.Region.IdPais,
                    Area = a
                }).ToListAsync().ConfigureAwait(false))
                                            .Select(x => {
                    var aNew    = x.Area;
                    aNew.IdPais = x.IdPais;
                    return(aNew);
                }).ToList();
                List <Region> existentRegions = await regionRepository.GetAll().ToListAsync().ConfigureAwait(false);

                List <Pais> existentPaises = await paisRepository.GetAll().ToListAsync().ConfigureAwait(false);

                List <Localizacion> newLocalizaciones = new List <Localizacion>();
                List <Area>         newAreas          = new List <Area>();
                List <Region>       newRegions        = new List <Region>();
                List <Pais>         newPaises         = new List <Pais>();

                int indexArea   = existentAreas.Max(p => p.Id);
                int indexRegion = existentRegions.Max(p => p.Id);
                int indexPais   = existentPaises.Max(p => p.Id);

                foreach (string[] dataRow in data)
                {
                    Localizacion newLocalizacion = new Localizacion(dataRow);
                    Area         newArea         = new Area(dataRow);
                    Region       newRegion       = new Region(dataRow);
                    Pais         newPais         = new Pais(dataRow);

                    if (!string.IsNullOrEmpty(newPais.Nombre))
                    {
                        if (existentPaises.Any(p => p.Nombre == newPais.Nombre))
                        {
                            newPais = existentPaises.Single(p => p.Nombre == newPais.Nombre);
                        }
                        else if (newPaises.Any(p => p.Nombre == newPais.Nombre))
                        {
                            newPais = newPaises.Single(p => p.Nombre == newPais.Nombre);
                        }
                        else
                        {
                            indexPais++;
                            newPais.Id             = indexPais;
                            newPais.LastAction     = "CREATE";
                            newPais.LastActionDate = DateTime.UtcNow;
                            newPaises.Add(newPais);
                        }

                        if (!string.IsNullOrEmpty(newRegion.Nombre))
                        {
                            if (existentRegions.Any(p => p.Nombre == newRegion.Nombre))
                            {
                                newRegion = existentRegions.Single(p => p.Nombre == newRegion.Nombre);
                            }
                            else if (newRegions.Any(p => p.Nombre == newRegion.Nombre))
                            {
                                newRegion = newRegions.Single(p => p.Nombre == newRegion.Nombre);
                            }
                            else
                            {
                                indexRegion++;
                                newRegion.Id             = indexRegion;
                                newRegion.IdPais         = newPais.Id;
                                newRegion.LastAction     = "CREATE";
                                newRegion.LastActionDate = DateTime.UtcNow;
                                newRegions.Add(newRegion);
                            }
                        }
                        else if (!string.IsNullOrEmpty(newArea.Nombre))
                        {
                            if (existentRegions.Any(p => p.Nombre == newArea.Nombre))
                            {
                                newRegion = existentRegions.Single(p => p.Nombre == newArea.Nombre);
                            }
                            else if (newRegions.Any(p => p.Nombre == newArea.Nombre))
                            {
                                newRegion = newRegions.Single(p => p.Nombre == newArea.Nombre);
                            }
                            else
                            {
                                indexRegion++;
                                newRegion.Id             = indexRegion;
                                newRegion.Nombre         = newArea.Nombre;
                                newRegion.IdPais         = newPais.Id;
                                newRegion.LastAction     = "CREATE";
                                newRegion.LastActionDate = DateTime.UtcNow;
                                newRegions.Add(newRegion);
                            }
                        }

                        if (!string.IsNullOrEmpty(newArea.Nombre))
                        {
                            if (existentAreas.Any(p => p.Nombre == newArea.Nombre && p.IdPais == newPais.Id))
                            {
                                newArea = existentAreas.Single(p => p.Nombre == newArea.Nombre && p.IdPais == newPais.Id);
                            }
                            else if (newAreas.Any(p => p.Nombre == newArea.Nombre && p.IdPais == newPais.Id))
                            {
                                newArea = newAreas.Single(p => p.Nombre == newArea.Nombre && p.IdPais == newPais.Id);
                            }
                            else
                            {
                                indexArea++;
                                newArea.Id             = indexArea;
                                newArea.IdRegion       = newRegion.Id;
                                newArea.IdPais         = newPais.Id;
                                newArea.LastAction     = "CREATE";
                                newArea.LastActionDate = DateTime.UtcNow;
                                newAreas.Add(newArea);
                            }
                        }
                    }

                    if (existentLocations.Contains(newLocalizacion.Nombre))
                    {
                        continue;
                    }

                    newLocalizacion.IdArea = null;
                    if (!string.IsNullOrEmpty(newArea.Nombre))
                    {
                        newLocalizacion.IdArea = newArea.Id;
                    }

                    newLocalizacion.LastAction     = "CREATE";
                    newLocalizacion.LastActionDate = DateTime.UtcNow;

                    newLocalizaciones.Add(newLocalizacion);
                }

                await paisRepository.BulkInsertAsync(newPaises).ConfigureAwait(false);

                await regionRepository.BulkInsertAsync(newRegions).ConfigureAwait(false);

                await areaRepository.BulkInsertAsync(newAreas).ConfigureAwait(false);

                await repository.BulkInsertAsync(newLocalizaciones).ConfigureAwait(false);

                //repository.AddRange(newLocalizaciones);
                //await repository.SaveChangesAsync().ConfigureAwait(false);

                return(true);
            }
示例#37
0
    private void GetPais(int idPais)
    {
        dvSalvarPais.Visible = true;
        dvListarPaiss.Visible = false;

        var Pais = new Pais();
        Pais.IDPais = idPais;
        Pais.Get();

        txtId.Text = Pais.IDPais.ToString();
        txtNome.Text = Pais.Nome.ToString();
    }
示例#38
0
        public async Task <Response <Empresa> > UpdateAsync(Empresa modelo)
        {
            var response = new Response <Empresa>();

            response.IsSuccess = false;
            try
            {
                Empresa empresa = await db.Empresas.FirstOrDefaultAsync(e => e.ID_Empresa == modelo.ID_Empresa);

                Region region = await db.Regiones.FirstOrDefaultAsync(r => r.ID_Region == modelo.Region.ID_Region);

                modelo.Region = region;
                Comuna comuna = await db.Comunas.FirstOrDefaultAsync(co => co.ID_Comuna == modelo.Comuna.ID_Comuna);

                modelo.Comuna = comuna;
                Estado estado = await db.Estados.FirstOrDefaultAsync(e => e.ID_Estado == modelo.Estado.ID_Estado);

                modelo.Estado = estado;
                Pais pais = await db.Paises.FirstOrDefaultAsync(p => p.ID_Pais == modelo.Pais.ID_Pais);

                modelo.Pais = pais;
                Ciudad ciudad = await db.Ciudades.FirstOrDefaultAsync(ci => ci.ID_Ciudad == modelo.Ciudad.ID_Ciudad);

                modelo.Ciudad = ciudad;
                Tipo_empresa tipo_Empresa = await db.Tipo_Empresa.FirstOrDefaultAsync(te => te.ID_Tipo_Empresa == modelo.Tipo_Empresa.ID_Tipo_Empresa);

                modelo.Tipo_Empresa = tipo_Empresa;
                if (empresa == null)
                {
                    response.Message = "Debe proveer la información solicitada...";
                    return(response);
                }

                if (await db.Empresas.AsNoTracking().AnyAsync(u => u.Rut.ToLower() == modelo.Rut.ToLower() && u.ID_Empresa != modelo.ID_Empresa))
                {
                    response.Message = "Error la descripcón ya existe...";
                    return(response);
                }

                //

                empresa.N_Empresa        = modelo.N_Empresa;
                empresa.Rut              = modelo.Rut;
                empresa.Giro             = modelo.Giro;
                empresa.Razon_Social     = modelo.Razon_Social;
                empresa.Observaciones    = modelo.Observaciones;
                empresa.Movil            = modelo.Movil;
                empresa.Telefono1        = modelo.Telefono1;
                empresa.Telefono2        = modelo.Telefono2;
                empresa.Direccion        = modelo.Direccion;
                empresa.Web              = modelo.Web;
                empresa.Direccion_Correo = modelo.Direccion_Correo;
                empresa.Ciudad           = ciudad;
                empresa.Comuna           = comuna;
                empresa.Region           = region;
                empresa.Pais             = pais;
                empresa.Estado           = estado;
                empresa.Tipo_Empresa     = tipo_Empresa;

                db.Empresas.Update(empresa);
                await db.SaveChangesAsync();

                db.Entry(empresa).State              = EntityState.Detached;
                db.Entry(empresa.Ciudad).State       = EntityState.Detached;
                db.Entry(empresa.Comuna).State       = EntityState.Detached;
                db.Entry(empresa.Region).State       = EntityState.Detached;
                db.Entry(empresa.Pais).State         = EntityState.Detached;
                db.Entry(empresa.Estado).State       = EntityState.Detached;
                db.Entry(empresa.Tipo_Empresa).State = EntityState.Detached;

                //
                response.IsSuccess = true;
                response.Result    = modelo;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
            }
            //
            return(response);
        }
示例#39
0
文件: Auxiliar.cs 项目: GeraElem/AEP
        public void UpdatePais(Pais pais)
        {
            using (var context = new AEPEntities())
            {
                Pais pais2 = context.Pais.First(i => i.PaisId == pais.PaisId);

                pais2.Descripcion = pais.Descripcion;

                context.SaveChanges();
            }
        }
示例#40
0
 /// <summary>
 /// CREATE COUNTRY
 /// </summary>
 /// <param name="pais"></param>
 public void CrearPais(Pais pais)
 {
 }
    private void cargar_DropDownList_PaisNacimiento()
    {
        DropDownList_PaisNacimiento.Items.Clear();

        Pais _pais = new Pais(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
        DataTable tablaPaises = _pais.ObtenerTodos();

        ListItem item = new ListItem("Seleccione...", "");
        DropDownList_PaisNacimiento.Items.Add(item);

        foreach (DataRow fila in tablaPaises.Rows)
        {
            item = new ListItem(fila["NOMBRE"].ToString(), fila["ID_PAIS"].ToString());
            DropDownList_PaisNacimiento.Items.Add(item);
        }

        DropDownList_PaisNacimiento.DataBind();
    }
示例#42
0
 // Construtor sem PK
 public Estado(Pais Country, string Name, string Initials)
 {
     Nome = Name;
     Sigla = Initials;
     Pais_Estado = Country.Cod_pais1;
 }
示例#43
0
 public PopScoutingAceptado()
 {
     Pais = new Pais {
         COUNTRY = "GUATEMALA"
     };
 }
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            if (idProducto != 0)
            { //Modificar

                Producto producto = new Producto();
                //producto.Foto = hiddenFoto.Value;
                //string ubicacion = null;
                Boolean fileOK = false;
                //String path = Server.MapPath("~/FotosProducto/");
                //string ruta = "/FotosProducto/";
                bool avanza = false;
                if (fileFoto.HasFile)
                {
                    String fileExtension =
                        System.IO.Path.GetExtension(fileFoto.FileName).ToLower();
                    String[] allowedExtensions = { ".gif", ".png", ".jpeg", ".jpg" };
                    for (int i = 0; i < allowedExtensions.Length; i++)
                    {
                        if (fileExtension == allowedExtensions[i])
                        {
                            fileOK = true;
                        }
                    }
                }

                if (fileFoto.HasFile && !fileOK)
                { //subio un archivo pero la extension es incorrecta
                    Label1.Text = "No se aceptar archivos de este tipo";
                    avanza = false;
                }
                else {
                    if (fileFoto.HasFile && fileOK)
                    {//subir el archivo
                        //string nombreArchivo = DateTime.Now.ToString("ddMMyyyyhhmmss") + fileFoto.FileName;
                        //ubicacion = path + nombreArchivo;

                        ////ubicacion = path + DateTime.Now.ToString("ddMMyyyyhhmmss") + fileFoto.FileName;
                        //fileFoto.PostedFile.SaveAs(ubicacion);
                        //producto.Foto = ruta + nombreArchivo;
                        avanza = true;
                    }
                    else {
                        avanza = true;
                    }
                }
                if (avanza)
                {
                    producto.Id = idProducto;
                    producto.Nombre = txtNombre.Text;
                    producto.Descripcion = txtDescripcion.Text;

                    HttpPostedFile ImgFile = fileFoto.PostedFile;
                    Byte[] byteImage = new Byte[fileFoto.PostedFile.ContentLength];
                    ImgFile.InputStream.Read(byteImage, 0, fileFoto.PostedFile.ContentLength);

                    producto.Foto = byteImage;
                    producto.PadecimientoId = int.Parse(DropDawnPadecimiento.SelectedValue);
                    if (CheckPublicado.Checked)
                    {
                        producto.Publicado = 1;
                    }
                    else
                    {
                        producto.Publicado = 0;
                    }

                    int[] listaPaises;
                    int contador = 0;
                    for (int i = 0; i < checkPaises.Items.Count; i++)
                    {

                        if (checkPaises.Items[i].Selected)
                        {
                            contador++;

                        }

                    }

                    listaPaises = new int[contador];
                    contador = 0;
                    int posicion = 0;
                    for (int i = 0; i < checkPaises.Items.Count; i++)
                    {

                        if (checkPaises.Items[i].Selected)
                        {
                            // contador++;
                            listaPaises[posicion] = int.Parse(checkPaises.Items[i].Value);
                            posicion++;
                        }

                    }

                    ProductoDAO bdevento = new ProductoDAO();

                    if (bdevento.ModificarProducto(producto, listaPaises, int.Parse(Session["id"].ToString()), int.Parse(Session["rol"].ToString())))
                    {
                        this.lblMensaje.Text = "Se modificó correctamente el Producto ID = " + producto.Id;
                    }
                    else
                        this.lblMensaje.Text = "Ocurrió un error al tratar de modificar el Producto";
                }

            }
            else {
                /**
                Verificamos que el usuario haya subido el archivo
                */
                //string ubicacion = null;
                Boolean fileOK = false;
                //String path = Server.MapPath("~/FotosProducto/");
                //string ruta = "/FotosProducto/";

                if (fileFoto.HasFile)
                {
                    String fileExtension =
                        System.IO.Path.GetExtension(fileFoto.FileName).ToLower();
                    String[] allowedExtensions = { ".gif", ".png", ".jpeg", ".jpg" };
                    for (int i = 0; i < allowedExtensions.Length; i++)
                    {
                        if (fileExtension == allowedExtensions[i])
                        {
                            fileOK = true;
                        }
                    }
                }

                if (fileOK)
                {
                    try
                    {
                        //string nombreArchivo = DateTime.Now.ToString("ddMMyyyyhhmmss") + fileFoto.FileName;
                        //ubicacion = path + nombreArchivo;

                        //ubicacion = path + DateTime.Now.ToString("ddMMyyyyhhmmss") + fileFoto.FileName;
                        //fileFoto.PostedFile.SaveAs(ubicacion);
                        //Label1.Text = "File uploaded!";

                        Producto producto = new Producto();
                        producto.Nombre = txtNombre.Text;
                        producto.Descripcion = txtDescripcion.Text;
                        //producto.Foto = ruta + nombreArchivo;
                        HttpPostedFile ImgFile = fileFoto.PostedFile;
                        Byte[] byteImage = new Byte[fileFoto.PostedFile.ContentLength];
                        ImgFile.InputStream.Read(byteImage, 0, fileFoto.PostedFile.ContentLength);

                        producto.Foto = byteImage;

                        producto.PadecimientoId = int.Parse(DropDawnPadecimiento.SelectedValue);
                        if (CheckPublicado.Checked)
                        {
                            producto.Publicado = 1;
                        }
                        else
                        {
                            producto.Publicado = 0;
                        }

                        try
                        {

                            this.lblMensaje.Visible = true;
                            List<Pais> listaPaises = new List<Pais>();
                            Pais listcheckPais = null;
                            for (int i = 0; i < checkPaises.Items.Count; i++)
                            {

                                if (checkPaises.Items[i].Selected)
                                {

                                    //lblMensaje.Text += checkPaises.Items[i].Text + "<br>";
                                    listcheckPais = new Pais();
                                    listcheckPais.Nombre = checkPaises.Items[i].Text;
                                    listcheckPais.Id = int.Parse(checkPaises.Items[i].Value);
                                    listaPaises.Add(listcheckPais);
                                }

                            }

                            int productoID = ProductoDAO.Inserta(producto, listaPaises,int.Parse(Session["id"].ToString()));

                            this.lblMensaje.Text = "Se ingreso correctamente el Producto ID = " + productoID;
                            this.resetControles();

                        }
                        catch (Exception exe)
                        {
                            this.lblMensaje.Visible = true;
                            this.lblMensaje.Text = "Error Mensaje:" + exe;
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.Write(ex);
                        //Label1.Text = "File could not be uploaded.";
                    }
                }
                else
                {
                    Label1.Text = "No se aceptan archivos de este tipo.";
                }
                /*Terminamos de verificar lo del archivo*/
            }
        }
示例#45
0
 public void CadastrarPais(Pais pais)
 {
     dao.Create(pais);
 }
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            if (idArticulo != 0)//es modificacion
            {
                Articulo articulo = new Articulo();
                //articulo.Foto = hiddenFoto.Value;
                //articulo.Documento = HiddenDoc.Value;

               // string ubicacionfoto = null;
                //string ubicaciondoc = null;
                bool fileOK = false;
                bool fileOK2 = false;
                //String path = Server.MapPath("~/FotosArticulo/");
                //string rutafotos = "/FotosArticulo/";
               // String path2 = Server.MapPath("~/DocArticulo/");
               // string rutaDoc = "/DocArticulo/";
                bool avanza = false;
                bool avanza2 = false;
                if (fileFoto.HasFile)
                {
                    String fileExtension =
                        System.IO.Path.GetExtension(fileFoto.FileName).ToLower();
                    String[] allowedExtensions = { ".gif", ".png", ".jpeg", ".jpg" };
                    for (int i = 0; i < allowedExtensions.Length; i++)
                    {
                        if (fileExtension == allowedExtensions[i])
                        {
                            fileOK = true;
                        }
                    }
                }

                if (fileFoto2.HasFile)
                {
                    String fileExtension2 = System.IO.Path.GetExtension(fileFoto2.FileName).ToLower();
                    String[] allowedExtensions2 = { ".pdf" };
                    for (int i = 0; i < allowedExtensions2.Length; i++)
                    {
                        if (fileExtension2 == allowedExtensions2[i])
                        {
                            fileOK2 = true;
                        }
                    }
                }

                if (fileFoto.HasFile && fileOK) {
                //subir archivo
                    //string nombreArchivo = DateTime.Now.ToString("ddMMyyyyhhmmss") + fileFoto.FileName;
                    //ubicacionfoto = path + nombreArchivo;
                    //fileFoto.PostedFile.SaveAs(ubicacionfoto);
                    //articulo.Foto = rutafotos + nombreArchivo;
                    avanza = true;
                }else{
                    if (fileFoto.HasFile && !fileOK)
                    {
                        avanza = false;
                    }
                    else {
                        avanza = true;
                    }
                }

                if (fileFoto2.HasFile && fileOK2)
                {
                    //subir archivo
                   // string nombreArchivo2 = DateTime.Now.ToString("ddMMyyyyhhmmss") + fileFoto2.FileName;
                    //ubicaciondoc = path2 + nombreArchivo2;
                    //fileFoto2.PostedFile.SaveAs(ubicaciondoc);
                    //articulo.Documento = rutaDoc + nombreArchivo2;

                    avanza2 = true;
                }
                else
                {
                    if (fileFoto2.HasFile && !fileOK2)
                    {
                        avanza2 = false;
                    }
                    else
                    {
                        avanza2 = true;
                    }
                }

                if (avanza && avanza2)
                {
                    //proceder a hacer la modificacion
                    articulo.Id = idArticulo;
                    articulo.Nombre = txtNombre.Text;
                    articulo.Descripcion = txtDescripcion.Text;
                    articulo.Autor = txtAutor.Text;
                    articulo.Fecha = txtFecha.Text;
                    articulo.CategoriaId = int.Parse(DropDawnCategoria.SelectedValue);

                    HttpPostedFile ImgFile = fileFoto.PostedFile;
                    Byte[] byteImage = new Byte[fileFoto.PostedFile.ContentLength];
                    ImgFile.InputStream.Read(byteImage, 0, fileFoto.PostedFile.ContentLength);
                    articulo.Foto = byteImage;

                    HttpPostedFile PdfFile = fileFoto2.PostedFile;
                    Byte[] bytePdf = new Byte[fileFoto2.PostedFile.ContentLength];
                    PdfFile.InputStream.Read(bytePdf, 0, fileFoto2.PostedFile.ContentLength);
                    articulo.Documento = bytePdf;

                    if (CheckPublicado.Checked)
                    {
                        articulo.Publicado = 1;
                    }
                    else
                    {
                        articulo.Publicado = 0;
                    }

                    this.lblMensaje.Visible = true;
                    int[] listaPaises;
                    int contador = 0;
                    for (int i = 0; i < checkPaises.Items.Count; i++)
                    {

                        if (checkPaises.Items[i].Selected)
                        {
                            contador++;

                        }

                    }

                    listaPaises = new int[contador];
                    contador = 0;
                    int posicion = 0;
                    for (int i = 0; i < checkPaises.Items.Count; i++)
                    {

                        if (checkPaises.Items[i].Selected)
                        {
                            // contador++;
                            listaPaises[posicion] = int.Parse(checkPaises.Items[i].Value);
                            posicion++;
                        }

                    }

                    try
                    {
                        ArticuloDAO daoModifica = new ArticuloDAO();

                        if (daoModifica.ModificarArticulo(articulo, listaPaises, int.Parse(Session["id"].ToString()), int.Parse(Session["rol"].ToString())))
                        {
                            this.lblMensaje.Text = "Se Modificó correctamente el Ártículo ID = " + idArticulo;
                        }
                        else
                            this.lblMensaje.Text = "Ocurrió un error al tratar de modificar el Artículo";
                    }
                    catch (Exception exc)
                    {
                        Response.Write("Ocurrió un error " + exc);
                    }
                }
                else {
                    if (!avanza) {
                        Label1.Text = "No se aceptan archivos de este tipo";
                    }
                    if (!avanza2) {
                        Label2.Text = "No se aceptan archivos de este tipo";
                    }
                }

            }
            else {
                /**
                Verificamos que el usuario haya subido el archivo
                */
                /*string ubicacionfoto = null;
                string ubicaciondoc = null;*/
                Boolean fileOK = false;
                Boolean fileOK2 = false;
                /*String path = Server.MapPath("~/FotosArticulo/");
                string rutafotos = "/FotosArticulo/";
                String path2 = Server.MapPath("~/DocArticulo/");
                string rutaDoc = "/DocArticulo/";*/

                if (fileFoto.HasFile && fileFoto2.HasFile)
                {
                    String fileExtension = System.IO.Path.GetExtension(fileFoto.FileName).ToLower();
                    String[] allowedExtensions = { ".gif", ".png", ".jpeg", ".jpg" };
                    for (int i = 0; i < allowedExtensions.Length; i++)
                    {
                        if (fileExtension == allowedExtensions[i])
                        {
                            fileOK = true;
                        }
                    }

                    String fileExtension2 = System.IO.Path.GetExtension(fileFoto2.FileName).ToLower();
                    String[] allowedExtensions2 = { ".pdf" };
                    for (int ii = 0; ii < allowedExtensions2.Length; ii++)
                    {
                        if (fileExtension2 == allowedExtensions2[ii])
                        {
                            fileOK2 = true;
                        }
                    }
                }

                if (fileOK && fileOK2)
                {
                    try
                    {
                        /*
                        string nombreArchivofoto = DateTime.Now.ToString("ddMMyyyyhhmmss") + fileFoto.FileName;
                        ubicacionfoto = path + nombreArchivofoto;

                        //ubicacion = path + DateTime.Now.ToString("ddMMyyyy") + fileFoto.FileName;
                        fileFoto.PostedFile.SaveAs(ubicacionfoto);
                        Label1.Text = "File uploaded!";

                        string nombreArchivoDoc = DateTime.Now.ToString("ddMMyyyyhhmmss") + fileFoto.FileName;
                        ubicaciondoc = path2 + nombreArchivoDoc;

                        fileFoto2.PostedFile.SaveAs(ubicaciondoc);
                        Label2.Text = "File uploaded!";*/
                        HttpPostedFile ImgFile = fileFoto.PostedFile;
                        Byte[] byteImage = new Byte[fileFoto.PostedFile.ContentLength];
                        ImgFile.InputStream.Read(byteImage, 0, fileFoto.PostedFile.ContentLength);

                        HttpPostedFile DocFile = fileFoto2.PostedFile;
                        Byte[] bytePdf = new Byte[fileFoto2.PostedFile.ContentLength];
                        DocFile.InputStream.Read(bytePdf, 0, fileFoto2.PostedFile.ContentLength);

                        Articulo articulo = new Articulo();
                        articulo.Nombre = txtNombre.Text;
                        articulo.Descripcion = txtDescripcion.Text;
                        articulo.Autor = txtAutor.Text;
                        articulo.Fecha = txtFecha.Text;
                        articulo.CategoriaId = int.Parse(DropDawnCategoria.SelectedValue);
                        articulo.Foto = byteImage;
                        articulo.Documento = bytePdf;

                        if (CheckPublicado.Checked)
                        {
                            articulo.Publicado = 1;
                        }
                        else
                        {
                            articulo.Publicado = 0;
                        }

                        try
                        {

                            this.lblMensaje.Visible = true;
                            List<Pais> listaPaises = new List<Pais>();
                            Pais listcheckPais = null;
                            for (int i = 0; i < checkPaises.Items.Count; i++)
                            {

                                if (checkPaises.Items[i].Selected)
                                {

                                    //lblMensaje.Text += checkPaises.Items[i].Text + "<br>";
                                    listcheckPais = new Pais();
                                    listcheckPais.Nombre = checkPaises.Items[i].Text;
                                    listcheckPais.Id = int.Parse(checkPaises.Items[i].Value);
                                    listaPaises.Add(listcheckPais);
                                }

                            }

                            int articuloID = ArticuloDAO.Inserta(articulo, listaPaises, int.Parse(Session["id"].ToString()));

                            this.lblMensaje.Text = "Se ingreso correctamente el Artículo ID = " + articuloID;
                            this.resetControles();
                            //checkPaises.Items.Clear();
                            //this.cargaPaises();

                        }
                        catch (Exception exe)
                        {
                            this.lblMensaje.Visible = true;
                            this.lblMensaje.Text = "Error Mensaje:" + exe;
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.Write(ex);
                        Label1.Text = "File could not be uploaded.";
                        Label2.Text = "File could not be uploaded.";
                    }
                }
                else
                {
                    Label1.Text = "Cannot accept files of this type.";
                    Label2.Text = "Cannot accept files of this type.";
                }
                /*Terminamos de verificar lo del archivo*/
            }
        }
示例#47
0
        public bool ModificarUsuario(Usuario usuario, int[] paisesElegidos)
        {
            bool Exito = false;
            try
            {
                SqlCommand cmdModificarPais = new SqlCommand();
                if (usuario.Password != null && usuario.Password != "")
                {
                    string encriptada = Encriptacion.encriptar(usuario.Password);
                    cmdModificarPais.CommandText = UsuarioSQLHelper.UPDATE_USUARIO_PASSWORD;

                    SqlParameter[] parametros = new SqlParameter[5];

                    parametros[0] = new SqlParameter(UsuarioSQLHelper.PARAMETRO_USUARIOID, SqlDbType.Int);
                    parametros[0].Value = usuario.Id;

                    parametros[1] = new SqlParameter(UsuarioSQLHelper.PARAMETRO_PASSWORD, SqlDbType.NVarChar, 100);
                    parametros[1].Value = encriptada;

                    parametros[2] = new SqlParameter(UsuarioSQLHelper.PARAMETRO_ROL_ID, SqlDbType.Int);
                    parametros[2].Value = usuario.RolId;

                    parametros[3] = new SqlParameter(UsuarioSQLHelper.PARAMETRO_NOMBRE, SqlDbType.NVarChar, 200);
                    parametros[3].Value = usuario.Nombre;

                    parametros[4] = new SqlParameter(UsuarioSQLHelper.PARAMETRO_HABILITADO, SqlDbType.Int);
                    parametros[4].Value = usuario.Habilitado;

                    cmdModificarPais.Parameters.AddRange(parametros);
                }
                else
                {
                    cmdModificarPais.CommandText = UsuarioSQLHelper.UPDATE_USUARIO;
                    SqlParameter[] parametros = new SqlParameter[4];

                    parametros[0] = new SqlParameter(UsuarioSQLHelper.PARAMETRO_USUARIOID, SqlDbType.Int);
                    parametros[0].Value = usuario.Id;

                    parametros[1] = new SqlParameter(UsuarioSQLHelper.PARAMETRO_ROL_ID, SqlDbType.Int);
                    parametros[1].Value = usuario.RolId;

                    parametros[2] = new SqlParameter(UsuarioSQLHelper.PARAMETRO_NOMBRE, SqlDbType.NVarChar, 200);
                    parametros[2].Value = usuario.Nombre;

                    parametros[3] = new SqlParameter(UsuarioSQLHelper.PARAMETRO_HABILITADO, SqlDbType.Int);
                    parametros[3].Value = usuario.Habilitado;

                    cmdModificarPais.Parameters.AddRange(parametros);
                }
                cmdModificarPais.CommandType = CommandType.StoredProcedure;
                cmdModificarPais.Connection = DBConnection.Open();

                cmdModificarPais.ExecuteReader();

                DBConnection.Close(cmdModificarPais.Connection);
                if (usuario.RolId == 2)
                {
                    this.DeleteUserPais(usuario.Id);
                }
                else {//Si es Administrador actualizar Países

                    List<int> paisesActivos = ConsultaUsuarioPais(usuario.Id);
                    //paisesElegidos
                    if (paisesActivos.Count == 0)
                    {//era Super Administrador y no tiene paises activos
                        List<Pais> paisNuevo = new List<Pais>();
                        Pais paisagr = null;
                        foreach (int eleg1 in paisesElegidos)
                        {

                                paisagr = new Pais();
                                paisagr.Id = eleg1;
                                paisNuevo.Add(paisagr);

                        }

                        InsertaUserPais(usuario, paisNuevo);

                    }
                    else {
                        //checar los paises seleccionados vs los que tengo registrados
                        //los que no esten en los seleccionados y en los registrados si a esos eliminarlos
                        int[] arrpaisesActivos = new int[paisesActivos.ToArray().Length];
                        int contpa = 0;

                        foreach (int pa in paisesActivos)
                        {
                            arrpaisesActivos[contpa] = pa;
                            contpa++;
                        }

                        List<Pais> paisNuevo = new List<Pais>();
                        Pais paisagr = null;

                        foreach (int eleg1 in paisesElegidos)
                        {
                            bool agrega = false;
                            foreach (int act2 in arrpaisesActivos)
                            {
                                if (eleg1 == act2)
                                {
                                    agrega = false;
                                    break;
                                }
                                else
                                {
                                    agrega = true;
                                }

                            }
                            if (agrega)
                            {
                                paisagr = new Pais();
                                paisagr.Id = eleg1;
                                paisNuevo.Add(paisagr);
                            }
                        }

                        InsertaUserPais(usuario, paisNuevo);

                        foreach (int act in arrpaisesActivos)
                        {
                            bool elimina = false;
                            foreach (int eleg in paisesElegidos)
                            {
                                if (eleg == act)
                                {
                                    elimina = false;
                                    break;
                                }
                                else
                                {
                                    elimina = true;
                                }

                            }
                            if (elimina) { EliminarUsuarioPais(act); }
                        }
                    }

                }
                Exito = true;
            }
            catch (Exception exc)
            {
                Console.Write(exc);
                return false;
            }

            return Exito;
        }
示例#48
0
 public void SetPais(Pais pais)
 {
     this.pais = pais;
 }
示例#49
0
 public void EditarPais(Pais pais)
 {
     dao.Update(pais);
 }
示例#50
0
 public void ActualizarPais(Pais pais)
 {
     _db.Update(pais);
 }
示例#51
0
 public void InsertarPais(Pais pais)
 {
     _db.Insert(pais);
 }
示例#52
0
        public bool ModificarProducto(Producto producto, int[] paisesElegidos, int usuarioID, int rolID)
        {
            bool Exito = false;

            SqlCommand cmdModificar = new SqlCommand();

            cmdModificar.CommandText = ProductoSQLHelper.UPDATE_PRODUCTO;
            cmdModificar.CommandType = CommandType.StoredProcedure;
            cmdModificar.Connection = DBConnection.Open();

            SqlParameter[] parametros = new SqlParameter[6];

            parametros[0] = new SqlParameter(ProductoSQLHelper.PARAMETRO_ID, SqlDbType.Int);
            parametros[0].Value = producto.Id;

            parametros[1] = new SqlParameter(ProductoSQLHelper.PARAMETRO_NOMBRE, SqlDbType.NVarChar, 100);
            parametros[1].Value = producto.Nombre;

            parametros[2] = new SqlParameter(ProductoSQLHelper.PARAMETRO_DESCRIPCION, SqlDbType.NVarChar);
            parametros[2].Value = producto.Descripcion;

            parametros[3] = new SqlParameter(ProductoSQLHelper.PARAMETRO_PADECIMIENTO_ID, SqlDbType.Int);
            parametros[3].Value = Convert.ToInt32(producto.PadecimientoId);

            parametros[4] = new SqlParameter(ProductoSQLHelper.PARAMETRO_FOTO, SqlDbType.VarBinary, 7000);
            parametros[4].Value = producto.Foto;

            parametros[5] = new SqlParameter(ProductoSQLHelper.PARAMETRO_PUBLICADO, SqlDbType.Int);
            parametros[5].Value = Convert.ToInt32(producto.Publicado);

            cmdModificar.Parameters.AddRange(parametros);
            cmdModificar.ExecuteReader();

            DBConnection.Close(cmdModificar.Connection);

            List<int> paisesActivos = ConsultaProductoPais(producto.Id, usuarioID, rolID);
            //paisesElegidos

            //checar los paises seleccionados vs los que tengo registrados
            //los que no esten en los seleccionados y en los registrados si a esos eliminarlos
            int[] arrpaisesActivos = new int[paisesActivos.ToArray().Length];
            int contpa = 0;

            foreach (int pa in paisesActivos)
            {
                arrpaisesActivos[contpa] = pa;
                contpa++;
            }

            List<Pais> paisNuevo = new List<Pais>();
            Pais paisagr = null;

            foreach (int eleg1 in paisesElegidos)
            {
                bool agrega = false;
                foreach (int act2 in arrpaisesActivos)
                {
                    if (eleg1 == act2)
                    {
                        agrega = false;
                        break;
                    }
                    else
                    {
                        agrega = true;
                    }

                }
                if (agrega)
                {
                    paisagr = new Pais();
                    paisagr.Id = eleg1;
                    paisNuevo.Add(paisagr);
                }
            }

            ProductoDAO.InsertaProductoPais(producto.Id, paisNuevo);

            foreach (int act in arrpaisesActivos)
            {
                bool elimina = false;
                foreach (int eleg in paisesElegidos)
                {
                    if (eleg == act)
                    {
                        elimina = false;
                        break;
                    }
                    else
                    {
                        elimina = true;
                    }

                }
                if (elimina) { EliminarProductoPais(act); }
            }

            Exito = true;

            return Exito;
        }
示例#53
0
        //Se rellenan todos los campos con los datos del pedido seleccionado
        private void rellenarCampos()
        {
            if (this.tempPedido.Editable)
            {
                //Pedido
                lblNumero.Text = tempPedido.IdPedido.ToString();
                for (int i = 0; i < clientes.Count(); i++)
                {
                    if (this.tempPedido.IdCliente == clientes[i].IdCliente)
                    {
                        pickerCliente.SelectedIndex = i;
                    }
                }
                switch (this.tempPedido.Estado)
                {
                case "Pendiente":
                    pickerEstado.SelectedIndex = 0;
                    break;

                case "Enviado":
                    pickerEstado.SelectedIndex = 1;
                    break;

                case "Entregado":
                    pickerEstado.SelectedIndex = 2;
                    break;

                case "Anulado":
                    pickerEstado.SelectedIndex = 3;
                    break;
                }

                dateFechaPedido.Date   = this.tempPedido.FechaPedido;
                dateFechaEntrega.Date  = this.tempPedido.FechaEntrega;
                txtGastosEnvio.Text    = this.tempPedido.GastosEnvio.ToString();
                switchPagado.IsToggled = this.tempPedido.Pagado;
            }
            else
            {
                pickerCliente.IsVisible     = false;
                pickerEstado.IsVisible      = false;
                dateFechaPedido.IsVisible   = false;
                dateFechaEntrega.IsVisible  = false;
                txtGastosEnvio.IsVisible    = false;
                imgAddDetalle.IsVisible     = false;
                btnGuardar.IsVisible        = false;
                btnGuardarDetalle.IsVisible = false;

                lblCliente.IsVisible      = true;
                lblEstado.IsVisible       = true;
                lblFecha.IsVisible        = true;
                lblFechaEntrega.IsVisible = true;
                lblGastosEnvio.IsVisible  = true;

                lblNumero.Text = tempPedido.IdPedido.ToString();
                foreach (Cliente cli in clientes)
                {
                    if (cli.IdCliente == this.tempPedido.IdCliente)
                    {
                        lblCliente.Text = cli.RazonSocial;
                    }
                }
                lblEstado.Text         = this.tempPedido.Estado;
                lblFecha.Text          = this.tempPedido.FechaPedido.ToString("dd/MM/yyyy");
                lblFechaEntrega.Text   = this.tempPedido.FechaEntrega.ToString("dd/MM/yyyy");
                lblGastosEnvio.Text    = this.tempPedido.GastosEnvio.ToString();
                switchPagado.IsToggled = this.tempPedido.Pagado;

                btnEliminar.BackgroundColor = Color.FromHex("#3AAFA9");
                btnEliminar.Text            = "Cancelar";
            }

            //Domicilio
            lblCalle.Text = tempDomicilio.Calle + " " + tempDomicilio.Numero.ToString();
            using (var cLocalidad = new ControladorLocalidad())
            {
                Localidad localidad = cLocalidad.FindById(tempDomicilio.IdLocalidad);
                lblLocalidad.Text = localidad.Denominacion;

                using (var cProvincia = new ControladorProvincia())
                {
                    Provincia provincia = cProvincia.FindById(localidad.IdProvincia);
                    lblProvincia.Text = provincia.Denominacion;

                    using (var cPais = new ControladorPais())
                    {
                        Pais pais = cPais.FindById(provincia.IdPais);
                        lblPais.Text = pais.Denominacion;
                    }
                }
            }

            //Totales
            lblSubTotal.Text = this.tempPedido.Subtotal.ToString();
            lblTotal.Text    = this.tempPedido.Total.ToString();
        }
        protected void Guardar_Click(object sender, EventArgs e)
        {
            //string ubicacion = null;
            Boolean fileOK = false;
               // String path = Server.MapPath("~/FotosEvento/");
            //string ruta = "/FotosEvento/";

            HttpPostedFile ImgFile = fileFoto.PostedFile;
            Byte[] byteImage = new Byte[fileFoto.PostedFile.ContentLength];
            ImgFile.InputStream.Read(byteImage, 0, fileFoto.PostedFile.ContentLength);

            /**
             Verificamos que el usuario haya subido el archivo
             */
            if (idEvento != 0)//es modificacion
            {
                Evento evento = new Evento();
                evento.Id = idEvento;
                evento.Nombre = txtNombre.Text;
                evento.Descripcion = txtDescripcion.Text;
                evento.FechaInicio = txtFechaInicio.Text;
                evento.FechaFinal = txtFechaFin.Text;
                evento.Lugar = txtLugar.Text;
                evento.Dirigido = txtDirigido.Text;
                //evento.Foto = ubicacion;
                if (CheckPublicado.Checked)
                {
                    evento.Publicado = 1;
                }
                else
                {
                    evento.Publicado = 0;
                }

                if (fileFoto.HasFile)
                {
                    String fileExtension = System.IO.Path.GetExtension(fileFoto.FileName).ToLower();
                    String[] allowedExtensions = { ".gif", ".png", ".jpeg", ".jpg" };
                    for (int i = 0; i < allowedExtensions.Length; i++)
                    {
                        if (fileExtension == allowedExtensions[i])
                        {
                            fileOK = true;
                        }
                    }

                    if (fileFoto.HasFile && fileOK)
                    {
                        evento.Foto = byteImage;
                        /*string nombreArchivo = DateTime.Now.ToString("ddMMyyyyhhmmss") + fileFoto.FileName;
                        ubicacion = path + nombreArchivo;

                        fileFoto.PostedFile.SaveAs(ubicacion);
                        Label1.Text = "File uploaded!";*/
                        //evento.Foto = ruta + nombreArchivo;
                    }
                    else {
                        //evento.Foto = hiddenFoto.Value;
                    }
                }
                else {
                   // evento.Foto = hiddenFoto.Value;
                }

                int[] listaPaises;
                int contador = 0;
                for (int i = 0; i < checkPaises.Items.Count; i++)
                {

                    if (checkPaises.Items[i].Selected)
                    {
                        contador++;

                    }

                }

                listaPaises = new int[contador];
                contador = 0;
                int posicion = 0;
                for (int i = 0; i < checkPaises.Items.Count; i++)
                {

                    if (checkPaises.Items[i].Selected)
                    {
                       // contador++;
                        listaPaises[posicion] = int.Parse(checkPaises.Items[i].Value);
                        posicion++;
                    }

                }

                EventoDAO bdevento = new EventoDAO();

                if (bdevento.ModificarEvento(evento, listaPaises, int.Parse(Session["id"].ToString()), int.Parse(Session["rol"].ToString())))
                {
                    this.lblMensaje.Text = "Se modificó correctamente el Evento ID = " + evento.Id;
                }else
                    this.lblMensaje.Text = "Ocurrió un error al tratar de modificar el Evento";

            }
            else
            {//Si es Alta de Evento

                if (fileFoto.HasFile)
                {
                    String fileExtension =
                        System.IO.Path.GetExtension(fileFoto.FileName).ToLower();
                    String[] allowedExtensions = { ".gif", ".png", ".jpeg", ".jpg" };
                    for (int i = 0; i < allowedExtensions.Length; i++)
                    {
                        if (fileExtension == allowedExtensions[i])
                        {
                            fileOK = true;
                        }
                    }
                }

                if (fileOK)
                {
                    try
                    {
                       /* string nombreArchivo = DateTime.Now.ToString("ddMMyyyyhhmmss") + fileFoto.FileName;
                        ubicacion = path + nombreArchivo;*/

                        //fileFoto.PostedFile.SaveAs(ubicacion);
                        //Label1.Text = "File uploaded!";

                        Evento evento = new Evento();
                        evento.Nombre = txtNombre.Text;
                        evento.Descripcion = txtDescripcion.Text;
                        evento.FechaInicio = txtFechaInicio.Text;
                        evento.FechaFinal = txtFechaFin.Text;
                        evento.Lugar = txtLugar.Text;
                        evento.Dirigido = txtDirigido.Text;
                        //evento.Foto = ruta + nombreArchivo;
                        evento.Foto = byteImage;
                        if (CheckPublicado.Checked)
                        {
                            evento.Publicado = 1;
                        }
                        else
                        {
                            evento.Publicado = 0;
                        }

                        try
                        {

                            this.lblMensaje.Visible = true;
                            List<Pais> listaPaises = new List<Pais>();
                            Pais listcheckPais = null;
                            for (int i = 0; i < checkPaises.Items.Count; i++)
                            {

                                if (checkPaises.Items[i].Selected)
                                {

                                    //lblMensaje.Text += checkPaises.Items[i].Text + "<br>";
                                    listcheckPais = new Pais();
                                    listcheckPais.Nombre = checkPaises.Items[i].Text;
                                    listcheckPais.Id = int.Parse(checkPaises.Items[i].Value);
                                    listaPaises.Add(listcheckPais);
                                }

                            }

                            int eventoID = EventoDAO.Inserta(evento, listaPaises, int.Parse(Session["id"].ToString()));

                            this.lblMensaje.Text = "Se ingreso correctamente el Evento ID = " + eventoID;
                            this.resetControles();
                            //checkPaises.Items.Clear();
                            //this.cargaPaises();

                        }
                        catch (Exception exe)
                        {
                            this.lblMensaje.Visible = true;
                            this.lblMensaje.Text = "Error Mensaje:" + exe;
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.Write(ex);
                        Label1.Text = "File could not be uploaded.";
                    }
                }
                else
                {
                    Label1.Text = "Cannot accept files of this type.";
                }
                /*Terminamos de verificar lo del archivo*/
            }
        }
示例#55
0
 protected Pessoa(string email, string telefone, string celular, string observacao, string logradouro, int numero, string bairro, string complemento, string cep, string cidade, string unidadeFederativa, Pais pais)
 {
     Codigo            = Guid.NewGuid();
     Email             = email;
     Telefone          = telefone;
     Celular           = celular;
     Observacao        = observacao;
     DataCadastro      = DateTime.Now;
     Logradouro        = logradouro;
     Numero            = numero;
     Bairro            = bairro;
     Complemento       = complemento;
     Cep               = cep;
     Cidade            = cidade;
     UnidadeFederativa = unidadeFederativa;
     Pais              = pais;
 }
示例#56
0
        public bool ModificarArticulo(Articulo articulo, int[] paisesElegidos,int usuarioID, int rolID)
        {
            bool Exito = false;

            SqlCommand cmdModificar = new SqlCommand();

            cmdModificar.CommandText = ArticuloSQLHelper.UPDATE_ARTICULO;
            cmdModificar.CommandType = CommandType.StoredProcedure;
            cmdModificar.Connection = DBConnection.Open();

            SqlParameter[] parametros = new SqlParameter[9];

            parametros[0] = new SqlParameter(ArticuloSQLHelper.PARAMETRO_ARTICULOID, SqlDbType.Int);
            parametros[0].Value = articulo.Id;

            parametros[1] = new SqlParameter(ArticuloSQLHelper.PARAMETRO_NOMBRE, SqlDbType.NVarChar, 100);
            parametros[1].Value = articulo.Nombre;

            parametros[2] = new SqlParameter(ArticuloSQLHelper.PARAMETRO_DESCRIPCION, SqlDbType.NVarChar);
            parametros[2].Value = articulo.Descripcion;

            parametros[3] = new SqlParameter(ArticuloSQLHelper.PARAMETRO_AUTOR, SqlDbType.NVarChar, 150);
            parametros[3].Value = articulo.Autor;
            //parametros[2].Value = Convert.ToDateTime("17/10/2012");

            parametros[4] = new SqlParameter(ArticuloSQLHelper.PARAMETRO_FECHA, SqlDbType.DateTime);
            parametros[4].Value = Convert.ToDateTime(articulo.Fecha);
            //parametros[3].Value = Convert.ToDateTime("20/10/2012");

            parametros[5] = new SqlParameter(ArticuloSQLHelper.PARAMETRO_CATEGORIAID, SqlDbType.Int);
            parametros[5].Value = Convert.ToInt32(articulo.CategoriaId);

            parametros[6] = new SqlParameter(ArticuloSQLHelper.PARAMETRO_FOTO, SqlDbType.VarBinary, 7000);
            parametros[6].Value = articulo.Foto;

            parametros[7] = new SqlParameter(ArticuloSQLHelper.PARAMETRO_DOCUMENTO, SqlDbType.VarBinary, 7000);
            parametros[7].Value = articulo.Documento;

            parametros[8] = new SqlParameter(ArticuloSQLHelper.PARAMETRO_PUBLICADO, SqlDbType.Int);
            parametros[8].Value = Convert.ToInt32(articulo.Publicado);

            cmdModificar.Parameters.AddRange(parametros);
            cmdModificar.ExecuteReader();

            DBConnection.Close(cmdModificar.Connection);

            List<int> paisesActivos = ConsultaArticuloPais(articulo.Id,usuarioID, rolID);
            //paisesElegidos

            //checar los paises seleccionados vs los que tengo registrados
            //los que no esten en los seleccionados y en los registrados si a esos eliminarlos
            int[] arrpaisesActivos = new int[paisesActivos.ToArray().Length];
            int contpa = 0;

            foreach (int pa in paisesActivos)
            {
                arrpaisesActivos[contpa] = pa;
                contpa++;
            }

            List<Pais> paisNuevo = new List<Pais>();
            Pais paisagr = null;

            foreach (int eleg1 in paisesElegidos)
            {
                bool agrega = false;
                foreach (int act2 in arrpaisesActivos)
                {
                    if (eleg1 == act2)
                    {
                        agrega = false;
                        break;
                    }
                    else
                    {
                        agrega = true;
                    }

                }
                if (agrega)
                {
                    paisagr = new Pais();
                    paisagr.Id = eleg1;
                    paisNuevo.Add(paisagr);
                }
            }

            ArticuloDAO.InsertaArticuloPais(articulo.Id, paisNuevo);

            foreach (int act in arrpaisesActivos)
            {
                bool elimina = false;
                foreach (int eleg in paisesElegidos)
                {
                    if (eleg == act)
                    {
                        elimina = false;
                        break;
                    }
                    else
                    {
                        elimina = true;
                    }

                }
                if (elimina) { EliminarArticuloPais(act); }
            }

            Exito = true;

            return Exito;
        }
示例#57
0
        public bool ModificarEvento(Evento evento, int[] paisesElegidos, int usuarioID, int rolID)
        {
            bool Exito = false;

            SqlCommand cmdModificar = new SqlCommand();

            cmdModificar.CommandText = EventoSQLHelper.UPDATE_EVENTO;
            cmdModificar.CommandType = CommandType.StoredProcedure;
            cmdModificar.Connection = DBConnection.Open();

            SqlParameter[] parametros = new SqlParameter[9];

            parametros[0] = new SqlParameter(EventoSQLHelper.PARAMETRO_ID, SqlDbType.Int);
            parametros[0].Value = evento.Id;

            parametros[1] = new SqlParameter(EventoSQLHelper.PARAMETRO_NOMBRE, SqlDbType.NVarChar, 100);
            parametros[1].Value = evento.Nombre;

            parametros[2] = new SqlParameter(EventoSQLHelper.PARAMETRO_DESCRIPCION, SqlDbType.NVarChar);
            parametros[2].Value = evento.Descripcion;

            parametros[3] = new SqlParameter(EventoSQLHelper.PARAMETRO_FECHAINICIO, SqlDbType.DateTime);
            parametros[3].Value = Convert.ToDateTime(evento.FechaInicio);

            parametros[4] = new SqlParameter(EventoSQLHelper.PARAMETRO_FECHAFIN, SqlDbType.DateTime);
            parametros[4].Value = Convert.ToDateTime(evento.FechaFinal);

            parametros[5] = new SqlParameter(EventoSQLHelper.PARAMETRO_LUGAR, SqlDbType.NVarChar, 150);
            parametros[5].Value = evento.Lugar;

            parametros[6] = new SqlParameter(EventoSQLHelper.PARAMETRO_DIRIGIDO, SqlDbType.NVarChar, 150);
            parametros[6].Value = evento.Dirigido;

            parametros[7] = new SqlParameter(EventoSQLHelper.PARAMETRO_FOTO, SqlDbType.VarBinary, 7000);
            parametros[7].Value = evento.Foto;

            parametros[8] = new SqlParameter(EventoSQLHelper.PARAMETRO_PUBLICADO, SqlDbType.Int);
            parametros[8].Value = Convert.ToInt32(evento.Publicado);

            cmdModificar.Parameters.AddRange(parametros);
            cmdModificar.ExecuteReader();

            DBConnection.Close(cmdModificar.Connection);

            List<int> paisesActivos = ConsultaEventoPais(evento.Id,usuarioID, rolID);
            //paisesElegidos

            //checar los paises seleccionados vs los que tengo registrados
            //los que no esten en los seleccionados y en los registrados si a esos eliminarlos
            int[] arrpaisesActivos = new int[paisesActivos.ToArray().Length];
            int contpa = 0;

            foreach(int pa in paisesActivos){
                arrpaisesActivos[contpa] = pa;
                contpa++;
            }

            List<Pais> paisNuevo = new List<Pais>();
            Pais paisagr = null;

            foreach (int eleg1 in paisesElegidos)
            {
                bool agrega = false;
                foreach (int act2 in arrpaisesActivos)
                {
                    if (eleg1 == act2)
                    {
                        agrega = false;
                        break;
                    }
                    else
                    {
                        agrega = true;
                    }

                }
                if (agrega) {
                    paisagr = new Pais();
                    paisagr.Id = eleg1;
                    paisNuevo.Add(paisagr);
                }
            }

            EventoDAO.InsertaEventoPais(evento.Id, paisNuevo);

            foreach (int act in arrpaisesActivos)
            {
               bool elimina = false;
                foreach (int eleg in paisesElegidos)
                {
                    if (eleg == act)
                    {
                        elimina = false;
                        break;
                    }
                    else {
                        elimina = true;
                    }

                }
                if (elimina) { EliminarEventoPais(act); }
            }

            //los que no esten en los registrados pero si en los seleccionados registrarlos ocmo uno nuevo

            Exito = true;

            return Exito;
        }