示例#1
0
        public CargoDTO Alterar(CargoDTO dto)
        {
            try
            {
                BaseDados.ComandText = "stp_RH_CARGO_ALTERAR";
                BaseDados.AddParameter("DESCRICAO", dto.Descricao);
                BaseDados.AddParameter("SIGLA", dto.Sigla);
                BaseDados.AddParameter("SITUACAO", dto.Estado);
                BaseDados.AddParameter("UTILIZADOR", dto.Utilizador);
                BaseDados.AddParameter("CODIGO", dto.Codigo);


                dto.Codigo  = BaseDados.ExecuteNonQuery();
                dto.Sucesso = true;
            }
            catch (Exception ex)
            {
                dto.Sucesso      = false;
                dto.MensagemErro = ex.Message.Replace("'", "");
            }
            finally
            {
                BaseDados.FecharConexao();
            }

            return(dto);
        }
示例#2
0
        public IActionResult Post([FromBody] CargoDTO cargoDTO)
        {
            try
            {
                Cargo cargo = new Cargo();

                var empresa = database.Empresas.Where(c => c.Ativo == true).FirstOrDefault(e => e.ID == cargoDTO.EmpresaID);
                if (empresa == null)
                {
                    Response.StatusCode = 404;
                    return(new ObjectResult(new { message = "Empresa Not Found", id = cargoDTO.EmpresaID, code = Response.StatusCode }));
                }
                cargo.Empresa       = empresa;
                cargo.Nome          = cargoDTO.Nome;
                cargo.DataCriacao   = DateTime.Now;
                cargo.DataAlteracao = Convert.ToDateTime("1900-01-01");
                cargo.Ativo         = true;

                database.Cargos.Add(cargo);
                database.SaveChanges();

                Response.StatusCode = 201;
                return(new ObjectResult(new { message = "Create", id = cargo.ID, Code = Response.StatusCode }));
            }
            catch (Exception ex)
            {
                Response.StatusCode = 400;
                return(new ObjectResult(new { message = ex.Message + " " + ex.InnerException.Message, id = cargoDTO.ID, code = Response.StatusCode }));
            }
        }
示例#3
0
        public int create(CargoDTO cargoDTO)
        {
            int           retorno = 0;
            SqlConnection conn    = new SqlConnection(connectionString);

            string sql = "INSERT INTO Cargo ( nombre ) values( @nombre)";

            SqlCommand sqlcmd = new SqlCommand(sql, conn);

            sqlcmd.Parameters.AddWithValue("@nombre", cargoDTO.nombre);
            sqlcmd.CommandType = CommandType.Text;
            conn.Open();

            try
            {
                retorno = sqlcmd.ExecuteNonQuery();
            }
            catch
            {
                retorno = 0;
            }
            finally
            {
                conn.Close();
            }

            return(retorno);
        }
