private void btnReload_Click(object sender, EventArgs e) { // permet de recharger son compte int addMonney; if (!(string.IsNullOrEmpty(tbReload.Text) || string.IsNullOrWhiteSpace(tbReload.Text))) { if (!Int32.TryParse(tbReload.Text, out addMonney)) using (var info = new InformationBox("La valeur rentrée n'est pas un entier")) { info.ShowDialog(); } else { if (addMonney < 1) return; string result = Service.GetPaymentService.CreditTransaction(currentClient.clientId, Convert.ToDouble(addMonney)); if (!(result == "OK")) using (var info = new InformationBox(result)) { info.ShowDialog(); } else { tbReload.Text = string.Empty; RefreshScreen(); } } } }
public List<CartesBancaire> GetCartes() { try { var result = Service.GetPaymentService.GetCarteBancaire(this.clientId).ToList(); if (result.Count != 0 && result[0].Count<2) using (var info = new InformationBox(result[0][0])) { info.ShowDialog(); return null; } List<CartesBancaire> cartes = new List<CartesBancaire> { }; foreach (var currentCarte in result) { cartes.Add(new CartesBancaire(Int32.Parse(currentCarte[0]), DateTime.Parse(currentCarte[1]), Int32.Parse(currentCarte[2]), currentCarte[3], currentCarte[4])); } return cartes; } catch (Exception ex) { using (var info = new InformationBox(ex.Message)) { info.ShowDialog(); return null; } } }
private DialogResult DoInscription() { // fait l'inscription if (string.IsNullOrEmpty(tbLogin.Text) || string.IsNullOrEmpty(tbPassword.Text) || string.IsNullOrEmpty(tbFirstName.Text) || string.IsNullOrEmpty(tbName.Text) || string.IsNullOrWhiteSpace(tbLogin.Text) || string.IsNullOrWhiteSpace(tbPassword.Text) || string.IsNullOrWhiteSpace(tbFirstName.Text) || string.IsNullOrWhiteSpace(tbName.Text)) return this.DialogResult = DialogResult.No; string result = Service.GetPaymentService.NewUser(tbLogin.Text, tbPassword.Text, tbName.Text, tbFirstName.Text, 0); if (!result.Equals("OK")) { InformationBox info = new InformationBox(result); using (info) { info.ShowDialog(); return this.DialogResult = DialogResult.No; } } return this.DialogResult = DialogResult.OK; }
private void btnAddBasket_Click(object sender, EventArgs e) { // ajoute le produit courant au panier avec la quantité indiquée. Il met à jour le tableau int currentQty; if (!Int32.TryParse(tbQty.Text,out currentQty)) using (var info = new InformationBox("Veuillez entrer une quantité numérique")) { info.ShowDialog(); tbQty.Text = string.Empty; return; } if (Basket.Select(p => p.Key.designation).ToList().Contains(currentProduct.designation)) Basket[currentProduct] = Basket[currentProduct] + currentQty; else Basket.Add(currentProduct, currentQty); dgvBasket.Rows.Clear(); foreach (var prod in Basket) dgvBasket.Rows.Add(prod.Key.designation,prod.Value.ToString()); tbQty.Text = string.Empty; }
private DialogResult CheckIdentification() { // permet l'authentification if (string.IsNullOrEmpty(tbLogin.Text) || string.IsNullOrWhiteSpace(tbLogin.Text)) return this.DialogResult = DialogResult.No; if (string.IsNullOrEmpty(tbPassword.Text) || string.IsNullOrWhiteSpace(tbPassword.Text)) return this.DialogResult = DialogResult.No; string result = Service.GetPaymentService.PersonIdentification(tbLogin.Text, tbPassword.Text); int idClient; if (!Int32.TryParse(result, out idClient)) { InformationBox displayInformation = new InformationBox(result); using (displayInformation) { displayInformation.ShowDialog(); return this.DialogResult = DialogResult.No; } } CurrentClient = new Client(idClient); if (string.IsNullOrWhiteSpace(CurrentClient.result[1]) || string.IsNullOrEmpty(CurrentClient.result[1])) { InformationBox displayInformation = new InformationBox(CurrentClient.result[0]); using (displayInformation) { displayInformation.ShowDialog(); return this.DialogResult = DialogResult.No; } } // avec les information récupérées, on créer une nouvelle instance du client CurrentClient.FillClient(CurrentClient.result); return this.DialogResult = DialogResult.Yes; }
private void btnPay_Click(object sender, EventArgs e) { // permet de payer if (string.IsNullOrEmpty(lblPrice.Text) || string.IsNullOrWhiteSpace(lblPrice.Text)) return; if (Convert.ToDouble(lblPrice.Text) < currentClient.sold) { var result = Service.GetPaymentService.DebitTransaction(currentClient.clientId, Convert.ToDouble(lblPrice.Text)); using (var info = new InformationBox(result)) { info.ShowDialog(); } RefreshScreen(); lbOrder.Items.Clear(); lblPrice.Text = string.Empty; Basket = null; } else using (var info = new InformationBox("Veuillez recharger, vous n'avez pas assez d'argent")) { info.ShowDialog(); } }
private void btnAdd_Click(object sender, EventArgs e) { // ajoute la carte avec les infos renseignées if (string.IsNullOrEmpty(tbNumber.Text) || string.IsNullOrWhiteSpace(tbNumber.Text) || string.IsNullOrEmpty(tbExpirationDate.Text) || string.IsNullOrWhiteSpace(tbExpirationDate.Text) || string.IsNullOrEmpty(tbCryto.Text) || string.IsNullOrWhiteSpace(tbCryto.Text) || string.IsNullOrEmpty(cbBank.Text) || string.IsNullOrEmpty(cbType.Text)) using (var info = new InformationBox ("Veuillez renseigner toutes les informations")) { info.ShowDialog(); return; } int numero; if (!Int32.TryParse(tbNumber.Text,out numero)) using (var info = new InformationBox ("Veuillez rentrer un numéro valide")) { info.ShowDialog(); return; } int crypto; if (!Int32.TryParse(tbCryto.Text,out crypto)) using (var info = new InformationBox ("Veuillez rentrer un cryptogramme valide")) { info.ShowDialog(); return; } var result = Service.GetPaymentService.AddCarteForClient(currentClient.clientId, numero, tbExpirationDate.Text, crypto, cbType.Text, cbBank.Text); using (var info = new InformationBox(result)) { info.ShowDialog(); RefreshScreen(); return; } }
private void Payment_Load(object sender, EventArgs e) { // charge le panier, les cartes du client Basket = MainMenu.Basket; lblClientSold.Text = currentClient.sold.ToString()+"€"; var cards = Service.GetPaymentService.GetCarteBancaire(currentClient.clientId); if (cards == null) return; if (cards[0].Count<2) using (var info = new InformationBox(cards[0][0])) { info.ShowDialog(); return; } List<string> cardsNumbers = new List<string> {}; foreach (var card in cards) { cardsNumbers.Add(card[0]); } cbCards.DataSource = cardsNumbers; lbOrder.Items.AddRange(Basket.Select(p => p.Key.designation).ToArray()); lblPrice.Text = Basket.Sum(p => p.Value*p.Key.prix).ToString(); }
private void RefreshScreen() { // actualise la page avec les nouvelles informations var result = Service.GetPaymentService.GetClient(currentClient.clientId); if (string.IsNullOrEmpty(result[1])||string.IsNullOrWhiteSpace(result[1])) using (var info = new InformationBox(result[0])) { info.ShowDialog(); cbCards.SelectedIndex = 0; return; } currentClient.FillClient(result); lblClientSold.Text = currentClient.sold.ToString()+"€"; cbCards.SelectedIndex = 0; }
private void pbPayment_Click(object sender, EventArgs e) { // on vérifie qu'un utilisateur est connecté puis on instancie la page demandée if (CurrentClient == null) using (var info = new InformationBox("Veuillez tout d'abord vous connecter s'il vous plaît")) { info.ShowDialog(); return; } PagePayment.ShowDialog(); PagePayment.Focus(); }
private void llblSignIn_Click(object sender, EventArgs e) { // permet la création d'un profil using (Inscription) { if (Inscription.ShowDialog()==DialogResult.OK) { InformationBox info = new InformationBox("Le profil a été créé avec succès"); using (info) { info.ShowDialog(); } } } }