コード例 #1
0
        public static void ModifyPret(ServiceSocial serviceSocial)
        {
            SqlConnection sqlConnection = new SqlConnection(constr);

            if (sqlConnection.State == ConnectionState.Closed)
            {
                sqlConnection.Open();
            }
            string command = "UPDATE " + table + " SET remb1=@remb1 , date1=@date1, " +
                             " remb2=@remb2 , date2=@date2," +
                             "remb3=@remb3 , date3=@date3," +
                             "remb10=@remb10 , date10=@date10," +
                             "remb4=@remb4 , date4=@date4," +
                             "remb5=@remb5 , date5=@date5," +
                             "remb6=@remb6 , date6=@date6," +
                             "remb7=@remb7 , date7=@date7," +
                             "remb8=@remb8 , date8=@date8," +
                             "remb9=@remb9 , date9=@date9 , observation=@observation " +
                             " WHERE Id=@id ;";
            SqlCommand sqlCommand = new SqlCommand(command, sqlConnection);

            using (sqlCommand)
            {
                sqlCommand.CommandType = CommandType.Text;
                sqlCommand.Parameters.AddWithValue("@id", serviceSocial.getid());
                int j;
                for (int i = 0; i < serviceSocial.getprelevements().Count; i++)
                {
                    j = i + 1;
                    String str = "@remb" + j;
                    sqlCommand.Parameters.AddWithValue(str, serviceSocial.getprelevement(i));
                }
                for (int i = 0; i < serviceSocial.getDates().Count; i++)
                {
                    j = i + 1;
                    String str = "@date" + j;
                    sqlCommand.Parameters.AddWithValue(str, serviceSocial.getDate(i));
                }
                for (int i = serviceSocial.getDates().Count; i < 10; i++)
                {
                    j = i + 1;
                    String str = "@date" + j;
                    sqlCommand.Parameters.AddWithValue(str, DBNull.Value);
                }
                if (String.IsNullOrEmpty(serviceSocial.getobservation()))
                {
                    sqlCommand.Parameters.AddWithValue("@observation", DBNull.Value);
                }
                else
                {
                    sqlCommand.Parameters.AddWithValue("@observation", serviceSocial.getobservation());
                }
                sqlCommand.ExecuteNonQuery();
            }
            sqlCommand.Dispose();
            sqlConnection.Close();
        }
コード例 #2
0
 public void addPret(ServiceSocial pret)
 {
     if (pret != null)
     {
         MyPret.Add(pret);
         MoneyToken += pret.getPrix();
         if (!(pret is Dons))
         {
             Debt += pret.getRestAPyer();
         }
     }
 }
コード例 #3
0
        public static void DeletePret(ServiceSocial serviceSocial)
        {
            if (serviceSocial is Electromenager)
            {
                ConnectionFacture.DeleteFacture(((Electromenager)serviceSocial).GetFacture());
                ConnectionBonCmd.DeleteBonCmd(((Electromenager)serviceSocial).GetBon_Cmd());
            }
            SqlConnection sqlConnection = new SqlConnection(constr);

            sqlConnection.Open();
            String     command    = "DELETE FROM " + table + " WHERE Id = @id ;";
            SqlCommand sqlCommand = new SqlCommand(command, sqlConnection);

            using (sqlCommand)
            {
                sqlCommand.CommandType = CommandType.Text;
                sqlCommand.Parameters.AddWithValue("@id", serviceSocial.getid());
                sqlCommand.ExecuteNonQuery();
            }
            sqlCommand.Dispose();
            sqlConnection.Close();
        }
コード例 #4
0
 public void setPret(int i, ServiceSocial serviceSocial)
 {
     MyPret[i] = serviceSocial;
 }
コード例 #5
0
 public void removePret(ServiceSocial pret)
 {
     MyPret.Remove(pret);
 }
コード例 #6
0
        public static void AddPret(ServiceSocial serviceSocial)
        {
            SqlConnection sqlConnection = new SqlConnection(constr);

            sqlConnection.Open();
            String Command = "INSERT INTO " + table + " VALUES (@Id , @Emp , @service ," +
                             "@pv , @somme , @remb1 , @date1 , @remb2 , @date2 , @remb3 , @date3" +
                             ", @remb4 , @date4 , @remb5 , @date5" +
                             ", @remb6 , @date6 , @remb7 , @date7 , @remb8 , @date8" +
                             ", @remb9 , @date9 , @remb10 , @date10 ,@observation ,@type ) ; ";
            SqlCommand sqlCommand = new SqlCommand(Command, sqlConnection);

            using (sqlCommand)
            {
                sqlCommand.CommandType = CommandType.Text;
                sqlCommand.Parameters.AddWithValue("@Id", serviceSocial.getid());
                sqlCommand.Parameters.AddWithValue("@Emp", serviceSocial.getEmployer());
                if (serviceSocial is PretSociale)
                {
                    sqlCommand.Parameters.AddWithValue("@service", 1);
                }
                else if (serviceSocial is Dons)
                {
                    sqlCommand.Parameters.AddWithValue("@service", 2);
                }
                else // Credit Electromenager
                {
                    sqlCommand.Parameters.AddWithValue("@service", 3);
                }
                sqlCommand.Parameters.AddWithValue("@pv", serviceSocial.getPV().getId());
                sqlCommand.Parameters.AddWithValue("@somme", serviceSocial.getPrix());

                int j;
                for (int i = 0; i < serviceSocial.getprelevements().Count; i++)
                {
                    j = i + 1;
                    String str = "@remb" + j;
                    sqlCommand.Parameters.AddWithValue(str, serviceSocial.getprelevement(i));
                }
                for (int i = 0; i < serviceSocial.getDates().Count; i++)
                {
                    j = i + 1;
                    String str = "@date" + j;
                    sqlCommand.Parameters.AddWithValue(str, serviceSocial.getDate(i));
                }
                for (int i = serviceSocial.getDates().Count; i < 10; i++)
                {
                    j = i + 1;
                    String str = "@date" + j;
                    sqlCommand.Parameters.AddWithValue(str, DBNull.Value);
                }
                if (String.IsNullOrEmpty(serviceSocial.getobservation()))
                {
                    sqlCommand.Parameters.AddWithValue("@observation", DBNull.Value);
                }
                else
                {
                    sqlCommand.Parameters.AddWithValue("@observation", serviceSocial.getobservation());
                }
                if (serviceSocial is Pret)
                {
                    TypePret type = ((Pret)serviceSocial).getTypePret();
                    sqlCommand.Parameters.AddWithValue("@type", type.Id);
                }
                else
                {
                    sqlCommand.Parameters.AddWithValue("@type", DBNull.Value);
                }

                sqlCommand.ExecuteNonQuery();
            }
            sqlCommand.Dispose();
            sqlConnection.Close();
            try
            {
                if (serviceSocial is Electromenager)
                {
                    ConnectionBonCmd.AddBonCmd(((Electromenager)serviceSocial).GetBon_Cmd());
                    ConnectionFacture.AddFacture(((Electromenager)serviceSocial).GetFacture());
                }
            }
            catch { }
        }