Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        public C_t_facture Lire_ID(int id_fact)
        {
            CreerCommande("Selectionnert_facture_ID");
            Commande.Parameters.AddWithValue("@id_fact", id_fact);
            Commande.Connection.Open();
            SqlDataReader dr  = Commande.ExecuteReader();
            C_t_facture   res = new C_t_facture();

            while (dr.Read())
            {
                res.id_fact   = int.Parse(dr["id_fact"].ToString());
                res.date_fact = DateTime.Parse(dr["date_fact"].ToString());
                res.id_inte   = int.Parse(dr["id_inte"].ToString());
                res.id_entre  = int.Parse(dr["id_entre"].ToString());
            }
            dr.Close();
            Commande.Connection.Close();
            return(res);
        }
Exemplo n.º 4
0
        public List <C_t_facture> Lire(string Index)
        {
            CreerCommande("Selectionnert_facture");
            Commande.Parameters.AddWithValue("@Index", Index);
            Commande.Connection.Open();
            SqlDataReader      dr  = Commande.ExecuteReader();
            List <C_t_facture> res = new List <C_t_facture>();

            while (dr.Read())
            {
                C_t_facture tmp = new C_t_facture();
                tmp.id_fact   = int.Parse(dr["id_fact"].ToString());
                tmp.date_fact = DateTime.Parse(dr["date_fact"].ToString());
                tmp.id_inte   = int.Parse(dr["id_inte"].ToString());
                tmp.id_entre  = int.Parse(dr["id_entre"].ToString());
                res.Add(tmp);
            }
            dr.Close();
            Commande.Connection.Close();
            return(res);
        }
Exemplo n.º 5
0
 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!");
     }
 }
Exemplo n.º 6
0
 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;
 }
Exemplo n.º 7
0
        private void btnCA_Click(object sender, EventArgs e)
        {
            float total  = 0f;
            float amount = 0f;

            if (dgvFacture.Rows.Count > 0)
            {
                Document  doc = new Document(PageSize.LETTER, 40, 40, 30, 25);
                PdfWriter pw  = PdfWriter.GetInstance(doc, new FileStream(@"E:\C#\InterimDesktopApp\Doc\CAM12mois.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("Chiffres d'affaire mensuel", 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("Chiffres 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 < dgvFacture.RowCount - 1; i++)
                {
                    var            nId        = Convert.ToInt32(dgvFacture.Rows[i].Cells[0].Value);
                    C_t_facture    facture    = Factures.Find(x => x.id_fact == (int)nId);
                    C_t_travail    prestation = Prestations.Find(x => x.id_fact == facture.id_fact);
                    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 pas de facture dans votre base de données");
            }
        }