Ejemplo n.º 1
0
 private void CreateData(TradeinValueModel model)
 {
     try
     {
         using (var context = new VincontrolEntities())
         {
             if (model.Trim != null)
             {
                 var tradein = new TrimTradeIn();
                 tradein.TrimId    = model.Trim.Value;
                 tradein.SampleVIN = model.SampleVin;
                 //decimal tradeinValue = 0;
                 //decimal.TryParse(TradeInValue.Text, out tradeinValue);
                 if (model.TradeinValue != null)
                 {
                     tradein.TradeInValue = model.TradeinValue.Value;
                 }
                 //long estimatedMileage = 0;
                 //long.TryParse(EstimatedMileage.Text, out estimatedMileage);
                 tradein.EstimatedZeroPointMileage = model.EstimatedMileage;
                 context.AddToTrimTradeIns(tradein);
                 context.SaveChanges();
                 MessageBox.Show("Tradein information has been successfully added.");
             }
         }
     }
     catch (Exception)
     {
         MessageBox.Show("There is already this year make model trim in the database.");
     }
 }
Ejemplo n.º 2
0
        private void CreateData(int trimId)
        {
            using (var context = new VincontrolEntities())
            {
                var tradein = new TrimTradeIn();

                //tradein.TrimId = trimId;
                //tradein.SampleVIN = SampleVin.Text;
                //decimal tradeinValue = 0;
                //decimal.TryParse(TradeInValue.Text, out tradeinValue);
                //tradein.TradeInValue = tradeinValue;
                //long estimatedMileage = 0;
                //long.TryParse(EstimatedMileage.Text, out estimatedMileage);
                //tradein.EstimatedZeroPointMileage = estimatedMileage;
                //context.AddToTrimTradeIns(tradein);
                context.SaveChanges();
            }
        }