Example #1
0
 protected void btn_submit_Click(object sender, EventArgs e)
 {
     try
     {
         using (var db = new THFinanceEntities())
         {
             tble_Vehicle tbl = new tble_Vehicle();
             tbl.VehicleBHP       = txt_vehiclebhp.Text;
             tbl.VehicleBorroerId = Convert.ToInt32(ddl_vehicelborrwer.SelectedValue);
             tbl.VehicleChasisNo  = txt_vehiclechasis.Text;
             tbl.VehicleColor     = txt_vehiclecolour.Text;
             tbl.VehicleEngineNo  = txt_enginenumber.Text;
             tbl.VehicleInsurance = txt_vehicleinsurance.Value;
             tbl.VehicleKeyNo     = txt_vehiclekey.Value;
             tbl.Vehiclemodel     = txt_vehiclemodel.Text;
             tbl.VehicleType      = txt_VehicleType.Value;
             if (tbl != null)
             {
                 db.tble_Vehicle.Add(tbl);
                 db.SaveChanges();
                 clearfields();
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #2
0
        protected void btn_update_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(lbl_id.Text);

            try
            {
                using (var db = new THFinanceEntities())
                {
                    var q = (from s in db.tble_Vehicle where s.VehicleBorroerId.Equals(id)
                             select s).Single();
                    tble_Vehicle tbl = new tble_Vehicle();
                    tbl.VehicleBHP       = txt_vehiclebhp.Text;
                    tbl.VehicleBorroerId = Convert.ToInt32(ddl_vehicelborrwer.SelectedValue);
                    tbl.VehicleChasisNo  = txt_vehiclechasis.Text;
                    tbl.VehicleColor     = txt_vehiclecolour.Text;
                    tbl.VehicleEngineNo  = txt_enginenumber.Text;
                    tbl.VehicleInsurance = txt_vehicleinsurance.Value;
                    tbl.VehicleKeyNo     = txt_vehiclekey.Value;
                    tbl.Vehiclemodel     = txt_vehiclemodel.Text;
                    tbl.VehicleType      = txt_VehicleType.Value;
                    db.SaveChanges();
                    clearfields();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }