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 btnEditer_Click(object sender, EventArgs e) { if (dgvFacture.SelectedRows.Count > 0) { Activer(false); tbId.Text = dgvFacture.SelectedRows[0].Cells["IdFact"].Value.ToString(); var facture = new G_t_facture(SChonn).Lire_ID(int.Parse(tbId.Text)); C_t_entreprise entreprise = Entreprises.Find(x => x.id_entre == facture.id_entre); C_t_interimeur interimeur = Interimeurs.Find(x => x.id_inte == facture.id_inte); dtpFacture.Value = facture.date_fact; cbEntre2.Text = entreprise.nom_entre.ToString(); cbInte2.Text = interimeur.nom_inte.ToString(); } else { MessageBox.Show(@"There is no row selected!"); } }
private void RemplireDgv() { DtFacture = new DataTable(); DtFacture.Columns.Add(new DataColumn("IdFact", Type.GetType("System.Int32") ?? throw new InvalidOperationException())); DtFacture.Columns.Add("DateFact"); DtFacture.Columns.Add("IdEntre"); DtFacture.Columns.Add("IdInte"); List <C_t_facture> factures = new G_t_facture(SChonn).Lire("Nom"); foreach (C_t_facture facture in factures) { C_t_entreprise entreprise = Entreprises.Find(x => x.id_entre == facture.id_entre); C_t_interimeur interimeur = Interimeurs.Find(x => x.id_inte == facture.id_inte); DtFacture.Rows.Add(facture.id_fact, facture.date_fact.ToString("dd/MM/yyyy"), entreprise.nom_entre, interimeur.nom_inte); } BsFacture = new BindingSource { DataSource = DtFacture }; dgvFacture.DataSource = BsFacture; }
private void btnConfirmer_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(tbId.Text)) { var nId = new G_t_facture(SChonn).Ajouter(dtpFacture.Value, Convert.ToInt32(cbEntre.SelectedItem), Convert.ToInt32(cbInte.SelectedItem)); DtFacture.Rows.Add(nId, DtFacture, cbEntre.SelectedItem, cbInte.SelectedItem); } else { var nId = int.Parse(tbId.Text); C_t_interimeur interimeur = Interimeurs.Find(x => x.nom_inte == cbInte2.Text); C_t_entreprise entreprise = Entreprises.Find(x => x.nom_entre == cbEntre2.Text); new G_t_facture(SChonn).Modifier(nId, dtpFacture.Value, interimeur.id_inte, entreprise.id_entre); dgvFacture.SelectedRows[0].Cells["DateFact"].Value = DtFacture; dgvFacture.SelectedRows[0].Cells["IdEntre"].Value = cbEntre.Text; dgvFacture.SelectedRows[0].Cells["IdInte"].Value = cbInte.Text; BsFacture.EndEdit(); Activer(true); } RefreshDgv(); ClearTb(); }