//changeType = Decides which attribute to change as the parameter item in switch public void Edit(_ChangedType changeType, object item) { switch (changeType) { case _ChangedType.Brand: Brand = item.ToString(); break; case _ChangedType.Color: Color = item.ToString(); break; case _ChangedType.Country: Country = item.ToString(); break; case _ChangedType.Owner: Owner = item.ToString(); break; case _ChangedType.Plate: Plate = item.ToString(); break; case _ChangedType.Type: Type = (_CarType)item; break; case _ChangedType.Year: Year = Convert.ToInt32(item); break; } }
//CONSTRUCTOR public Vehicles(string plate = "", string owner = "", string brand = "", string color = "", string country = "", int year = 0, _CarType type = _CarType.FAMILY) { Plate = plate.ToUpper(); Owner = owner.ToUpper(); Brand = brand.ToUpper(); Type = type; Color = color.ToUpper(); Country = country.ToUpper(); Year = year; }
public object Select_CarType(int num) { object result = null; CStatementList cstate = new CStatementList(_SQLConnection.CSQLConnection); try { try { CSQLParameterList plist = new CSQLParameterList(); plist.Add("@num", DbType.Int32, num, ParameterDirection.Input); CSQLDataAdepterList adlist = new CSQLDataAdepterList(); CSQLStatementValue csvUser = new CSQLStatementValue(this._statement, plist, NoomLibrary.StatementType.Select); adlist.Add(csvUser); cstate.Open(); result = cstate.Execute(adlist); DataTable dt = (DataTable)result; TypeCar = dt; foreach (DataRow item in dt.Rows) { int id = int.Parse(item["ID"].ToString()); _CarType _c = new _CarType(); _c.ID = id; _c.Name = item["Name"].ToString(); this.Add(id, _c); } cstate.Commit(); } catch (SqlException) { cstate.Rollback(); throw; } finally { cstate.Close(); } } catch (Exception) { throw; } return(result); }
public bool SaveCarType(_CarType c) { try { if (c.IsNew) { db.CAR_TYPE.Add(new CAR_TYPE() { Id = c.Id, DailyCost = c.DailyCost, DailyPenalty = c.DailyPenalty, GearType = c.GearType, Manufacturer = c.Manufacturer, Model = c.Model, Year = c.Year }); } else { var curr = db.CAR_TYPE.Where(w => w.Id == c.Id).FirstOrDefault(); curr.Id = c.Id; curr.DailyCost = c.DailyCost; curr.DailyPenalty = c.DailyPenalty; curr.GearType = c.GearType; curr.Manufacturer = c.Manufacturer; curr.Model = c.Model; curr.Year = c.Year; } db.SaveChanges(); } catch { return(false); } return(true); }