private void BtRemoveBus_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count > 0)
            {
                var getFun      = new FuncionarioItemEdit();
                var funcionario = getFun.GetFuncionarioEdit();
                var getBus      = new OnibusItemCollection();
                getBus.SetList(funcionario.Onibus);
                var listonibusEdit = new List <OnibusItem>();
                var testelist      = new List <OnibusItem>();
                for (int i = 0; i < listView1.SelectedItems.Count; i++)
                {
                    ListViewItem onibusItem     = listView1.SelectedItems[i];
                    var          onibusTodelete = new OnibusItem(_buslistviewIndexHelper, onibusItem.SubItems[0].Text, onibusItem.SubItems[1].Text, Convert.ToDouble(onibusItem.SubItems[2].Text));
                    listonibusEdit.Add(onibusTodelete);
                }
                foreach (OnibusItem onibusItem in listonibusEdit)
                {
                    testelist = getBus.GetFuncionarioOnibusCollection();
                    getBus.RemoveBusbyId(0);
                    testelist = getBus.GetFuncionarioOnibusCollection();
                }

                //final list for visualization testes
                listonibusEdit = getBus.GetFuncionarioOnibusCollection();
                OnibusTableHandler(listonibusEdit);
                funcionario.Onibus = getBus.MakeListToCollection();
                getFun.SetFuncionarioEdit(funcionario);



                //OnibusItem onibus = new OnibusItem(listView1.SelectedItems[0]);
            }
        }
