private void RemplirDgvPrestations() { int joursRestants; DtPrestations = new DataTable(); DtPrestations.Columns.Add(new DataColumn("IdPresta", Type.GetType("System.Int32") ?? throw new InvalidOperationException())); DtPrestations.Columns.Add("Interimaire"); DtPrestations.Columns.Add("Entreprise"); DtPrestations.Columns.Add("Travail"); DtPrestations.Columns.Add("DateDebut"); DtPrestations.Columns.Add("DateFin"); DtPrestations.Columns.Add("JourRestant"); DtPrestations.Columns.Add("Facture"); DtPrestations.Columns.Add("Status"); foreach (var prestation in Prestations) { C_t_facture facture = Factures.Find(x => x.id_fact == prestation.id_fact); C_t_categorie travail = Travails.Find(x => x.id_categ == prestation.id_categ); C_t_interimeur interimaire = Interimaires.Find(x => x.id_inte == facture.id_inte); C_t_entreprise entreprise = Entreprises.Find(x => x.id_entre == facture.id_entre); //MessageBox.Show(entreprise.nom_entre); joursRestants = Convert.ToInt32((prestation.date_fin - DateTime.Today).TotalDays); if (joursRestants < 0) { joursRestants = 0; } DtPrestations.Rows.Add(prestation.Id_travail, interimaire.nom_inte, entreprise.nom_entre, travail.nom_categ, prestation.date_debut.ToString("dd-MM-yyyy"), prestation.date_fin.ToString("dd-MM-yyyy"), joursRestants, facture.date_fact, (prestation.date_fin > DateTime.Today) ? "En Cours" : "Terminer"); } BsPrestations = new BindingSource { DataSource = DtPrestations }; dgvPrestations.DataSource = BsPrestations; }
private void btnEmplDuTmp_Click(object sender, EventArgs e) { // the creation of the repport document of "emploi du temps de l'interimaire" if (dgvInterimeur.Rows.Count > 0)//si il y a des trus dans le dgv { Document doc = new Document(PageSize.LETTER, 40, 40, 30, 25); PdfWriter pw = PdfWriter.GetInstance(doc, new FileStream(@"E:\C#\InterimDesktopApp\Doc\Emploid de temps des interimairs.pdf", FileMode.Create)); doc.Open();// opening the pdf to write in Image logo = Image.GetInstance(@"E:\C#\InterimDesktopApp\Images\circle.png"); Paragraph logo_name = new Paragraph("Circle", small_font); Paragraph date = new Paragraph("Le" + " " + DateTime.Today.ToString("dd/MM/yyyy"), date_font); Paragraph title = new Paragraph("Emploi de temps de chaque interimaire", header_font); Paragraph newLine = new Paragraph("\n"); logo.ScalePercent(10.0f); logo.Alignment = 0;// 0 = left; 1=center ; 2=right logo.Alignment = 0; date.Alignment = 2; title.Alignment = 1; doc.Add(logo); doc.Add(logo_name); doc.Add(date); doc.Add(title); doc.Add(newLine); for (int i = 0; i < dgvInterimeur.RowCount - 1; i++) { var nId = Convert.ToInt32(dgvInterimeur.Rows[i].Cells[0].Value); C_t_interimeur interimeur = Interimeurs.Find(x => x.id_inte == (int)nId); C_t_categorie categorie = Categories.Find(x => x.nom_categ == interimeur.specialisation); C_t_travail prestation = Prestations.Find(x => x.id_categ == categorie.id_categ); //MessageBox.Show(categorie.nom_categ + "=>" + prestation.nom_travail); PdfPTable table_interimeur = new PdfPTable(2); PdfPCell nom_interimeur = new PdfPCell(new Phrase(interimeur.nom_inte, normal_font)); PdfPCell col_date_debut = new PdfPCell(new Phrase("Debut", normal_font)); PdfPCell col_date_fin = new PdfPCell(new Phrase("Fin", normal_font)); nom_interimeur.Colspan = 2; nom_interimeur.BackgroundColor = BaseColor.ORANGE; nom_interimeur.HorizontalAlignment = 1; col_date_debut.HorizontalAlignment = 1; col_date_fin.HorizontalAlignment = 1; table_interimeur.AddCell(nom_interimeur); table_interimeur.AddCell(col_date_debut); table_interimeur.AddCell(col_date_fin); table_interimeur.AddCell(prestation.date_debut.ToString("dd/MM/yyyy")); table_interimeur.AddCell(prestation.date_fin.ToString("dd/MM/yyyy")); //table_interimeur.AddCell(interimeur.nom_inte); //table_interimeur.AddCell("nothing"); doc.Add(table_interimeur); doc.Add(newLine); } doc.Close(); //closing the pdf } else { MessageBox.Show(@"Vous n'aves pas d'interimaire dans vorte base de donneés"); } }
private void btnConfirmer_Click_1(object sender, EventArgs e) { if (string.IsNullOrEmpty(tbId.Text)) { if (string.IsNullOrEmpty(tbNomPresta.Text) || string.IsNullOrEmpty(tbSalPresta.Text)) { MessageBox.Show(@"Please fill all require information"); } else // ajouter dans la base de donnees { //try //{ //MessageBox.Show(cbCategorie.SelectedItem.ToString()+" - "+cbFacture.SelectedItem.ToString() ); //foreach (var f in Factures) // MessageBox.Show(f.id_fact.ToString()+" "+f.date_fact.ToString()); C_t_categorie categorie = Categories.Find(x => x.nom_categ == cbCategorie.SelectedItem.ToString()); C_t_facture facture = Factures.Find(x => x.date_fact.ToString("dd/MM/yyyy") == cbFacture.SelectedItem.ToString()); //MessageBox.Show(facture.id_fact.ToString() + " - " + categorie.id_categ.ToString()); //MessageBox.Show(facture.id_fact.ToString()); new G_t_travail(SChonn).Ajouter(tbNomPresta.Text, double.Parse(tbSalPresta.Text), dtpStart.Value, dtpEnd.Value, categorie.id_categ, facture.id_fact); //} //catch (Exception ex){ MessageBox.Show(ex.Message);} //finally { RemplireDgv(); } } } else // modification de la base de donnees { var nId = int.Parse(tbId.Text); //foreach (var f in Factures) // MessageBox.Show(f.date_fact.ToString("dd/MM/yyyy") +"->"+ cbFacture.Text); C_t_categorie categorie = Categories.Find(x => x.nom_categ == cbCategorie.Text); C_t_facture facture = Factures.Find(x => x.date_fact.ToString("dd/MM/yyyy") == cbFacture.Text); MessageBox.Show(categorie.nom_categ + " " + facture.date_fact.ToString("dd/MM/yyyy")); new G_t_travail(SChonn).Modifier(nId, tbNomPresta.Text, Convert.ToDouble(tbSalPresta.Text), dtpStart.Value, dtpEnd.Value, categorie.id_categ, facture.id_fact); dgvPrestation.SelectedRows[0].Cells["NomTravail"].Value = tbNomPresta.Text; dgvPrestation.SelectedRows[0].Cells["DtDebut"].Value = dtpStart.Text; dgvPrestation.SelectedRows[0].Cells["DtFin"].Value = dtpEnd.Text; dgvPrestation.SelectedRows[0].Cells["SalTravail"].Value = tbSalPresta.Text; dgvPrestation.SelectedRows[0].Cells["IdCateg"].Value = cbCategorie.SelectedItem; dgvPrestation.SelectedRows[0].Cells["IdFact"].Value = cbFacture.Text; dgvPrestation.EndEdit(); Activer(true); } RefreshDgv(); ClearTb(); }
public C_t_categorie Lire_ID(int id_categ) { CreerCommande("Selectionnert_categorie_ID"); Commande.Parameters.AddWithValue("@id_categ", id_categ); Commande.Connection.Open(); SqlDataReader dr = Commande.ExecuteReader(); C_t_categorie res = new C_t_categorie(); while (dr.Read()) { res.id_categ = int.Parse(dr["id_categ"].ToString()); res.nom_categ = dr["nom_categ"].ToString(); res.sal_categ = double.Parse(dr["sal_categ"].ToString()); } dr.Close(); Commande.Connection.Close(); return(res); }
public List <C_t_categorie> Lire(string Index) { CreerCommande("Selectionnert_categorie"); Commande.Parameters.AddWithValue("@Index", Index); Commande.Connection.Open(); SqlDataReader dr = Commande.ExecuteReader(); List <C_t_categorie> res = new List <C_t_categorie>(); while (dr.Read()) { C_t_categorie tmp = new C_t_categorie(); tmp.id_categ = int.Parse(dr["id_categ"].ToString()); tmp.nom_categ = dr["nom_categ"].ToString(); tmp.sal_categ = double.Parse(dr["sal_categ"].ToString()); res.Add(tmp); } dr.Close(); Commande.Connection.Close(); return(res); }
private void btnEditer_Click_1(object sender, EventArgs e) { if (dgvPrestation.SelectedRows.Count > 0) { Activer(false); tbId.Text = dgvPrestation.SelectedRows[0].Cells["IdPresta"].Value.ToString(); var travail = new G_t_travail(SChonn).Lire_ID(int.Parse(tbId.Text)); tbNomPresta.Text = travail.nom_travail; tbSalPresta.Text = Convert.ToString(travail.prix_travail, CultureInfo.InvariantCulture); dtpStart.Text = Convert.ToString(travail.date_debut, CultureInfo.CurrentCulture); dtpEnd.Text = Convert.ToString(travail.date_fin, CultureInfo.CurrentCulture); C_t_categorie categorie = Categories.Find(x => x.id_categ == travail.id_categ); C_t_facture facture = Factures.Find(x => x.id_fact == travail.id_fact); cbCategorie.Text = categorie.nom_categ; cbFacture.Text = facture.date_fact.ToString("dd/MM/yyyy"); } else { MessageBox.Show(@"There is no row selected!"); } }
private void RemplireDgv() { _info.CurrencySymbol = " € "; DtPrestation = new DataTable(); DtPrestation.Columns.Add(new DataColumn("IdPresta", Type.GetType("System.Int32") ?? throw new InvalidOperationException())); DtPrestation.Columns.Add("NomTravail"); DtPrestation.Columns.Add("DtDebut"); DtPrestation.Columns.Add("DtFin"); DtPrestation.Columns.Add("SalTravail"); DtPrestation.Columns.Add("IdCateg"); DtPrestation.Columns.Add("IdFact"); foreach (var prestation in Prestations) { C_t_categorie categorie = Categories.Find(x => x.id_categ == prestation.id_categ); C_t_facture facture = Factures.Find(x => x.id_fact == prestation.id_fact); //MessageBox.Show(facture.id_fact.ToString() + "->" + prestation.Id_travail); DtPrestation.Rows.Add(prestation.Id_travail, prestation.nom_travail, string.Format("{0:dd/MM/yyyy}", prestation.date_debut), string.Format("{0:dd/MM/yyyy}", prestation.date_fin), string.Format(_info, "{0:C}", prestation.prix_travail), categorie.nom_categ, string.Format("{0:dd/MM/yyyy}", facture.date_fact)); } BsPrestation = new BindingSource { DataSource = DtPrestation }; dgvPrestation.DataSource = BsPrestation; }
private void btnCAmensuel_Click(object sender, EventArgs e) { float total = 0f; float amount = 0f; if (dgvPrestation.Rows.Count > 0) { Document doc = new Document(PageSize.LETTER, 40, 40, 30, 25); PdfWriter pw = PdfWriter.GetInstance(doc, new FileStream(@"E:\C#\InterimDesktopApp\Doc\CAM12.pdf", FileMode.Create)); doc.Open();// opening the pdf to write in Image logo = Image.GetInstance(@"E:\C#\InterimDesktopApp\Images\circle.png"); Paragraph logo_name = new Paragraph("Circle", small_font); Paragraph date = new Paragraph("Le" + " " + DateTime.Today.ToString("dd/MM/yyyy"), date_font); Paragraph title = new Paragraph("Chiffre d'affaire mensuel par 12 mois", header_font); Paragraph newLine = new Paragraph("\n"); logo.ScalePercent(10.0f); logo.Alignment = 0;// 0 = left; 1=center ; 2=right logo.Alignment = 0; date.Alignment = 2; title.Alignment = 1; doc.Add(logo); doc.Add(logo_name); doc.Add(date); doc.Add(title); doc.Add(newLine); PdfPTable table_prestation = new PdfPTable(2); PdfPCell title_table = new PdfPCell(new Phrase("chiffre d' affaires", normal_font)); title_table.Colspan = 2; title_table.BackgroundColor = BaseColor.ORANGE; title_table.HorizontalAlignment = 1; PdfPCell col_prestation = new PdfPCell(new Phrase("Nom Prestation", normal_font)); PdfPCell col_Amount = new PdfPCell(new Phrase("Prix", normal_font)); PdfPCell description_total = new PdfPCell(new Phrase("Total")); col_prestation.HorizontalAlignment = 1; col_Amount.HorizontalAlignment = 1; table_prestation.AddCell(title_table); table_prestation.AddCell(col_prestation); table_prestation.AddCell(col_Amount); for (int i = 0; i < dgvPrestation.RowCount - 1; i++) { var nId = Convert.ToInt32(dgvPrestation.Rows[i].Cells[0].Value); C_t_travail prestation = Prestations.Find(x => x.Id_travail == (int)nId); C_t_categorie categorie = Categories.Find(x => x.id_categ == prestation.id_categ); C_t_interimeur interimeur = Interimeurs.Find(x => x.specialisation == categorie.nom_categ); //MessageBox.Show(categorie.nom_categ + "=>" + interimeur.nom_inte); amount = (float)prestation.prix_travail + (float)((prestation.prix_travail * interimeur.bonus_sal) / 100); total += amount; PdfPCell cell_prestation = new PdfPCell(new Phrase(prestation.nom_travail, normal_font)); table_prestation.AddCell(cell_prestation); table_prestation.AddCell(amount + "€"); } doc.Add(newLine); table_prestation.AddCell(description_total); table_prestation.AddCell(total.ToString() + "€"); doc.Add(table_prestation); total = 0f; doc.Close(); //closing the pdf } else { MessageBox.Show("Vous n'avez aucune prestation !"); } }
private void btnMomntLbr_Click(object sender, EventArgs e) { Document doc = new Document(PageSize.LETTER, 40, 40, 30, 25); doc.Open(); //the creation of the repport concerning " les moments libre de l'interimaire" PdfWriter pw = PdfWriter.GetInstance(doc, new FileStream(@"E:\C#\InterimDesktopApp\Doc\moments libres des interimaires.pdf", FileMode.Create)); doc.Open();//open for writing Image logo = Image.GetInstance(@"E:\C#\InterimDesktopApp\Images\circle.png"); Paragraph logo_name = new Paragraph("Circle", small_font); Paragraph date = new Paragraph("Le" + " " + DateTime.Today.ToString("dd/MM/yyyy"), date_font); Paragraph title = new Paragraph("Moments libres des interimaires par specialisation", header_font); Paragraph newLine = new Paragraph("\n"); logo.ScalePercent(10.0f); logo.Alignment = 0;// 0 = left; 1=center ; 2=right logo.Alignment = 0; date.Alignment = 2; title.Alignment = 1; doc.Add(logo); doc.Add(logo_name); doc.Add(date); doc.Add(title); doc.Add(newLine); for (int i = 0; i < dgvInterimeur.RowCount - 1; i++) { string specialite = (string)dgvInterimeur.Rows[i].Cells[3].Value; Paragraph nom_specialite = new Paragraph(specialite, header_font); nom_specialite.Alignment = 1; doc.Add(nom_specialite); doc.Add(newLine); for (int j = 0; j < dgvInterimeur.RowCount - 1; j++) { var nId = Convert.ToInt32(dgvInterimeur.Rows[j].Cells[0].Value); C_t_interimeur interimeur = Interimeurs.Find(x => x.id_inte == (int)nId); if (interimeur.specialisation == specialite) { C_t_categorie categorie = Categories.Find(x => x.nom_categ == interimeur.specialisation); C_t_travail prestation = Prestations.Find(x => x.id_categ == categorie.id_categ); //MessageBox.Show(categorie.nom_categ + "=>" + prestation.nom_travail); //if (interimeur.specialisation != specialite) continue; //else //{ //MessageBox.Show(interimeur.specialisation+" "+specialite+" "+ "=>" +prestation.date_fin.ToString("dd/MM/yyyy")); PdfPTable table_interimeur = new PdfPTable(2); PdfPCell nom_interimeur = new PdfPCell(new Phrase(interimeur.nom_inte, normal_font)); PdfPCell col_date_debut = new PdfPCell(new Phrase("Debut", normal_font)); PdfPCell col_date_fin = new PdfPCell(new Phrase("Fin", normal_font)); nom_interimeur.Colspan = 2; nom_interimeur.BackgroundColor = BaseColor.ORANGE; nom_interimeur.HorizontalAlignment = 1; col_date_debut.HorizontalAlignment = 1; col_date_fin.HorizontalAlignment = 1; table_interimeur.AddCell(nom_interimeur); table_interimeur.AddCell(col_date_debut); table_interimeur.AddCell(col_date_fin); table_interimeur.AddCell("Libre depuis"); table_interimeur.AddCell(prestation.date_fin.ToString("dd/MM/yyyy")); //table_interimeur.AddCell(interimeur.nom_inte); //table_interimeur.AddCell("nothing"); doc.Add(table_interimeur); doc.Add(newLine); // simply adding a new line //} } else { continue; } } } doc.Close(); }