public Historique(Client cli, double sum, double newSold, DateTime transacDate) { client = cli; transactionSum = sum; soldAfterTransaction = newSold; transactionDate = transacDate; }
public static bool LinkClientAndCarteBancaire(Client currentClient, CarteBancaire currentCard) { List<ClientCarteBancaire> clientCarteBancaireDB = ClientCarteBancaireDAO.Search("ID_CLIENT='" + currentClient.ClientId + "' AND ID_CARTE_BANCAIRE = '" + currentCard.BankCardId + "'"); if (clientCarteBancaireDB.Any()) return false; ClientCarteBancaire newCarte = new ClientCarteBancaire(currentClient, currentCard); ClientCarteBancaireDAO.Insert(newCarte); return true; }
public static void Update(Client client) { SqlCommand cmd = new SqlCommand(); const string query = "UPDATE CLIENT set LOGIN_CLIENT = '{0}', PASSWORD='******', NOM='{2}', PRENOM='{3}', SOLDE='{4}', IS_DELETE='{5}' where ID_CLIENT='{6}'"; cmd.CommandText = string.Format(query, client.ClientLogin, client.Password, client.Name, client.FirstName, client.Sold.ToString().Replace(",","."), client.IsDelete ? "1" : "0", client.ClientId.ToString()); cmd.CommandType = CommandType.Text; cmd.Connection = BDDConnexion.Conn; try { cmd.ExecuteNonQuery(); } catch (Exception e) { throw (e); } finally { cmd.Dispose(); cmd = null; } }
public static void Insert(Client client) { SqlCommand cmd = new SqlCommand(); const string query = "INSERT INTO CLIENT VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')"; cmd.CommandText = string.Format(query, GenerateId().ToString(), client.ClientLogin, client.Password, client.Name , client.FirstName, DateTime.Now.ToShortDateString(), client.Sold.ToString().Replace(",", "."), client.IsDelete ? "1" : "0"); cmd.CommandType = CommandType.Text; cmd.Connection = BDDConnexion.Conn; try { cmd.ExecuteNonQuery(); } catch (Exception e) { throw (e); } finally { cmd.Dispose(); cmd = null; } }
public string NewUser(string login, string pwdClient, string nameClient, string firstNameClient, double soldClient) { String msg = string.Empty; try { List<Client> clientDB = ClientDAO.Search("LOGIN_CLIENT = '" + login + "'"); if (!clientDB.Any()) { Client newClient = new Client( login, pwdClient, nameClient, firstNameClient, DateTime.Now, soldClient, false); ClientDAO.Insert(newClient); msg = "OK"; } else { throw new Exception ("Création du compte impossible: le login " + login + " est déjà utilisé pour un compte existant déjà en base."); } BDDConnexion.CloseConnection(); } catch(Exception ex) { msg = ex.Message; } return msg; }
public string DeleteAccount(int idAdmin, int idClient) { String msg = string.Empty; try { List<Client> clientDB = ClientDAO.Search("ID_CLIENT = '" + idClient + "' AND IS_DELETE = '0'"); if (clientDB.Any()) { Client newClient = new Client(clientDB[0].ClientId, clientDB[0].ClientLogin, clientDB[0].Password, clientDB[0].Name, clientDB[0].FirstName, clientDB[0].InscriptionDate, clientDB[0].Sold, true); ClientDAO.Insert(newClient); msg = "Le compte de " + clientDB[0].Name + " " + clientDB[0].FirstName + " vient d'être supprimé par l'administrateur: "+ AdministrateurDAO.Read(idAdmin).Name; } else { throw new Exception ("Le compte associé au login n'existe pas en base ou bien a déjà été supprimé par un administrateur."); } BDDConnexion.CloseConnection(); } catch(Exception ex) { msg=ex.Message; } return msg; }
public Historique(Client cli, double sum, double newSold) { client = cli; transactionSum = sum; soldAfterTransaction = newSold; }
private static List<Client> ExecuteReader(SqlCommand cmd) { SqlDataReader reader = cmd.ExecuteReader(); List<Client> result = new List<Client>(); try { while (reader.Read()) { Client currentClient = new Client(Convert.ToInt32(reader["ID_CLIENT"]), reader["LOGIN_CLIENT"].ToString(), reader["PASSWORD"].ToString() ,reader["NOM"].ToString(), reader["PRENOM"].ToString(), DateTime.Parse(reader["DATE_INSCRIPTION"].ToString()) , Convert.ToDouble(reader["SOLDE"]), (Convert.ToInt32(reader["IS_DELETE"]) == 1)); result.Add(currentClient); } } catch (Exception e) { throw (e); } finally { reader.Close(); reader.Dispose(); reader = null; } return result; }
public ClientCarteBancaire(Client cli, CarteBancaire bankcard) { client = cli; bankCard = bankcard; }