示例#1
0
        private void BtnBuscar_Click(object sender, EventArgs e)
        {
            var listado = new List <Cargos>();


            if (txtCriterio.Text.Trim().Length > 0)
            {
                switch (cbFiltro.SelectedIndex)
                {
                case 0:    //Todo
                    listado = CargoBLL.GetList(p => true);
                    break;

                case 1:    //ID
                    int id = Convert.ToInt32(txtCriterio.Text);
                    listado = CargoBLL.GetList(p => p.CargoId == id);
                    break;

                case 2:    //Descripcion
                    listado = CargoBLL.GetList(p => p.Descripcion.Contains(txtCriterio.Text));
                    break;
                }
            }
            else
            {
                listado = CargoBLL.GetList(p => true);
            }

            dgvConsulta.DataSource = null;
            dgvConsulta.DataSource = listado;
        }
        private void GuardarButton_Click(object sender, EventArgs e)
        {
            Cargos cargos = BLL.CargoBLL.Buscar((int)IdnumericUpDown.Value);

            if (ValidarForm())
            {
                if (cargos == null)
                {
                    if (CargoBLL.Guardar(LlenaClase()))
                    {
                        MessageBox.Show("Guardado Con Exito");
                    }
                    else
                    {
                        MessageBox.Show("El Cagos No Se Guardo");
                    }
                    limpiar();
                }
                else
                {
                    if (CargoBLL.Editar(LlenaClase()))
                    {
                        MessageBox.Show("Modificado Con Exito");
                    }
                    else
                    {
                        MessageBox.Show("El Cargos No Se Modifico");
                    }
                }
            }
            else
            {
                MessageBox.Show("Faltan Datos");
            }
        }
示例#3
0
        public ActionResult GetCargosByIdDpto(int idDpto)
        {
            List <Cargo> objCargo   = CargoBLL.GetCargosByIdDpto(idDpto);
            SelectList   listCargos = new SelectList(objCargo, "pkCargo", "txtNombre");

            return(Json(listCargos));
        }
