// Métodos; public Abastecimento() { _veiculo = new Veiculo(); _fornecedor = new Fornecedor(); _funcionario = new Funcionario(); _combustivel = new Combustivel(); }
public void atualizaSecao() { funcCota = new Funcionario(); daoCota_Mensal = new DAOCota_mensal(); funcCota.Matricula = txbMatricula.Text; funcCota.Nome=txbNome.Text; funcCota.ID=Int32.Parse(ddFuncao.SelectedValue); Session["lstFuncCotaMens"] = daoCota_Mensal.listFuncCota(funcCota, Int16.Parse(ddMes.SelectedValue), Int16.Parse(ddAno.SelectedValue)); (Session["selectFuncCotaMens"] as List<Funcionario>).Clear(); }
private void getFuncionario() { funcionario = (Session["funcionario"] as Funcionario); funcionario.Matricula = txbMatricula.Text; if (funcionario.Matricula != "") { daoFuncionario = new DAOFuncionario(); daoFuncionario.buscarMatricula(funcionario); } else funcionario.Nome = ""; Session["funcionario"] = funcionario; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { funcionario = new Funcionario(); Session["funcionario"] = funcionario; } if (Session["buscaFunc"] != null) { txbMatricula.Text = (Session["buscaFunc"] as Funcionario).Matricula; txbMatricula_TextChanged(sender, e); Session.Remove("buscaFunc"); } }
public bool verifMatricula(Funcionario obj) { SqlCommand command = new SqlCommand(); Int32 co; bool resultado = false; try { command.Connection = MsSQL.getConexao(); command.Connection.Open(); command.CommandText = "SELECT COUNT(NOME) AS CO FROM FUNCIONARIO " + "WHERE MATRICULA='" + ((Funcionario)obj).Matricula + "' and ID<>" + ((Funcionario)obj).ID.ToString(); co = (int)command.ExecuteScalar(); resultado = (co > 0); } finally { command.Connection.Close(); } return resultado; }
public void excluirItemSecao(Funcionario obj) { foreach (Funcionario f in (Session["lstFuncCotaMens"] as List<Funcionario>)) { if (f.ID == obj.ID) { (Session["lstFuncCotaMens"] as List<Funcionario>).Remove(f); break; } } }
protected void ibtAdicionar_Click(object sender, ImageClickEventArgs e) { lstfuncCotaMens = (Session["selectFuncCotaMens"] as List<Funcionario>); bool itemSelecionado = false; daoFuncao = new DAOFuncao(); daoFuncionario = new DAOFuncionario(); foreach (GridDataItem dataItem in RadGrid1.Items) { if ((dataItem.FindControl("cbSelecao") as CheckBox).Checked) { itemSelecionado = true; funcCota = new Funcionario(); funcCota.ID = int.Parse(dataItem.Cells[3].Text); daoFuncionario.buscarID(funcCota); daoFuncao.buscarID(funcCota.Funcao); lstfuncCotaMens.Add(funcCota); excluirItemSecao(funcCota); } } if (itemSelecionado) { Session["selectFuncCotaMens"] = lstfuncCotaMens; RadGrid1.DataBind(); } else { lbMens.Visible = true; lbMens.Text = "Nenhum item selecionado"; } }
// Métodos public Cota_extra() { _funcionario = new Funcionario(); _veiculo = new Veiculo(); }
protected void ibtExcluir_Click(object sender, ImageClickEventArgs e) { funcionario = (Session["funcionario"] as Funcionario); funcionario.deletar(); try { funcionario.aplicar(new DAOFuncionario()); Response.Redirect("pesqFuncionario.aspx"); } catch (Exception Ex) { lbMsgErro.Visible = true; lbMsgErro.Text = Ex.Message; } }
public Int32 verifCotaextra(Funcionario obj, Int32 pmes, Int32 pano) { SqlDataReader reader; Int32 resultado = 0; try { command.Connection = MsSQL.getConexao(); command.Connection.Open(); vsql.Append("SELECT SUM(QUANTIDADE) as QUANTIDADE FROM COTA_EXTRA "); vsql.Append(" WHERE ID_FUNCIONARIO=" + obj.ID.ToString()); vsql.Append(" AND MONTH(DATA)=" + pmes); vsql.Append(" AND YEAR(DATA)=" + pano); command.CommandText = command.CommandText + vsql.ToString(); reader = command.ExecuteReader(); if (reader.Read()) { resultado = Convert.ToInt32(((reader["QUANTIDADE"].ToString()=="")?0:reader["QUANTIDADE"])); } else { resultado = 0; } } finally { command.Connection.Close(); } return resultado; }
// Métodos; public Cota_mensal() { _funcionario = new Funcionario(); }
public List<Funcionario> listFuncCota(Funcionario obj, Int16 pMes, Int16 pAno) { SqlDataReader reader; List<Funcionario> listaFuncCota = new List<Funcionario>(); Int32 x = 0; String conteudo; try { command.Connection = MsSQL.getConexao(); command.Connection.Open(); vsql.Append("SELECT A.ID,A.MATRICULA,A.NOME,A.ID_FUNCAO,B.NOME as NOME_FUNCAO FROM FUNCIONARIO A "); vsql.Append("LEFT OUTER JOIN FUNCAO B ON (B.ID=A.ID_FUNCAO) "); vsql.Append("WHERE A.ID NOT IN (SELECT C.ID_FUNCIONARIO FROM COTA_MENSAL C "); vsql.Append("WHERE C.ID_FUNCIONARIO=A.ID AND C.MES=" + pMes.ToString() + " AND C.ANO=" + pAno.ToString() + ") "); vsql.Append(" and A.DATA_DEMISSAO IS NULL "); if (obj.Matricula != "") { conteudo = obj.Matricula.ToUpper(); vsql.Append(" and (A.MATRICULA = '" + conteudo + "')"); } if (obj.Nome != "") { conteudo = "%" + obj.Nome.ToUpper() + "%"; vsql.Append(" and (A.NOME LIKE '" + conteudo + "')"); } if (obj.ID != 0) { conteudo = obj.ID.ToString(); vsql.Append(" and (B.ID = " + conteudo + ")"); } vsql.Append("ORDER BY A.NOME"); command.CommandText = vsql.ToString(); reader = command.ExecuteReader(); while (reader.Read()) { listaFuncCota.Add(new Funcionario()); listaFuncCota[x].ID = Convert.ToInt32(reader["ID"]); listaFuncCota[x].Matricula = reader["MATRICULA"].ToString(); listaFuncCota[x].Nome = reader["NOME"].ToString(); listaFuncCota[x].Funcao.ID = Convert.ToInt32(reader["ID_FUNCAO"].ToString()); listaFuncCota[x].Funcao.Nome = reader["NOME_FUNCAO"].ToString(); x++; } return listaFuncCota; } catch (Exception e) { throw new Exception("Erro ao montar a lista de cota de combustível. " + e.Message); } finally { command.Connection.Close(); } }
public Double verifSaldo(Funcionario obj, Int32 pMes, Int32 pAno) { DAOCota_mensal daoCota_mensal = new DAOCota_mensal(); DAOCota_extra daoCota_extra = new DAOCota_extra(); Int32 vcota_mensal; Int32 vcota_extra; Double vqtde_abastecido; Int32 vresultado; vcota_mensal = daoCota_mensal.verifCota(obj.ID,pMes,pAno); vcota_extra = daoCota_extra.verifCotaextra(obj,pMes,pAno); vqtde_abastecido = verifAbastecido(obj, pMes, pAno); vresultado=((vcota_mensal+vcota_extra)-Convert.ToInt32(vqtde_abastecido)); return vresultado; }
public Double verifAbastecido(Funcionario obj, Int32 pmes, Int32 pano) { SqlDataReader reader; Double qtde_abastecido; try { command.Connection = MsSQL.getConexao(); command.Connection.Open(); vsql.Append("SELECT SUM(QUANTIDADE) as QUANTIDADE FROM ABASTECIMENTO "); vsql.Append("WHERE ID_FUNCIONARIO= "+obj.ID.ToString()); vsql.Append(" AND MONTH(DATA_ABASTEC)=" + pmes.ToString()); vsql.Append(" AND YEAR(DATA_ABASTEC)=" + pano.ToString()); command.CommandText = command.CommandText + vsql.ToString(); reader = command.ExecuteReader(); if (reader.Read()) { qtde_abastecido = Convert.ToInt32(((reader["QUANTIDADE"].ToString()=="")?0:reader["QUANTIDADE"])); } else { qtde_abastecido = 0; } } finally { command.Connection.Close(); } return qtde_abastecido; }
public void excluir(Funcionario obj) { (Session["selectFuncCotaMens"] as List<Funcionario>).Remove(obj); }
protected void ibtGravar_Click(object sender, ImageClickEventArgs e) { funcionario = (Session["funcionario"] as Funcionario); setDados(); try { funcionario.aplicar(new DAOFuncionario()); Session["prox_pagina"] = "pesqFuncionario.aspx"; Response.Redirect("OperacaoRealizada.aspx"); } catch (Exception Ex) { lbMsgErro.Visible = true; lbMsgErro.Text = Ex.Message; } }
// Métodos public Veiculo() { _modelo = new Modelo(); _funcionario = new Funcionario(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { carregaListaFuncao(); funcionario = new Funcionario(); funcionario.ID = int.Parse(Request.QueryString["ID"]); if (funcionario.ID != 0) { daoFuncionario = new DAOFuncionario(); daoFuncionario.buscarID(funcionario); getDados(); habilitarCtrl(false); funcionario.editar(); } else habilitarCtrl(true); Session["funcionario"] = funcionario; } }
/******************************************************************************/ protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { veiculo = new Veiculo(); funcionario = new Funcionario(); fornecedor = new Fornecedor(); Session["veiculo"] = veiculo; Session["funcionario"] = funcionario; Session["fornec"] = fornecedor; } if (Session["buscaFornec"] != null) { txbID_Fornecedor.Text = (Session["buscaFornec"] as Fornecedor).ID.ToString(); txbID_Fornecedor_TextChanged(sender, e); Session.Remove("buscaFornec"); } if (Session["buscaVeiculo"] != null) { txbPlaca.Text = (Session["buscaVeiculo"] as Veiculo).Placa; txbPlaca_TextChanged(sender, e); Session.Remove("buscaVeiculo"); } if (Session["buscaFunc"] != null) { txbMatricula.Text = (Session["buscaFunc"] as Funcionario).Matricula; txbMatricula_TextChanged(sender, e); Session.Remove("buscaFunc"); } }