Example #1
0
        public void finalePayement(DateTime date)
        {
            double preleveTot = 0;

            calculeDebt();
            if (getDebt() > 0)
            {
                foreach (ServiceSocial service in MyPret)
                {
                    if ((service is PretSociale))
                    {
                        PretSociale pret = (PretSociale)service;
                        pret.activePreleve(date);
                        preleveTot += pret.getTranshe();
                    }
                    else if ((service is Electromenager))
                    {
                        Electromenager Electro = (Electromenager)service;
                        Electro.activePreleve(date);
                        preleveTot += Electro.getTranshe();
                    }
                }
            }
            setTranshe(preleveTot);
        }
Example #2
0
        public void DemandDiffere(DateTime dt)
        {
            calculeDebt();

            if (getDebt() > 0)
            {
                List <ServiceSocial> services = new List <ServiceSocial>();
                foreach (ServiceSocial serviceSocial in myPret())
                {
                    if (serviceSocial is PretSociale)
                    {
                        PretSociale pret = (PretSociale)serviceSocial;
                        pret.demandDiffere(dt);
                        services.Add(pret);
                    }

                    else
                    {
                        services.Add(serviceSocial);
                    }
                }

                setMypret(services);
            }
            else
            {
                throw new LogiqueException("Opération non valide ! \nCe salarié n'a aucune somme à rembourser\n ");
            }
        }
        public static List <ServiceSocial> GetListPrets(int EmpID)
        {
            List <ServiceSocial> serviceSocials = new List <ServiceSocial>();
            PV            pv;   Service service; TypePret type; Bon_Cmd bon_Cmd; Facture facture;
            ServiceSocial serviceSocial;
            SqlConnection sqlConnection = new SqlConnection(constr);

            sqlConnection.Open();
            String     command    = "SELECT * FROM " + table + " WHERE EmpID = @emp ; ";
            SqlCommand sqlCommand = new SqlCommand(command, sqlConnection);

            using (sqlCommand)
            {
                sqlCommand.CommandType = CommandType.Text;
                sqlCommand.Parameters.AddWithValue("@emp", EmpID);
                SqlDataReader dataReader = sqlCommand.ExecuteReader();
                while (dataReader.Read())
                {
                    service = ConnectionService.GetService((int)dataReader[2]);
                    if (service.nom.Equals("Pret sociale"))
                    {
                        PretSociale pretSociale = new PretSociale();
                        type = new TypePret();
                        type = ConnectionTypes.GetTypePret((int)dataReader[26]);
                        pretSociale.setType(type);
                        serviceSocial = pretSociale;
                    }
                    else if (service.nom.Equals("Dons"))
                    {
                        Dons dons = new Dons();
                        type = ConnectionTypes.GetTypePret((int)dataReader[26]);
                        dons.setType(type);
                        serviceSocial = dons;
                    }
                    else if (service.nom.Equals("Credit Eledtromenager"))
                    {
                        Electromenager electromenager = new Electromenager();
                        try
                        {
                            bon_Cmd = ConnectionBonCmd.GetBonCmd((int)dataReader[0]);
                            electromenager.setBon_cmd(bon_Cmd);
                            facture = ConnectionFacture.GetFacture((int)dataReader[0]);
                            electromenager.setFournissure(facture.GetFournisseur());


                            electromenager.setFacture(facture);
                        }
                        catch { }

                        serviceSocial = electromenager;
                    }
                    else
                    {
                        serviceSocial = new Pret();
                        // Cette cas n'est pas valide
                        throw new Exception();
                    }
                    pv = ConnectionPV.GetPV((int)dataReader[3]);
                    serviceSocial.setPV(pv);
                    serviceSocial.setid((int)dataReader[0]);
                    serviceSocial.setEmployer((int)dataReader[1]);
                    serviceSocial.setPrix(Convert.ToDouble(dataReader[4]));
                    if (dataReader[25] != DBNull.Value)
                    {
                        serviceSocial.setobservation((string)dataReader[25]);
                    }
                    int             indice = 5;
                    List <Double>   prelev = new List <double>();
                    List <DateTime> dates  = new List <DateTime>();
                    while (indice < 25)
                    {
                        prelev.Add(Convert.ToDouble(dataReader[indice]));
                        indice++;
                        if (!(String.IsNullOrEmpty(dataReader[indice].ToString())))
                        {
                            dates.Add(Convert.ToDateTime(dataReader[indice]));
                        }
                        indice++;
                    }
                    serviceSocial.setDates(dates);
                    serviceSocial.setprelevements(prelev);
                    serviceSocials.Add(serviceSocial);
                }
                dataReader.Close();
            }
            sqlCommand.Dispose();
            sqlConnection.Close();
            return(serviceSocials);
        }