Exemple #2
0
        private void LoadSelectedFuncionarioInfo()
        {
            var objSql     = new DataBaseHandler();
            var objHandler = new SqlToSharpHandler();

            //buscar informacoes do funcionario
            if (listBox1.SelectedIndex >= 0)
            {
                FuncionarioItem funcionario = objHandler.ConvertoFromSqlTo_1_FuncionarioItem(objSql.GetFuncionariosInfo(_previewList[listBox1.SelectedIndex].Idfuncionario.ToString()));
                objSql.GetDocuments(funcionario.IdFuncionario);
                var functesteequals     = funcionario;
                var funcionarioSelected = new FuncionarioItemEdit();

                funcionarioSelected.SetFuncionarioEdit(functesteequals);
                bool teste          = funcionario.Equals(funcionarioSelected.GetFuncionarioEdit());
                var  objInformacoes = new InformacoesControl(funcionarioSelected.GetFuncionarioEdit());
                panelInfo.Controls.Clear();
                panelInfo.Controls.Add(objInformacoes);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btAddBus_Click(object sender, EventArgs e)
        {
            var getFun      = new FuncionarioItemEdit();
            var funcionario = getFun.GetFuncionarioEdit();
            var getBus      = new OnibusItemCollection();

            getBus.SetList(funcionario.Onibus);
            int id = getBus.COuntList() + 1;

            //----------------------working now------------------
            if (txtLinha.Text.Trim() != "" & cbCartao.Text.Trim() != "")
            {
                var onibus = new OnibusItem(id, txtLinha.Text.Trim(), cbCartao.Text.Trim(), Convert.ToDouble(txtPreco.Text.Trim()));
                getBus.AddBus(onibus);
                int id2 = getBus.COuntList() + 1;
            }
            funcionario.Onibus  = getBus.MakeListToCollection();
            ParentPanel.Visible = false;
            ParentPanel.SendToBack();
            ParentPanel.Controls.Clear();
            int[] a = new int[5];
        }
        /// <summary>
        /// CONVERT FUNCIONARIO SQL INFORMATION TO FUNCIONARIOITEM
        ///
        /// SEM INFORMACOES DE ONIBUS
        /// </summary>
        /// <param name="_dt"></param>
        /// <returns></returns>
        public FuncionarioItem ConvertoFromSqlTo_1_FuncionarioItem(DataTable dt)
        {
            List <FuncionarioItem> listFUncionarios = new List <FuncionarioItem>();
            int             aux         = 0;
            FuncionarioItem funcionario = null;

            if (dt.Rows.Count == 1)
            {
                foreach (DataRow rows in dt.Rows)
                {
                    Image picture = null;
                    //helper less conversions
                    int row = 0;
                    //matricula
                    int matricula = Convert.ToInt32(dt.Rows[row][0]);
                    if (matricula >= aux)
                    {
                        aux = matricula;
                    }
                    //deal if date is a picture
                    if (Convert.IsDBNull(dt.Rows[row][1]) == false)
                    {
                        Byte[] data = new Byte[0];
                        data = (Byte[])(dt.Rows[row][1]);
                        MemoryStream mem = new MemoryStream(data);
                        picture = Image.FromStream(mem);
                    }
                    //nome.... etc
                    string      nome        = dt.Rows[row][2].ToString();
                    string      identidade  = dt.Rows[row][3].ToString();
                    string      cpf         = dt.Rows[row][4].ToString();
                    DateTime    dn          = Convert.ToDateTime(dt.Rows[row][5]);
                    string      sexo        = dt.Rows[row][6].ToString();
                    string      rua         = dt.Rows[row][7].ToString();
                    string      numero      = dt.Rows[row][8].ToString();
                    string      bairro      = dt.Rows[row][9].ToString();
                    string      cidade      = dt.Rows[row][10].ToString();
                    string      estado      = dt.Rows[row][11].ToString();
                    string      complemento = dt.Rows[row][12].ToString();
                    string      cep         = dt.Rows[row][13].ToString();
                    string      observacao  = dt.Rows[row][14].ToString();
                    bool        inativo     = Convert.ToBoolean(dt.Rows[row][15]);
                    string      telefone    = dt.Rows[row][16].ToString();
                    DateTime    admissao    = Convert.ToDateTime(dt.Rows[row][17]);
                    CultureInfo cult        = new CultureInfo("pt-BR");
                    DateTime    inativacao;
                    if (Convert.IsDBNull(dt.Rows[row][18]) == false)
                    {
                        inativacao = Convert.ToDateTime(dt.Rows[row][18], cult);
                    }
                    else
                    {
                        inativacao = Convert.ToDateTime("01/01/1900", cult);
                    }

                    var dataBaseHandler = new DataBaseHandler();
                    var sQlDataHandler  = new SqlToSharpHandler();

                    //Get func information bus
                    OnibusItemCollection funcListOnibus = new OnibusItemCollection();
                    funcListOnibus.SetList(sQlDataHandler.ConvertSQlToBusCollectionItem(dataBaseHandler.GetBus(matricula)));

                    //get information about Vaccine
                    Vacina.FuncionarioVaccinaColletion funcVaccineList = new Vacina.FuncionarioVaccinaColletion();
                    funcVaccineList.SetList(sQlDataHandler.ConvertSqlVaccineToColletion(dataBaseHandler.GetVacinas(matricula)));

                    //get func information about ferias
                    Ferias.FeriasColletionItem listFerias = new Ferias.FeriasColletionItem();
                    listFerias.SetList(sQlDataHandler.ConvertSqLtoFeriasItem(dataBaseHandler.GetFerias(matricula)));

                    //get information about exames

                    Exames.Data.ExameItemColletion collectionExams = new Exames.Data.ExameItemColletion();

                    Exames.Data.ExameItemColletion colletion = sQlDataHandler.ConvertSqlExamToItem(dataBaseHandler.GetExames(matricula));
                    //CollectionExams.SetList(SQlDataHandler.ConvertSqlExamToItem(DataBaseHandler.GetExames(matricula)));



                    //GENERATES FUNCIONARIO ITEM WITH ALL INFO COLLECTED
                    funcionario = new FuncionarioItem(matricula, picture, nome, cpf, identidade, sexo, dn, rua, numero, complemento, bairro, observacao, cidade, estado, cep, telefone, inativo, admissao, inativacao, null, funcListOnibus, funcVaccineList, listFerias, colletion);
                    var funcionarioSelected = new FuncionarioItemEdit();
                    funcionarioSelected.SetFuncionarioEdit(funcionario);
                    row++;
                }
            }

            return(funcionario);
        }