示例#4
0
        private void btnGravar_Click(object sender, EventArgs e)
        {
            try
            {
                Types.CargoType type = new Types.CargoType();
                type.Descricao      = txtDescricao.Text;
                type.IdDepartamento = Int32.Parse(cmbDepartamento.SelectedValue.ToString());

                CargoBLL itemBLL = new CargoBLL();
                if (txtID.Text == "")
                {
                    txtID.Text = Convert.ToString(itemBLL.insert(type));
                }
                else
                {
                    type.IdCargo = Convert.ToInt32(txtID.Text);
                    itemBLL.alterar(type);
                }
            }
            catch (Exception erro)
            {
                MessageBox.Show("Erro ao gravar. Mensagem: " +
                                erro.Message, "Erro", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
            findAll();
        }
示例#5
0
        private void form_CadUsuario_Load(object sender, EventArgs e)
        {
            this.alterarBotoes(1);

            ConexaoDAL conexao = new ConexaoDAL(DadosConexaoDAL.StringDeConexão);
            //cb cidade
            CidadeBLL cidbll = new CidadeBLL(conexao);

            usr_cidadeComboBox.DataSource    = cidbll.Pesquisar("");
            usr_cidadeComboBox.DisplayMember = "cid_descriçao";
            usr_cidadeComboBox.ValueMember   = "cid_id";
            //cb estado
            EstadoBLL estbll = new EstadoBLL(conexao);

            usr_estadoComboBox.DataSource    = estbll.Pesquisar("");
            usr_estadoComboBox.DisplayMember = "est_descriçao";
            usr_estadoComboBox.ValueMember   = "est_id";
            //cb cargo
            CargoBLL carbll = new CargoBLL(conexao);

            usr_cargoComboBox.DataSource    = carbll.Pesquisar("");
            usr_cargoComboBox.DisplayMember = "car_cargo";
            usr_cargoComboBox.ValueMember   = "car_id";

            this.LimpaTela();
        }
        private void ConsultaButton_Click(object sender, EventArgs e)
        {
            var listado = new List <Cargos>();

            if (CriteriotextBox.Text.Trim().Length > 0)
            {
                switch (FiltrocomboBox.Text)
                {
                case "Todo":
                    listado = CargoBLL.GetList(p => true);
                    break;

                case "Id":
                    int id = Convert.ToInt32(CriteriotextBox.Text);
                    listado = CargoBLL.GetList(p => p.CargoId == id);
                    break;

                case "Descripcion":
                    listado = CargoBLL.GetList(p => p.Descripcion.Contains(CriteriotextBox.Text));
                    break;
                }
            }
            else
            {
                listado = CargoBLL.GetList(p => true);
            }

            ConsultadataGridView.DataSource = null;
            ConsultadataGridView.DataSource = listado;
        }
示例#7
0
        private void LlenarComboBox()
        {
            BLL.CargoBLL Usuario = new BLL.CargoBLL();

            CargocomboBox.DataSource    = CargoBLL.GetList(c => true);
            CargocomboBox.ValueMember   = "CargoId";
            CargocomboBox.DisplayMember = "Descripcion";
        }
示例#8
0
        public ActionResult Edit(int id)
        {
            Cargo departamento = CargoBLL.GetCargoById(id);
            List <Departamento> listaEmpleados = DepartamentoBLL.SelectAll();

            ViewBag.DepartamentoPk = new SelectList(listaEmpleados, "pkDepartamento", "txtNombre");

            return(View(departamento));
        }
示例#9
0
        private void buttonBuscar_Click(object sender, EventArgs e)
        {
            Expression <Func <Cargos, bool> > filtro = a => true;
            int id;

            switch (FiltroComboBox.SelectedIndex)
            {
            case 0:    //Filtrando por ID
                id     = Convert.ToInt32(CriterioTextBox.Text);
                filtro = a => a.CargoId == id;
                break;
            }

            CargosConsultaDataGridView.DataSource = CargoBLL.GetList(filtro);
        }
示例#10
0
 public ActionResult Edit(Cargo departamento)
 {
     try
     {
         if (ModelState.IsValid)
         {
             CargoBLL.UpdateCargo(departamento);
             return(RedirectToAction("Index"));
         }
     }
     catch (DataException /* dex */)
     {
         //Log the error (uncomment dex variable name after DataException and add a line here to write a log.
         ModelState.AddModelError(string.Empty, "Unable to save changes. Try again, and if the problem persists contact your system administrator.");
     }
     return(View(departamento));
 }
示例#11
0
        //
        // GET: /Cargo/

        public ActionResult Index(string sortOrder, string currentFilter, string searchString, int?page)
        {
            IEnumerable <Cargo> listaCargo = CargoBLL.SelectAll();

            ViewBag.CurrentSort  = sortOrder;
            ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            ViewBag.DateSortParm = sortOrder == "Date" ? "date_desc" : "Date";

            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }
            ViewBag.CurrentFilter = searchString;

            var students = from s in listaCargo
                           select s;

            if (!String.IsNullOrEmpty(searchString))
            {
                students = students.Where(s => s.txtNombre.ToUpper().Contains(searchString.ToUpper()) ||
                                          s.fkDepartamento.ToString().ToUpper().Contains(searchString.ToUpper()));
            }
            switch (sortOrder)
            {
            case "name_desc":
                students = students.OrderByDescending(s => s.txtNombre);
                break;

            case "Date":
                students = students.OrderBy(s => s.fkDepartamento);
                break;

            case "date_desc":
                students = students.OrderByDescending(s => s.fkDepartamento);
                break;

            default:      // Name ascending
                students = students.OrderBy(s => s.txtNombre);
                break;
            }
            return(View(students.ToList <Cargo>()));
        }
示例#12
0
        private void NuevoButton_Click(object sender, EventArgs e)
        {
            MyErrorProvider.Clear();

            int id;

            int.TryParse(CargosIdnumericUpDown.Text, out id);

            Limpiar();

            if (CargoBLL.Eliminar(id))
            {
                MessageBox.Show("Eliminado", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MyErrorProvider.SetError(CargosIdnumericUpDown, "No se puede eliminar una persona que no existe");
            }
        }
        private void EliminarButton_Click(object sender, EventArgs e)
        {
            MyErrorProvider.Clear();

            int id;

            int.TryParse(CargoIdnumericUpDown.Text, out id);
            Limpiar();

            if (CargoBLL.Eliminar(id))
            {
                MessageBox.Show("Elimino el ID: " + id + "", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Dispose();
            }
            else
            {
                MyErrorProvider.SetError(CargoIdnumericUpDown, "Id no Existe");
            }
        }
示例#14
0
        private void BuscarButton_Click(object sender, EventArgs e)
        {
            int    id;
            Cargos cargos = new Cargos();

            int.TryParse(CargosIdnumericUpDown.Text, out id);

            Limpiar();

            cargos = CargoBLL.Buscar(id);

            if (cargos != null)
            {
                MessageBox.Show("Persona Encontrada");
                LlenarCampo(cargos);
            }
            else
            {
                MessageBox.Show("Persona no Encontrada");
            }
        }
示例#15
0
        private void btnExcluir_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Tem certeza que deseja excluir?", "Exclusão", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == System.Windows.Forms.DialogResult.Yes)
            {
                try
                {
                    Types.CargoType type = new Types.CargoType();
                    type.IdCargo = Convert.ToInt32(txtID.Text);

                    CargoBLL itemBLL = new CargoBLL();
                    itemBLL.excluir(type);
                }
                catch (Exception erro)
                {
                    MessageBox.Show("Erro ao excluir. Mensagem: " +
                                    erro.Message, "Erro", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                findAll();
                LimparCampos();
            }
        }
示例#16
0
        private void BtnGuardar_Click(object sender, EventArgs e)
        {
            Cargos cargos;
            bool   paso = false;

            if (!Validar())
            {
                return;
            }

            cargos = LlenarClase();
            Limpiar();

            //Determinar si es guardar o modificar
            if (Cargo.Value == 0)
            {
                paso = CargoBLL.Guardar(cargos);
            }
            else
            {
                if (!ExisteEnLaBaseDeDatos())
                {
                    MessageBox.Show("No se puede modificar el cargo que no existe", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                paso = CargoBLL.Modificar(cargos);
            }

            //Informar el resultado
            if (paso)
            {
                MessageBox.Show("Guardado!!", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("No fue posible guardar!!", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void ConsultaCargobutton_Click_1(object sender, EventArgs e)
        {
            var listado = new List <Cargos>();

            if (!Validar())
            {
                return;
            }

            if (CriterioCargoTextBox.Text.Trim().Length > 0)
            {
                switch (FiltroCargocomboBox.SelectedIndex)
                {
                case 0:
                    listado = CargoBLL.GetList(p => true);
                    break;

                case 1:     //ID
                    int id = Convert.ToInt32(CriterioCargoTextBox.Text);
                    listado = CargoBLL.GetList(p => p.CargoId == id);
                    break;

                case 2:    //Descripcion
                    listado = CargoBLL.GetList(p => p.Descripcion.Contains(CriterioCargoTextBox.Text));
                    break;
                }

                //listado = listado.Where(c => c.FechaIngreso.Date >= DesdeDateTimePicker.Value.Date && c.FechaIngreso.Date <= HastaDateTimePicker.Value.Date).ToList();
            }
            else
            {
                listado = CargoBLL.GetList(p => true);
            }

            ConsultaCargoDataGridView.DataSource = null;
            ConsultaCargoDataGridView.DataSource = listado;
        }
        private void GuardarButton_Click(object sender, EventArgs e)
        {
            Cargos cargo;
            bool   paso = false;

            if (!Validar())
            {
                return;
            }

            cargo = LlenarClase();
            Limpiar();

            if (CargoIdnumericUpDown.Value == 0)
            {
                paso = CargoBLL.Guardar(cargo);
            }
            else
            {
                if (!ExisteEnLaBaseDeDatos())
                {
                    MessageBox.Show("No se puede modificar una persona que no existe", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                paso = CargoBLL.Modificar(cargo);
            }

            if (paso)
            {
                MessageBox.Show("Guardado!!", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Dispose();
            }
            else
            {
                MessageBox.Show("Error al Guardar!!", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#19
0
        private bool ExisteEnLaBaseDeDatos()
        {
            Cargos cargos = CargoBLL.Buscar((int)CargosIdnumericUpDown.Value);

            return(cargos != null);
        }
示例#20
0
        private void BtnModificar_Click(object sender, EventArgs e)
        {
            Cargos cargos = new Cargos();

            CargoBLL.Modificar(cargos);
        }
示例#21
0
        private bool ExisteEnLaBaseDeDatos()
        {
            Cargos cargo = CargoBLL.Buscar((int)Cargo.Value);

            return(cargo != null);
        }
示例#22
0
        private void findAll()
        {
            CargoBLL bll = new CargoBLL();

            dataGridView1.DataSource = bll.select();
        }
示例#23
0
        public ViewResult Details(int id)
        {
            Cargo cargo = CargoBLL.GetCargoById(id);

            return(View(cargo));
        }
示例#24
0
 public ActionResult Create(Cargo cargo)
 {
     CargoBLL.InsertObjetoCargo(cargo);
     return(RedirectToAction("Index", "Cargo"));
 }