joseh254

epic cars sales form

Mar 24th, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.11 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using EpicCars;
  11.  
  12. namespace SalesStaff
  13. {
  14.     public partial class frmEpicCars : Form
  15.     {
  16.         public frmEpicCars()
  17.         {
  18.             InitializeComponent();
  19.         }
  20.  
  21.         private void selectCarBTN_Click(object sender, EventArgs e)
  22.         {
  23.            // Select Image to display in picture box
  24.             openFD.ShowDialog();
  25.             carPicBox.ImageLocation = openFD.FileName;
  26.         }
  27.  
  28.         private void frmEpicCars_Load(object sender, EventArgs e)
  29.         {
  30.             PopulateFormWithAutomobile();
  31.         }
  32.  
  33.         private void submitBTN_Click(object sender, EventArgs e)
  34.         {
  35.             SaveAutomobileFromForm();
  36.         }
  37.  
  38.         private void refreshBTN_Click(object sender, EventArgs e)
  39.         {
  40.  
  41.         }
  42.  
  43.         void PopulateFormWithAutomobile()
  44.         {
  45.             var svc = new AutomobileService();
  46.  
  47.             var automobile = svc.GetAutomobiles();
  48.  
  49.             if (automobile == null)
  50.                 return;
  51.  
  52.             colorTB.Text = automobile.Color;
  53.             makeTB.Text = automobile.Make;
  54.             modelTB.Text = automobile.Model;
  55.             yearTB.Text = automobile.Year.ToString();
  56.                
  57.  
  58.         }
  59.  
  60.         void SaveAutomobileFromForm()
  61.         {
  62.             var automobile = new Automobiles();
  63.             automobile.Color = colorTB.Text;
  64.             automobile.Make = makeTB.Text;
  65.             automobile.Model = modelTB.Text;
  66.             int year;
  67.             if (int.TryParse(yearTB.Text , out year))
  68.                 automobile.Year = year;
  69.             int amount;
  70.             if (int.TryParse(startingBidTB.Text, out amount))
  71.                 automobile.Amount = amount;
  72.             var svc = new AutomobileService();
  73.             svc.SaveAutomobiles(automobile);
  74.             //if (int.TryParse(startingBidTB.Text, out bid))
  75.                
  76.  
  77.            
  78.         }
  79.  
  80.        
  81.     }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment