Ejemplo n.º 1
0
 // PUT: api/Facturation/5
 public void Put(int id, [FromBody] Facturation factu)
 {
     try
     {
         if (factu != null)                                                               // si l'objet source n'est pas null => update de la base
         {
             Facturation ts = db.Facturation.Where(res => res.ID == id).FirstOrDefault(); // recuperer la tache pointé par l'id pris en paramètre de la fonction
             db.Facturation.Attach(ts);                                                   // Faire ecouter le contexte de base de donnée sur les changements de l'objet ts
             ts.Commande = factu.Commande;                                                // changement des différents attribut de l'objet pointé avec les attributs de l'objet pris en paramètre
             ts.Mois     = factu.Mois;                                                    // same
             ts.Montant  = factu.Montant;                                                 // same
             ts.FK_Devis = factu.FK_Devis;                                                // same
             ts.Date     = factu.Date;                                                    // same
             ts.Filename = factu.Filename;                                                // same
             db.SaveChanges();                                                            // mise a jour de la table
         }
         else // sinon je throw une exception
         {
             throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, "l'objet source est vide"));
         }
     }
     catch (Exception e)
     {
         throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e.Message));
     }
 }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text != null)
            {
                try
                {
                    data = new SqlDataAdapter("select * from Facture where CodeComm=" + comboBox1.Text, con);
                    data.Fill(set, "Facture");
                    data = new SqlDataAdapter("select C.* from Commande as C inner Join Facture as F on C.Codecommande=F.CodeComm where F.CodeComm=" + comboBox1.Text, con);
                    data.Fill(set, "Commande");
                    data = new SqlDataAdapter("select Cl.* from Client as Cl inner join Commande as C on C.CodeClient=Cl.Codeclient inner Join Facture as F on C.Codecommande=F.CodeComm where F.CodeComm=" + comboBox1.Text, con);
                    data.Fill(set, "Client");
                    Facturation f = new Facturation();
                    f.SetDataSource(set);
                    Report_Viewer_Form r = new Report_Viewer_Form();
                    r.Text = "Facture N° " + comboBox1.Text;
                    r.crystalReportViewer1.ReportSource = f;
                    r.Show();
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Voulez choisir une Facture", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Edit(long id, [Bind("FacturationId,AchatId,PrixTotal")] Facturation facturation)
        {
            if (id != facturation.FacturationId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(facturation);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FacturationExists(facturation.FacturationId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AchatId"] = new SelectList(_context.Achat, "AchatId", "AchatId", facturation.AchatId);
            return(View(facturation));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("FacturationId,AchatId,PrixTotal")] Facturation facturation)
        {
            if (ModelState.IsValid)
            {
                _context.Add(facturation);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AchatId"] = new SelectList(_context.Achat, "AchatId", "AchatId", facturation.AchatId);
            return(View(facturation));
        }
Ejemplo n.º 5
0
        // GET: api/Facturation/5
        public Facturation Get(int id)
        {
            Facturation res = this.db.Facturation.Where(s => s.ID == id).FirstOrDefault();   // renvoi l'objet pointé par l'id pris en paramètre

            if (res != null)
            {
                return(res);
            }
            else
            {
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, "pas d'objet pour cet ID"));
            }
        }
Ejemplo n.º 6
0
 // DELETE: api/Facturation/5
 public void Delete(int id)
 {
     try                                                                              // vérrif si un objet a été trouvé pour l'id
     {
         Facturation ts = db.Facturation.Where(res => res.ID == id).FirstOrDefault(); // récupération de la tache pointé par l'id
         db.Facturation.Attach(ts);                                                   // ecouter les changement de l'objet
         db.Facturation.Remove(ts);                                                   // remove l'objet ts
         db.SaveChanges();                                                            // mettre a jour la table
     }
     catch (Exception e)
     {
         throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Pas d'objet pour cet Id"));
     }
 }
Ejemplo n.º 7
0
        public static void FacturerCommande_Print(int CodeCommande)
        {
            try
            {
                int CodeFacture = int.Parse(ExecuteScalar("select CodeFacture from Facture where CodeComm = '" + CodeCommande + "'").ToString());

                DataSet Data_Set = getFacture(CodeCommande);

                Facturation reportCommande = new Facturation();
                reportCommande.SetDataSource(Data_Set);

                Report_Viewer_Form frm = new Report_Viewer_Form();
                frm.Text = "Facture N°: " + CodeFacture + " pour la commande N°: " + CodeCommande;
                frm.crystalReportViewer1.ReportSource = reportCommande;
                frm.Show();
            }
            catch (Exception Err)
            {
                MessageBox.Show(Err.Message, "Un Erreur est survenue", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 8
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                data = new SqlDataAdapter("select CodeFacture,Total from Facture where CodeComm=" + textBox6.Text, con);
                data.Fill(set, "Facture");
                data = new SqlDataAdapter("select C.CodeDepot,C.CodeClient,C.DateCommande,C.Codecommande from Commande as C inner Join Facture as F on C.Codecommande=F.CodeComm where F.CodeComm=" + textBox6.Text, con);
                data.Fill(set, "Commande");
                data = new SqlDataAdapter("select Cl.Nom,Cl.Prenom,Cl.Cin,Cl.Tel,Cl.Adresse,Cl.Email from Client as Cl inner join Commande as C on C.CodeClient=Cl.Codeclient inner Join Facture as F on C.Codecommande=F.CodeComm where F.CodeComm=" + textBox6.Text, con);
                data.Fill(set, "Client");
                Facturation f = new Facturation();
                f.SetDataSource(set);
                Report_Viewer_Form r = new Report_Viewer_Form();
                r.Text = "Facture N° " + textBox6.Text;
                r.crystalReportViewer1.ReportSource = f;
                r.Show();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 9
0
        // POST: api/Facturation
        public void Post(object genObjec_f)
        {
            var           stringed     = genObjec_f.ToString();
            GeneralObject newGenObject = JsonConvert.DeserializeObject <GeneralObject>(stringed);

            foreach (Projet p in newGenObject.projets)
            {
                p.découpageStories.Add("B", new List <MasterStories>());
                p.découpageStories.Add("PR", new List <MasterStories>());
                p.découpageStories.Add("PNR", new List <MasterStories>());
                foreach (MasterStories s in p.Stories)
                {
                    if ((bool)s.Bonus)
                    {
                        p.découpageStories["B"].Add(s);
                    }
                    else if (s.nonEffetue)
                    {
                        p.découpageStories["PNR"].Add(s);
                    }
                    else
                    {
                        p.découpageStories["PR"].Add(s);
                    }
                }
            }
            Calculator devisCalculator = new Calculator(newGenObject);
            //DevisCalculator devisCalculator = new DevisCalculator(genObjec_d);
            SumManager  resultFromcallCalculator = devisCalculator.CalculateFactu();
            Facturation facturation = new Facturation();
            FileFiller  filler      = new FileFiller(facturation, true, resultFromcallCalculator, newGenObject);

            //StreamWriter logFile = new StreamWriter(System.AppDomain.CurrentDomain.BaseDirectory + @"\Content\test.txt");
            //logFile.WriteLine("je suis juste un petit fichier de test qui va me permettre de savoir si j'arriva a renvoyer des fichiers au clients");
            //logFile.Close();
            //  DateTime longDate = DateTime.Now;
            //var path = System.AppDomain.CurrentDomain.BaseDirectory + @"\Content\Devis" + longDate.Year.ToString() + "_" + longDate.AddMonths(-1).Month + @"\" + "Etat_des_lieux_VS_Devis_initial_All_NS_Reneco_" + longDate.Year.ToString() + "_" + longDate.AddMonths(-1).Month + ".docx";
            //HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
            //var stream = new FileStream(path, FileMode.Open);
            //result.Content = new StreamContent(stream);
            //result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
            //result.Content.Headers.ContentDisposition.FileName = Path.GetFileName(path);
            //result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
            //result.Content.Headers.ContentLength = stream.Length;

            // string strdocPath;
            //strdocPath = System.AppDomain.CurrentDomain.BaseDirectory + @"\Content\Devis" + longDate.Year.ToString() + "_" + longDate.AddMonths(-1).Month + @"\Calcul" + ".txt";
            // strdocPath = System.AppDomain.CurrentDomain.BaseDirectory + @"\Content\Devis" + longDate.Year.ToString() + "_" + longDate.AddMonths(-1).Month + @"\" + "Etat_des_lieux_VS_Devis_initial_All_NS_Reneco_" + longDate.Year.ToString() + "_" + longDate.AddMonths(-1).Month + ".docx";

            //FileStream objfilestream = new FileStream(strdocPath, FileMode.Open, FileAccess.Read);
            //int len = (int)objfilestream.Length;
            // Byte[] documentcontents = File.ReadAllBytes(strdocPath);
            // objfilestream.Read(documentcontents, 0, len);
            // objfilestream.Close();

            //string stringFile = Convert.ToBase64String(documentcontents);

            //HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, "value");
            //response.Content = new StringContent(stringFile, Encoding.UTF8);
            //response.Content = new StringContent(stringFile);
            //response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.wordprocessingml.document");

            //return response;
            newGenObject.SaveToDb(true, facturation);
            //return new HttpResponseMessage(HttpStatusCode.Accepted);
            //}
            //catch (Exception e)
            //{
            //    throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, e.Message)); //lance exception si un attribut dans l'objet est nulle
            //}
        }
Ejemplo n.º 10
0
        public List <Employed> getListEmployed()
        {
            //int idEmployed = 0;

            List <Employed> listEmployed = new List <Employed>();
            // List<Dependecy> listDependecies = new List<Dependecy>();
            var QueryDistinct = from employed in dbContext.t_beneficiaires
                                join Succursal in dbContext.t_succursales on employed.C_id_succ equals Succursal.C_id
                                join Departement in dbContext.t_departement on employed.C_id_depart equals Departement.C_id


                                select new{ employed, Succursal, Departement };



            var Query = from employed in dbContext.t_beneficiaires
                        join bonCommand in dbContext.t_bon_commandes on employed.C_id equals bonCommand.C_id_bene
                        join Facturation in dbContext.t_factures on bonCommand.C_id_bon equals Facturation.C_id_bon
                        into Facturation from subfacturation in Facturation.DefaultIfEmpty()
                        join CenterHealth in dbContext.t_centre_soins on bonCommand.C_id_centre equals CenterHealth.C_id_centre
                        join Succursal in dbContext.t_succursales on employed.C_id_succ equals Succursal.C_id
                        join Departement in dbContext.t_departement on employed.C_id_depart equals Departement.C_id


                        select new { employed, bonCommand, subfacturation, CenterHealth, Succursal, Departement };


            foreach (var query in QueryDistinct)
            {
                List <BonCommand> listDependecies = new List <BonCommand>();
                List <BonCommand> MyFacturations  = new List <BonCommand>();


                int    id       = query.employed.C_id;
                string _id      = id.ToString();
                var    result   = Query.Where(x => x.employed.C_id.Equals(id)).FirstOrDefault();
                int    nbreBCmd = Query.Where(x => x.employed.C_id.Equals(id)).ToList().Count;

                foreach (var itemMyFact in Query.Where(x => x.employed.C_id.Equals(id)))
                {
                    BonCommand Bcommand = new BonCommand
                    {
                        id             = itemMyFact.bonCommand.C_id_bon,
                        datecmd        = itemMyFact.bonCommand.C_datedeb,
                        dateValidation = itemMyFact.bonCommand.C_datefin,
                        motif          = itemMyFact.bonCommand.C_motif,
                        idBene         = itemMyFact.bonCommand.C_id_bene.Value,
                        idHealth       = itemMyFact.CenterHealth.C_name,
                        cout           = (decimal)(itemMyFact.subfacturation == null ? (0.0M) : itemMyFact.subfacturation.C_cout),
                        nameDoctor     = itemMyFact.bonCommand.C_namedoctor,
                        dateFacture    = (itemMyFact.subfacturation == null ? String.Empty:itemMyFact.subfacturation.C_datefacture),
                        nameAuthor     = itemMyFact.employed.C_name
                    };
                    if (itemMyFact.subfacturation != null)
                    {
                        MyFacturations.Add(Bcommand);
                    }
                }
                var dependecies = from beneficiaire in dbContext.t_beneficiaires
                                  join bonCommand in dbContext.t_bon_commandes on beneficiaire.C_id equals bonCommand.C_id_bene
                                  join Facturation in dbContext.t_factures on bonCommand.C_id_bon equals Facturation.C_id_bon
                                  into Facturation
                                  from subFacturation in Facturation.DefaultIfEmpty()
                                  join CenterHealth in dbContext.t_centre_soins on bonCommand.C_id_centre equals CenterHealth.C_id_centre
                                  where beneficiaire.C_id_parent.Equals(_id) || beneficiaire.C_id_partenaire.Equals(_id) && beneficiaire.C_id_succ.Equals(null)
                                  select new { beneficiaire, subFacturation, CenterHealth, bonCommand };

                int nbreChilds = dependecies.ToList().Count;

                foreach (var itemCmd in dependecies)
                {
                    int        idBon = itemCmd.bonCommand.C_id_bon;
                    BonCommand bcmd  = new BonCommand
                    {
                        id             = itemCmd.bonCommand.C_id_bon,
                        datecmd        = itemCmd.bonCommand.C_datedeb,
                        dateValidation = itemCmd.bonCommand.C_datefin,
                        nameDoctor     = itemCmd.bonCommand.C_namedoctor,
                        motif          = itemCmd.bonCommand.C_motif,
                        idBene         = itemCmd.bonCommand.C_id_bene.Value,
                        idHealth       = itemCmd.CenterHealth.C_name,
                        cout           = (decimal)(itemCmd.subFacturation == null?(0.0M):itemCmd.subFacturation.C_cout),
                        nameAuthor     = itemCmd.beneficiaire.C_name,
                        sexeAuthor     = itemCmd.beneficiaire.C_sex,
                        dateFacture    = (itemCmd.subFacturation == null?string.Empty:itemCmd.subFacturation.C_datefacture)
                    };
                    if (itemCmd.subFacturation != null)
                    {
                    }

                    listDependecies.Add(bcmd);
                }

                // this.AddMyFacturation(query.employed.C_id);
                if (result != null)
                {
                    Employed employed = new Employed
                    {
                        Matricule      = query.employed.C_mat,
                        id             = query.employed.C_id.ToString(),
                        name           = result.employed.C_name,
                        sex            = result.employed.C_sex,
                        phone          = result.employed.C_phone,
                        datenaiss      = result.employed.C_datenais,
                        CivilStatus    = result.employed.C_statusmaritalk,
                        picture        = result.employed.C_picture,
                        ID_Succursale  = result.Succursal.C_name,
                        ID_Departement = result.Departement.C_id_depart,
                        CtrBon         = nbreBCmd,
                        nbreDepencies  = nbreChilds,
                        dependecies    = listDependecies,
                        Facturations   = MyFacturations
                    };

                    listEmployed.Add(employed);
                }
                else
                {
                    if (nbreChilds > 0)
                    {
                        Employed employed = new Employed
                        {
                            Matricule      = query.employed.C_mat,
                            id             = query.employed.C_id.ToString(),
                            name           = query.employed.C_name,
                            sex            = query.employed.C_sex,
                            phone          = query.employed.C_phone,
                            datenaiss      = query.employed.C_datenais,
                            CivilStatus    = query.employed.C_statusmaritalk,
                            picture        = query.employed.C_picture,
                            ID_Succursale  = query.Succursal.C_name,
                            ID_Departement = query.Departement.C_id_depart,
                            CtrBon         = 0,
                            nbreDepencies  = nbreChilds,
                            dependecies    = listDependecies
                        };

                        listEmployed.Add(employed);
                    }
                }
            }
            // HttpContext.Current.Session.Add("reporting", listEmployed);
            return(listEmployed);
        }
Ejemplo n.º 11
0
        public void SaveToDb(bool isFactu, dynamic fichier)
        {
            DevisFacturationEntities db = new DevisFacturationEntities();

            if (!isFactu)
            {
                fichier = (Devis)fichier;
            }
            else
            {
                fichier = (Facturation)fichier;
            }
            switch (isFactu)
            {
            case false:
                List <Devis> lesdevis = db.Devis.Where(devisVerif => devisVerif.Commande.Trim().ToLower() == this.epic.Trim().ToLower()).ToList();
                if (lesdevis.Count() > 0)
                {
                    Devis devisAsupprimer = lesdevis[0];
                    fichier = lesdevis[0];
                    List <Stories_Devis> storiesDevisASuprimer = db.Stories_Devis.Where(stdevis => stdevis.FK_Devis == devisAsupprimer.ID).ToList();
                    foreach (Stories_Devis myStoriesDevis in storiesDevisASuprimer)
                    {
                        Stories_d      storyASupprimer  = db.Stories_d.Where(sas => sas.ID == myStoriesDevis.FK_Stories_d).FirstOrDefault();
                        List <Tasks_d> tachesAsupprimer = db.Tasks_d.Where(tachasup => tachasup.FK_Stories_d == storyASupprimer.ID).ToList();
                        foreach (Tasks_d ta in tachesAsupprimer)
                        {
                            db.Tasks_d.Remove(ta);
                        }
                        db.Stories_d.Remove(storyASupprimer);
                        db.Stories_Devis.Remove(myStoriesDevis);
                    }
                    devisAsupprimer.Date = DateTime.Now;
                    db.SaveChanges();
                    foreach (Projet p in this.projets)
                    {
                        if (!this.verifyProjectExist(p))
                        {
                            p.save();
                        }
                        foreach (MasterStories s in p.Stories)
                        {
                            Stories_d     stories_d     = new Stories_d(s);
                            Stories_Devis stories_Devis = new Stories_Devis();
                            Projet        proj          = db.Projet.Where(pro => pro.Nom.Trim().ToLower() == p.Nom.Trim().ToLower()).FirstOrDefault();
                            stories_d.Fk_Project   = proj.Id;
                            stories_d.IsPayed      = false;
                            stories_d.Epic         = this.epic;
                            stories_Devis.FK_Devis = fichier.ID;
                            stories_d.save();
                            stories_Devis.FK_Stories_d = stories_d.ID;
                            stories_Devis.CreationDate = DateTime.Now;
                            db.Stories_Devis.Add(stories_Devis);
                            db.SaveChanges();
                            foreach (MasterTasks ts in s.Tasks)
                            {
                                Tasks_d  tasks_d   = new Tasks_d(ts);
                                string[] initiales = tasks_d.Initials.Split('+');
                                foreach (string init in initiales)
                                {
                                    Ressource myressource = db.Ressource.Where(rez => rez.Initial == init).FirstOrDefault();
                                    tasks_d.Fk_Ressource_Initials += myressource.ID + ";";
                                }
                                tasks_d.FK_Stories_d = stories_d.ID;
                                tasks_d.save();
                            }
                        }
                    }
                }
                break;

            case true:
                List <Facturation> lesFacturations = db.Facturation.Where(devisVerif => devisVerif.Commande.Trim().ToLower() == this.epic.Trim().ToLower()).ToList();
                if (lesFacturations.Count() > 0)
                {
                    Facturation facturationASupprimer = lesFacturations[0];
                    fichier = lesFacturations[0];
                    List <Stories_Facturation> storiesDevisASuprimer = db.Stories_Facturation.Where(stdevis => stdevis.FK_Facturation == facturationASupprimer.ID).ToList();
                    foreach (Stories_Facturation myStoriesFacturation in storiesDevisASuprimer)
                    {
                        Stories_f      storyASupprimer  = db.Stories_f.Where(sas => sas.ID == myStoriesFacturation.FK_Stories_f).FirstOrDefault();
                        List <Tasks_f> tachesAsupprimer = db.Tasks_f.Where(tachasup => tachasup.FK_Stories_f == storyASupprimer.ID).ToList();
                        foreach (Tasks_f ta in tachesAsupprimer)
                        {
                            db.Tasks_f.Remove(ta);
                        }
                        db.Stories_f.Remove(storyASupprimer);
                        db.Stories_Facturation.Remove(myStoriesFacturation);
                    }
                    facturationASupprimer.Date = DateTime.Now;
                    db.SaveChanges();
                    foreach (Projet p in this.projets)
                    {
                        if (!this.verifyProjectExist(p))
                        {
                            p.save();
                        }
                        foreach (MasterStories s in p.Stories)
                        {
                            Stories_f           stories_f           = new Stories_f(s);
                            Stories_Facturation stories_Facturation = new Stories_Facturation();
                            Projet proj = db.Projet.Where(pro => pro.Nom.Trim().ToLower() == p.Nom.Trim().ToLower()).FirstOrDefault();
                            stories_f.Fk_Project = proj.Id;
                            stories_f.IsPayed    = true;
                            stories_f.Epic       = this.epic;
                            stories_Facturation.FK_Facturation = fichier.ID;
                            stories_f.save();
                            stories_Facturation.FK_Stories_f = stories_f.ID;
                            stories_Facturation.CreationDate = DateTime.Now;
                            db.Stories_Facturation.Add(stories_Facturation);
                            db.SaveChanges();
                            foreach (MasterTasks ts in s.Tasks)
                            {
                                Tasks_f  tasks_f   = new Tasks_f(ts);
                                string[] initiales = tasks_f.Initials.Split('+');
                                foreach (string init in initiales)
                                {
                                    Ressource myressource = db.Ressource.Where(rez => rez.Initial == init).FirstOrDefault();
                                    tasks_f.Fk_Ressource_Initials += myressource.ID + ";";
                                }
                                tasks_f.FK_Stories_f = stories_f.ID;
                                tasks_f.save();
                            }
                        }
                    }
                }
                break;
            }
        }