/// <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); }
private void LoadFuncFerias(FeriasColletionItem feriasCol) { int auxMonthS = 0; int auxMonthE = 0; Control tagFound = new Control(); Control row1 = ShowPanel.Controls[1]; Control row2 = ShowPanel.Controls[2]; Control row3 = ShowPanel.Controls[3]; foreach (FeriasItem feriasItem in feriasCol.ListaFerias) { //auxiliary variables DateTime currentDate = new DateTime(); //get first and last vacation days auxMonthS = feriasItem.InicioFerias.Month; auxMonthE = feriasItem.FimFerias.Month; //calculates the number of days int numberOfDaysFerias = Math.Abs((feriasItem.InicioFerias - feriasItem.FimFerias).Days); //calculates number of months int numberOfMonths = auxMonthE - auxMonthS + 1; //inicialize dateitems for calendar //DateItem[] d = new DateItem[NumberOfDaysFerias]; //d.Initialize(); //for (int j = 0; j < NumberOfDaysFerias; j++) // d[j] = new DateItem(); int auxCounter = 0; List <DateItem> listD = new List <DateItem>(); //repeat if more then 1 month for (int m = 1; m <= numberOfMonths; m++) { Control calendarControl = new Control(); if (auxMonthS != 0) { if (auxMonthS > 0 && auxMonthS < 5) { calendarControl = HelperClass.FindTag(row1.Controls, $"month{auxMonthS}"); } else if (auxMonthS > 4 && auxMonthS < 9) { calendarControl = HelperClass.FindTag(row2.Controls, $"month{auxMonthS}"); } else { calendarControl = HelperClass.FindTag(row3.Controls, $"month{auxMonthS}"); } } MonthCalendar calendarToAdd = (MonthCalendar)calendarControl ?? throw new Exception("Algo deu ruim no calendario"); //cast dates to dateitems for (int i = auxCounter; i <= numberOfDaysFerias; i++) { //compare current months currentDate = feriasItem.InicioFerias.AddDays(i); //make sure same month if (auxMonthS == currentDate.Month) { DateItem d = new DateItem(); //add date to dateitem d.Date = currentDate; FileStream fs = new FileStream(@"Imagens\sunny.png", FileMode.Open, FileAccess.Read); Image img = Image.FromStream(fs); Bitmap objBitmap = new Bitmap(img, new Size(10, 10)); ImageList list = new ImageList(); d.Image = objBitmap; fs.Close(); d.BackColor1 = Color.Red; listD.Add(d); } else { auxMonthS += 1; break; } auxCounter++; } DateItem[] e = new DateItem[listD.Count()]; e.Initialize(); for (int i = 0; i < listD.Count(); i++) { e[i] = listD[i]; } calendarToAdd.AddDateInfo(e); } } }