示例#4
0
    protected void btnEditar_Click(object sender, EventArgs e)
    {
        btnEditar.Visible = false;
        btnGrabar.Visible = true;

        CargoDTO theCargoDTO = new CargoDTO();

        theCargoDTO.IdCargo             = decimal.Parse(HdnIdCargo.Value);
        theCargoDTO.NombreCargo         = this.txtNombre.Text;
        theCargoDTO.DescripcionCargo    = this.txtDescripcion.Text;
        theCargoDTO.UsuarioModificacion = myUsuario.Rut;

        //YouCom.DTO.Seguridad.CondominioDTO myCondominioDTO = new YouCom.DTO.Seguridad.CondominioDTO();
        //myCondominioDTO.IdCondominio = decimal.Parse(ddlCondominio.SelectedValue);
        //theCargoDTO.TheCondominioDTO = myCondominioDTO;

        bool respuesta = YouCom.bll.CargoBLL.Update(theCargoDTO);

        if (respuesta)
        {
            cargarCargo();
            this.txtNombre.Text      = string.Empty;
            this.txtDescripcion.Text = string.Empty;

            if (!Page.ClientScript.IsClientScriptBlockRegistered("SET"))
            {
                string script = "alert('Cargo editado correctamente.');";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
            }
        }
        else
        {
        }
    }
        public IActionResult Actualizar([FromBody] CargoDTO cargo)
        {
            if (cargo == null)
            {
                return(BadRequest("Debe enviar datos"));
            }

            if (cargo.IdCar == 0)
            {
                return(BadRequest("Debe enviar id"));
            }

            if (string.IsNullOrEmpty(cargo.Descripcion))
            {
                return(BadRequest("Debe enviar descripción"));
            }

            var cargoActualizar = _cargoService.Actualizar(cargo);

            if (cargoActualizar == null)
            {
                return(BadRequest("Cargo no actualizado"));
            }

            return(Ok(cargoActualizar));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,StartOfShipping,EndOfShipping,Departure,Destination,Info,Weight,Volume,TruckTypeID,CompanyID")] CargoDTO cargo)
        {
            if (id != cargo.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cargo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CargoExists(cargo.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CompanyID"]   = new SelectList(_context.Companies, "Id", "Id", cargo.CompanyID);
            ViewData["TruckTypeID"] = new SelectList(_context.TruckTypes, "TruckTypeID", "TruckTypeID", cargo.TruckTypeID);
            return(View(cargo));
        }
示例#7
0
        public IActionResult Put([FromBody] CargoDTO cargoDTO)
        {
            try
            {
                var cargo = database.Cargos.Where(c => c.Ativo == true).FirstOrDefault(c => c.ID == cargoDTO.ID);
                if (cargo == null)
                {
                    Response.StatusCode = 404;
                    return(new ObjectResult(new { message = "Not Found", id = cargoDTO.EmpresaID, code = Response.StatusCode }));
                }
                var empresa = database.Empresas.FirstOrDefault(e => e.ID == cargoDTO.EmpresaID);
                if (empresa == null)
                {
                    Response.StatusCode = 404;
                    return(new ObjectResult(new { message = "Empresa Not Found", id = cargoDTO.EmpresaID, code = Response.StatusCode }));
                }
                cargo.Empresa       = empresa;
                cargo.Nome          = cargoDTO.Nome;
                cargo.DataAlteracao = DateTime.Now;

                database.SaveChanges();

                Response.StatusCode = 200;
                return(new ObjectResult(new { message = "Salved", id = cargo.ID, Code = Response.StatusCode }));
            }
            catch (Exception ex)
            {
                Response.StatusCode = 400;
                return(new ObjectResult(new { message = ex.Message + " " + ex.InnerException.Message, id = cargoDTO.ID, code = Response.StatusCode }));
            }
        }
示例#8
0
        public DataTable read(CargoDTO cargoDTO)
        {
            DataTable     dt   = new DataTable();
            SqlConnection conn = new SqlConnection(connectionString);

            string sql = "SELECT * FROM Cargo WHERE cargoID = @cargoID";

            SqlCommand sqlcmd = new SqlCommand(sql, conn);

            sqlcmd.Parameters.Add(new SqlParameter("@cargoID", SqlDbType.Int));
            sqlcmd.Parameters["@cargoID"].Value = cargoDTO.cargoID;

            try
            {
                conn.Open();
                SqlDataReader rdr = sqlcmd.ExecuteReader();
                dt.Load(rdr);
                rdr.Close();
            }
            catch
            {
                dt = null;
            }
            finally
            {
                conn.Close();
            }

            return(dt);
        }
        public ActionResult Cargo(int?id = null)
        {
            if (!this.currentUser())
            {
                return(RedirectToAction("Ingresar"));
            }
            if (!this.isAdministrator())
            {
                return(RedirectToAction("Index"));
            }

            MenuNavBarSelected(5);

            CargoBL objBL = new CargoBL();

            ViewBag.IdEntidad = id;
            var objSent = TempData["Cargo"];

            if (objSent != null)
            {
                TempData["Cargo"] = null; return(View(objSent));
            }
            if (id != null)
            {
                CargoDTO obj = objBL.getCargo((int)id);
                return(View(obj));
            }
            return(View());
        }
示例#10
0
        public int delete(CargoDTO cargoDTO)
        {
            int retorno = 0;

            string        sql = "DELETE FROM FormulaMedicamento WHERE formulamedicamentoID=@formulamedicamentoID";
            SqlConnection con = new SqlConnection(connectionString);
            SqlCommand    cmd = new SqlCommand(sql, con);

            cmd.Parameters.AddWithValue("@cargoID", cargoDTO.cargoID);
            cmd.CommandType = CommandType.Text;
            con.Open();

            try
            {
                retorno = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                retorno = 0;
            }
            finally
            {
                con.Close();
            }
            return(retorno);
        }
        public ActionResult EditCargo(CargoDTO cargo, Guid?categoryId)
        {
            return(HttpHandleExtensions.AjaxCallGetResult(() =>
            {
                if (categoryId.HasValue)
                {
                    cargo.Category = new CategoryDTO()
                    {
                        Id = categoryId.Value
                    };
                }
                if (cargo.Id == Guid.Empty)
                {
                    cargo.CreatorId = GetCurrentUser().UserId;
                    _cargoService.Add(cargo);
                    this.JsMessage = MessagesResources.Add_Success;
                }
                else
                {
                    _cargoService.Update(cargo);
                    this.JsMessage = MessagesResources.Update_Success;
                }

                return Json(new AjaxResponse
                {
                    Succeeded = true,
                    RedirectUrl = Url.Action("Index")
                });
            }));
        }
示例#12
0
    protected void rptCargoInactivo_OnItemCommand(object sender, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "Activar")
        {
            HiddenField hdnIdCargo = new HiddenField();
            hdnIdCargo = (HiddenField)e.Item.FindControl("HdnIdCargo");

            CargoDTO theCargoDTO = new CargoDTO();
            theCargoDTO.IdCargo             = decimal.Parse(hdnIdCasa.Value);
            theCargoDTO.UsuarioModificacion = myUsuario.Rut;
            bool respuesta = YouCom.bll.CargoBLL.ActivaCargo(theCargoDTO);
            if (respuesta)
            {
                cargarCargoInactivo();
                if (!Page.ClientScript.IsClientScriptBlockRegistered("SET"))
                {
                    string script = "alert('Cargo Activada correctamente.');";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
                }
            }
            else
            {
            }
        }
    }
示例#13
0
        /// <summary>
        /// Consulta informações do usuário por nome.
        /// </summary>
        /// <param name="_id">Nome do usuário que será consultado.</param>
        /// <returns>Informações do usuário encontrado.</returns>
        public CargoDTO ReadId(int _id)
        {
            try
            {
                dataBaseAccess.AddParameters("_cargo", _id);

                DataTable dataTable = new DataTable();
                dataTable = dataBaseAccess.Consult(CommandType.StoredProcedure, "sp_cargo_id");

                CargoDTO cargoDTO = new CargoDTO();
                cargoDTO.IdCargo        = Convert.ToInt32(dataTable.Rows[0]["IdCargo"]);
                cargoDTO.DescricaoCargo = dataTable.Rows[0]["DescricaoCargo"].ToString();

                return(cargoDTO);
            }
            catch (Exception ex)
            {
                StringBuilder message = new StringBuilder();
                message.Append("Não foi possível consultar cargos por id:\n\n").Append(ex.Message);
                throw new Exception(message.ToString());
            }
            finally
            {
                dataBaseAccess.ClearParameters();
            }
        }
示例#14
0
        public CargoDTO ObterPorPK(CargoDTO dto)
        {
            try
            {
                BaseDados.ComandText = "stp_RH_CARGO_OBTERPORPK";

                BaseDados.AddParameter("CODIGO", dto.Codigo);

                MySqlDataReader dr = BaseDados.ExecuteReader();

                dto = new CargoDTO();

                while (dr.Read())
                {
                    dto.Codigo    = int.Parse(dr[0].ToString());
                    dto.Descricao = dr[1].ToString();
                    dto.Sigla     = dr[2].ToString();
                    dto.Estado    = int.Parse(dr[3].ToString());
                }
            }
            catch (Exception ex)
            {
                dto.Sucesso      = false;
                dto.MensagemErro = ex.Message.Replace("'", "");
            }
            finally
            {
                BaseDados.FecharConexao();
            }

            return(dto);
        }
示例#15
0
        /// <summary>
        /// Consulta informações do usuário por nome.
        /// </summary>
        /// <param name="post">Nome do usuário que será consultado.</param>
        /// <returns>Informações do usuário encontrado.</returns>
        public CargoCollectionDTO ReadName(string post)
        {
            CargoCollectionDTO cargoCollectionDTO = new CargoCollectionDTO();

            try
            {
                dataBaseAccess.AddParameters("_cargo", post);

                DataTable dataTable = new DataTable();
                dataTable = dataBaseAccess.Consult(CommandType.StoredProcedure, "sp_cargo_nome");

                foreach (DataRow row in dataTable.Rows)
                {
                    CargoDTO cargoDTO = new CargoDTO();
                    cargoDTO.IdCargo        = Convert.ToInt32(row["IdCargo"]);
                    cargoDTO.DescricaoCargo = row["DescricaoCargo"].ToString();

                    cargoCollectionDTO.Add(cargoDTO);
                }

                return(cargoCollectionDTO);
            }
            catch (Exception ex)
            {
                StringBuilder message = new StringBuilder();
                message.Append("Não foi possível consultar cargos por nome:\n\n").Append(ex.Message);
                throw new Exception(message.ToString());
            }
            finally
            {
                dataBaseAccess.ClearParameters();
            }
        }
        public IHttpActionResult CreateCargo(OrderDetail orderDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _db.OrderDetail.Add(orderDetail);
            _db.SaveChanges();


            var dto = new CargoDTO()
            {
                Address            = orderDetail.Order.ShippedAddress,
                BuyerFirstName     = orderDetail.Order.AppUser.Profile.FirstName,
                BuyerLastName      = orderDetail.Order.AppUser.Profile.LastName,
                Email              = orderDetail.Order.Email,
                ProductName        = orderDetail.Product.ProductName,
                Quantity           = orderDetail.Quantity,
                ShipperCompanyName = orderDetail.Order.Shipper.CompanyName,
                ShipperPhoneNumber = orderDetail.Order.Shipper.Phone,
                TotalPrice         = orderDetail.TotalPrice,
            };

            return(CreatedAtRoute("DefaultApi", new { id = orderDetail.ID }, dto));
        }
        public void UpdateCargo(int id, CargoDTO cargoDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            var orderDetailInDB = _db.OrderDetail.FirstOrDefault(x => x.ID == id);

            if (orderDetailInDB != null)
            {
                var cargo = from s in _db.OrderDetail
                            select new CargoDTO
                {
                    TotalPrice         = s.TotalPrice,
                    Quantity           = s.Quantity,
                    ProductName        = s.Product.ProductName,
                    ShipperCompanyName = s.Order.Shipper.CompanyName,
                    Address            = s.Order.ShippedAddress,
                    BuyerFirstName     = s.Order.AppUser.Profile.FirstName,
                    BuyerLastName      = s.Order.AppUser.Profile.LastName,
                    Email = s.Order.Email,
                };
                _db.SaveChanges();
            }
        }
        public void Update(CargoDTO item)
        {
            Cargo cargo = _context.Cargos.FirstOrDefault(x => x.Id == item.Id);

            cargo.Nome           = item.Nome;
            cargo.ValorBeneficio = cargo.ValorBeneficio;
            _context.SaveChanges();
        }
        public IActionResult Editar(int id)
        {
            var      cargo     = Database.Cargos.First(c => c.Id == id);
            CargoDTO cargoView = new CargoDTO();

            cargoView.Id   = cargo.Id;
            cargoView.Nome = cargo.Nome;
            return(View(cargo));
        }
示例#20
0
        public int create(CargoDTO cargoDTO)
        {
            int      retorno  = 0;
            CargoDAO cargoDAO = new CargoDAO();

            retorno = cargoDAO.create(cargoDTO);

            return(retorno);
        }
 public IActionResult Edit(CargoDTO cargo)
 {
     if (ModelState.IsValid)
     {
         Repository.Update(cargo);
         return(RedirectToAction("Index"));
     }
     return(View(cargo));
 }
        private void btnCadastrar_Click(object sender, EventArgs e)
        {
            try
            {
                CargoDTO  depto  = cboDepto.SelectedItem as CargoDTO;
                EstadoDTO estado = cboEstado.SelectedItem as EstadoDTO;

                FuncionarioDTO dto = new FuncionarioDTO();
                dto.Nome        = txtNome.Text;
                dto.Rg          = mkbRg.Text;
                dto.Salario     = nudSalario.Value;
                dto.Cpf         = mkbCpf.Text;
                dto.Telefone    = mkbTelefone.Text;
                dto.Email       = txtEmail.Text;
                dto.IdDepto     = depto.Id;
                dto.Cidade      = txtCidade.Text;
                dto.IdEstado    = estado.IdEstado;
                dto.Cep         = mkbCep.Text;
                dto.Rua         = txtEndereco.Text;
                dto.Complemento = txtComplemento.Text;
                dto.Numero      = txtNumero.Text;

                dto.Imagem = ImagemPlugIn.ConverterParaString(pbxImagem.Image);

                FuncionariosBusiness buss = new FuncionariosBusiness();
                buss.Salvar(dto);

                frmMessage tela = new frmMessage();
                tela.LoadScreen("Funcionário cadastrado com sucesso!");
                tela.ShowDialog();
            }
            catch (MySqlException mex)
            {
                if (mex.Number == 1062)
                {
                    string msg = "Funcionario já está cadastrado. Verifique se o CPF está corretamente preenchido ou se ele já esta no sistema.";

                    frmAlert tela = new frmAlert();
                    tela.LoadScreen(msg);
                    tela.ShowDialog();
                }
            }
            catch (ValidacaoException vex)
            {
                string msg = vex.Message;

                frmAlert tela = new frmAlert();
                tela.LoadScreen(msg);
                tela.ShowDialog();
            }
            catch (Exception)
            {
                frmException tela = new frmException();
                tela.LoadScreen("Ocorreu um erro.\nConsulte o administrador do sistema.");
                tela.ShowDialog();
            }
        }
        public IActionResult Put(int id, CargoDTO dto)
        {
            if (!_gravarCargoService.Alterar(id, dto))
            {
                return(BadRequest(_gravarCargoService.notificationContext.Notifications));
            }

            return(Created($"/api/cargo/{id}", dto));
        }
        public IActionResult Post(CargoDTO dto)
        {
            if (!_gravarCargoService.Adicionar(dto))
            {
                return(BadRequest(_gravarCargoService.notificationContext.Notifications));
            }

            return(Created($"/api/cargo/{dto.Id}", dto));
        }
示例#25
0
 public CargoDTO Salvar(CargoDTO dto)
 {
     if (dto.Codigo > 0)
     {
         return(dao.Alterar(dto));
     }
     else
     {
         return(dao.Adicionar(dto));
     }
 }
        public void Add(CargoDTO item)
        {
            var cargo = new Cargo
            {
                Nome           = item.Nome,
                ValorBeneficio = item.ValorBeneficio
            };

            _context.Cargos.Add(cargo);
            _context.SaveChanges();
        }
        public IActionResult Delete(CargoDTO cargo)
        {
            CargoDTO car = Repository.GetCargo(cargo.Id);

            if (car != null)
            {
                Repository.Delete(cargo.Id);
                TempData["Message"] = "Cargo " + car.Nome + " foi removido";
            }
            return(RedirectToAction("Index"));
        }
示例#28
0
        public void Incluir(CargoDTO carDalCrud)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = conexao.Conexao;
            cmd.CommandText = "insert into tbCargo(car_cargo) values (@car_cargo);select @@identity;";
            cmd.Parameters.AddWithValue("@car_cargo", carDalCrud.Car_cargo);
            conexao.Conectar();
            carDalCrud.Car_id = Convert.ToInt32(cmd.ExecuteScalar());
            conexao.Desconectar();
        }//incluir
示例#29
0
        public void Alterar(CargoDTO carBllCrud)
        {
            if (carBllCrud.Car_cargo.Trim().Length == 0) //verifica se foi informado o sexo
            {
                throw new Exception("O cargo é obrigatório");
            }

            CargoDAL dalObj = new CargoDAL(conexao);

            dalObj.Alterar(carBllCrud);
        }
示例#30
0
 public void BotaoInserir()
 {
     try
     {
         CargoSelected = new CargoDTO();
         IsEditar      = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Alerta do sistema", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
示例#31
0
 public new List<CargoDTO> selectCargo(CargoDTO Cargo)
 {
     return base.selectCargo(Cargo);
 }