joseh254

Epic Car form

Mar 26th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.55 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. using System.IO;
  12.  
  13. namespace SalesStaff
  14. {
  15.     public partial class frmEpicCars : Form
  16.     {
  17.         public frmEpicCars()
  18.         {
  19.             InitializeComponent();
  20.            
  21.         }
  22.  
  23.         private void carImageButton_Click(object sender, EventArgs e)
  24.         {
  25.            // Select Image to display in picture box
  26.             openFD.ShowDialog();
  27.             carPictureBox.ImageLocation = openFD.FileName;
  28.  
  29.         }
  30.  
  31.         private void frmEpicCars_Load(object sender, EventArgs e)
  32.         {
  33.             PopulateFormWithCar();
  34.         }
  35.  
  36.         private void submitButton_Click(object sender, EventArgs e)
  37.         {
  38.             SaveCarFromForm();
  39.         }
  40.  
  41.         private void refreshButton_Click(object sender, EventArgs e)
  42.         {
  43.             SaveBidFromForm();
  44.         }
  45.  
  46.         private void SaveBidFromForm()
  47.         {
  48.             var bid = new Bidders();
  49.             bid.BiddersName = biddersNameTextBox.Text;
  50.             int firstBid;
  51.             if (int.TryParse(amountTextBox.Text, out firstBid))
  52.                 bid.FirstBid = firstBid;
  53.  
  54.             var svc = new BiddersService();
  55.             svc.SaveStartingBid(bid); ;
  56.         }
  57.  
  58.         void PopulateFormWithCar()
  59.         {
  60.             var svc = new CarService();
  61.  
  62.             var car = svc.GetAutomobiles();
  63.  
  64.             if (car == null)
  65.                 return;
  66.  
  67.             colorTextBox.Text = car.Color;
  68.             makeTextBox.Text = car.Make;
  69.             modelTextBox.Text = car.Model;
  70.             yearTextBox.Text = car.Year.ToString();
  71.             amountTextBox.Text = car.Amount.ToString();  
  72.  
  73.         }
  74.  
  75.         void SaveCarFromForm()
  76.         {
  77.             var car = new Car();
  78.             car.Color = colorTextBox.Text;
  79.             car.Make = makeTextBox.Text;
  80.             car.Model = modelTextBox.Text;
  81.             int year;
  82.             if (int.TryParse(yearTextBox.Text , out year))
  83.                 car.Year = year;
  84.             int amount;
  85.             if (int.TryParse(amountTextBox.Text, out amount))
  86.               car.Amount = amount;
  87.  
  88.             //automobile.ImageBytes = File.ReadAllBytes(Server.MagPath("~/CarImages/2013_Nissan_Altima.jpg"));
  89.             var svc = new CarService();
  90.             svc.SaveCar(car);
  91.            
  92.                
  93.  
  94.            
  95.         }
  96.  
  97.        
  98.     }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment