Advertisement
joseh254

Epic Car Customers web form

Mar 26th, 2015
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.52 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using EpicCars;
  8.  
  9. namespace Customers
  10. {
  11.     public partial class Default : System.Web.UI.Page
  12.     {
  13.         protected void Page_Load(object sender, EventArgs e)
  14.         {
  15.             if (!Page.IsPostBack)
  16.                PopulateFormWithAutomobile();
  17.         }
  18.  
  19.         protected void submitBTN_Click(object sender, EventArgs e)
  20.         {
  21.             SaveBidFromForm();
  22.         }
  23.  
  24.         private void SaveStartingBidFromFor()
  25.         {
  26.             throw new NotImplementedException();
  27.         }
  28.  
  29.        void PopulateFormWithAutomobile()
  30.         {
  31.             var svc = new CarService();
  32.  
  33.             var automobile = svc.GetAutomobiles();
  34.  
  35.             if (automobile == null)
  36.                 return;
  37.  
  38.             colorTextBox.Text = automobile.Color;
  39.             makeTextBox.Text = automobile.Make;
  40.             modelTextBox.Text = automobile.Model;
  41.             yearTextBox.Text = automobile.Year.ToString();
  42.             amountTextBox.Text = automobile.Amount.ToString();  
  43.  
  44.         }
  45.  
  46.        void SaveBidFromForm()
  47.         {
  48.             var bid = new Bidders();
  49.             bid.BiddersName = BiddersNameTextBox.Text;
  50.             int firstBid;
  51.             if (int.TryParse(bidAmountTB.Text, out firstBid))
  52.                 bid.FirstBid = firstBid;
  53.  
  54.             var svc = new BiddersService();
  55.             svc.SaveStartingBid(bid);
  56.            
  57.         }
  58.  
  59.  
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement