private void addBtnClicked(object sender, RoutedEventArgs e)
        {
            if (!ValidateFields())
            {
                return;
            }
            int carPower, carDayPrince, carBail;

            Int32.TryParse(CarPower.Text, out carPower);
            Int32.TryParse(CarDayPrince.Text, out carDayPrince);
            Int32.TryParse(CarBail.Text, out carBail);

            Model.Car tempCar = new Model.Car()
            {
                CarRegNumb   = CarRegNumb.Text.ToString(),
                CarColor     = Color.Text.ToString(),
                CarPower     = carPower,
                CarDayPrince = carDayPrince,
                CarBail      = carBail,
                Status       = (Model.CarStatus)StatusCombo.SelectedIndex,
                Engine       = (Model.CarEngineType)EngineCombo.SelectedIndex,
                Gearbox      = (Model.CarGearBoxType)GearBoxCombo.SelectedIndex,
                Model        = staffMenu.ObservableCarModel[ModelCombo.SelectedIndex]
            };

            MyController.manageCars.SaveCar(tempCar, -1);
            staffMenu.updateCarList();
        }
Exemple #2
0
        public void ShowCarManager(Model.Car car)
        {
            var carManagerWindow = new CarManageWindow(null, car, models);

            carManagerWindow.OnRemove = (carId) =>
            {
                Application.MainLoop.Invoke(() =>
                {
                    MyController.manageCars.DeleteCar(carId);
                });
            };
            carManagerWindow.OnSave = (editData) =>
            {
                Application.MainLoop.Invoke(() =>
                {
                    MyController.manageCars.SaveCar(editData.carData, editData.carId);
                    cars = MyController.manageCars.GetCarList();
                });
            };
            carManagerWindow.OnBack = () =>
            {
                Application.RequestStop();
                Application.Top.Remove(carManagerWindow);
                ShowCarList();
            };
            Top = Application.Top;
            Top.Add(carManagerWindow);
            Application.Run(Top);
        }
 public void SaveCar(Model.Car carData, int editCarId)
 {
     if (editCarId == -1)
     {
         model.Cars.Add(carData);
         model.SaveChanges();
         view.ShowMessage("Pomyślnie dodano samochód " + carData);
     }
     else
     {
         var tempCar = model.Cars.SingleOrDefault(c => c.CarId == editCarId);
         if (tempCar != null)
         {
             tempCar.CarBail      = carData.CarBail;
             tempCar.Model        = carData.Model;
             tempCar.CarColor     = carData.CarColor;
             tempCar.CarDayPrince = carData.CarDayPrince;
             tempCar.CarPower     = carData.CarPower;
             tempCar.CarRegNumb   = carData.CarRegNumb;
             tempCar.Engine       = carData.Engine;
             tempCar.Gearbox      = carData.Gearbox;
             tempCar.Status       = carData.Status;
             model.SaveChanges();
             view.ShowMessage("Edycja samochodu zakończona pomyślnie.");
         }
     }
 }
Exemple #4
0
        public static Data.Entities.Car ConvertToEntity(this Model.Car model)
        {
            var car = new Data.Entities.Car
            {
                CarId       = model.CarId,
                RaceNumber  = model.RaceNumber,
                CarModel    = model.CarModel,
                CupCategory = model.CupCategory,
                TeamName    = model.TeamName
            };

            if (model.Drivers != null && model.Drivers.Any())
            {
                foreach (var modelDriver in model.Drivers)
                {
                    var driver    = modelDriver.ConvertToEntity();
                    var carDriver = new Data.Entities.CarDriver
                    {
                        CarId    = car.Id,
                        DriverId = driver.Id,
                        Driver   = driver
                    };

                    car.CarDriver.Add(carDriver);
                }
            }

            return(car);
        }
        private async Task <int> AddCarAndUser(InputModel input)
        {
            // add user
            var appUser = new Model.AppUser()
            {
                FirstName   = input.Name,
                Patronimyc  = input.Patronimic,
                Password    = input.Password,
                PhoneNumber = input.PhoneNumber
            };

            _context.AppUsers.Add(appUser);
            _context.SaveChanges();


            // add car
            var car = new Model.Car()
            {
                ImageName = "",
                ImagePath = "",
                CarMark   = input.CarMark,
                Number    = input.CarNumber,
                UserId    = appUser.Id
            };

            _context.Cars.Add(car);
            _context.SaveChanges();

            await SaveFile(input.CarPhoto, car);

            return(appUser.Id);
        }
 private void deleteBtnclicked(object sender, RoutedEventArgs e)
 {
     if (carList.SelectedIndex > 0)
     {
         Model.Car tempCar = staffMenu.ObservableCar[carList.SelectedIndex];
         staffMenu.ObservableCar.Remove(tempCar);
         MyController.manageCars.DeleteCar(tempCar.CarId);
     }
 }
Exemple #7
0
 public ReservationWindow(Terminal.Gui.View parent, List <Model.Car> cars, Model.Car selectedCar, Model.User user, Controller.AppController controller) : base("Dodaj rezerwację")
 {
     this.controller  = controller;
     this.cars        = cars;
     this.user        = user;
     this.selectedCar = selectedCar;
     _parent          = parent;
     InitControls();
     InitStyle();
 }
Exemple #8
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     Model.Car tempCar = userMenu.ObservableCar.Where(x => x.CarId == selectedCar).FirstOrDefault();
     if (tempCar != null)
     {
         CarCombo.SelectedItem    = tempCar;
         DatesList                = new ObservableCollection <string>(MyController.manageReservation.GetCarReservationDates(selectedCar));
         CarDatesList.ItemsSource = DatesList;
     }
 }
 private void saveBtnClicked(object sender, RoutedEventArgs e)
 {
     if (!ValidateFields())
     {
         return;
     }
     Model.Car tempCar = staffMenu.ObservableCar[carList.SelectedIndex];
     MyController.manageCars.SaveCar(tempCar, tempCar.CarId);
     staffMenu.updateCarList();
 }
Exemple #10
0
 public static CarPub ToPublicModel(Model.Car car)
 {
     return(new CarPub()
     {
         Brand = car.Brand,
         CarName = car.Name,
         Colour = car.Colour,
         Price = car.Price
     });
 }
Exemple #11
0
        static void Main(string[] args)
        {
            var car = new Model.Car(4, "Supacars", Tuple.Create(2.0, 4.0));

            var bike = Model.Vehicle.NewMotorbike("CR", 250);

            if (bike.IsMotorbike)
            {
                var motorBike  = (Model.Vehicle.Motorbike)bike;
                var engineSize = motorBike.EngineSize;
            }

            var subaru = Model.Functions.CreateCar(4, "Subaru", 2, 4);

            var tesla = Model.Functions.CreateFourWheeledCar.Invoke("Tesla").Invoke(2.0).Invoke(4.0);
        }
        /// <summary>
        /// Allows the class to be copied
        /// </summary>
        /// <remarks>
        /// Performs a 'deep copy' of all the data in the class (and its children)
        /// </remarks>
        public override object Clone()
        {
            Model.Car newObject = new Model.Car(_elementName);
            newObject.m_Make         = m_Make;
            newObject.m_Color        = m_Color;
            newObject.m_IsValidColor = m_IsValidColor;
            newObject.m_Owner        = m_Owner;
            newObject.m_IsValidOwner = m_IsValidOwner;

// ##HAND_CODED_BLOCK_START ID="Additional clone"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS

// Add Additional clone code here...

// ##HAND_CODED_BLOCK_END ID="Additional clone"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS

            return(newObject);
        }
Exemple #13
0
        public void TestGetMethod()
        {
            TestLambdaContext       context;
            APIGatewayProxyRequest  request;
            APIGatewayProxyResponse response;

            Functions functions = new Functions();

            var car = new Model.Car()
            {
                Model = "Passat", Mileage = 150000, Make = "VW", Year = 1999
            };

            request  = new APIGatewayProxyRequest();
            context  = new TestLambdaContext();
            response = functions.Get(request, context);
            Assert.Equal(200, response.StatusCode);
            string result = JsonConvert.SerializeObject(car);

            Assert.Equal(result, response.Body);
        }
Exemple #14
0
        public void ShowReservationWindow(Model.Car selectedCar = null)
        {
            var reservationWindow = new ReservationWindow(null, avaliableCars, selectedCar, user, MyController);

            reservationWindow.OnSave = (reservationData) =>
            {
                Application.MainLoop.Invoke(() =>
                {
                    MyController.manageReservation.AddReservation(reservationData);
                });
            };
            reservationWindow.OnBack = () =>
            {
                Application.RequestStop();
                Application.Top.Remove(reservationWindow);
                ShowMenu();
            };
            Top = Application.Top;
            Top.Add(reservationWindow);
            Application.Run(Top);
        }
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnNew_Click(object sender, EventArgs e)
        {
            int AddedCarId = 0;
            int shipId = Convert.ToInt32(this.ShopId.SelectedItem.Value);
            int cartypeid = Convert.ToInt32(this.CarTypeId.SelectedItem.Value);
            string carname = this.CarName.Text.Trim();
            string carmodel = this.CarModel.Text.Trim();
            string basicInsure = this.BasicInsure.Text.Trim();
            string PreAuthorization = this.PreAuthorization.Text.Trim();
            decimal price = Convert.ToDecimal(this.Price.Text.Trim());
            string IsMileage = this.IsMileage.SelectedItem.Value;
            string Status = this.Status.SelectedItem.Value;
            string describe = this.Describe.Text.Trim();
            string remark = this.Remark.Text.Trim();

            int carnum = Convert.ToInt32(this.CarNum.Text.Trim());
            string carage = this.CarAge.Text.Trim();
            string derailleur = this.drpDerailleur.SelectedItem.Text;
            decimal monthprice = Convert.ToDecimal(this.MonthPrice.Text.Trim());
            try
            {
                using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
                {
                    ZLzuche.Model.Car car = new Model.Car();
                    car.ShopId = shipId;
                    car.CarTypeId = cartypeid;
                    car.CarName = carname;
                    car.CarModel = carmodel;
                    car.BasicInsure = basicInsure;
                    car.PreAuthorization = PreAuthorization;
                    car.Price = Convert.ToDecimal(price);
                    car.IsMileage = IsMileage;
                    car.Status = Status;
                    car.Describe = describe;
                    car.Remark = remark;

                    car.carnum = carnum;
                    car.CarAge = carage;
                    car.Derailleur = derailleur;
                    car.MonthPrice = monthprice;
                    entity.AddToCar(car);
                    entity.SaveChanges();

                    if (carpic.HasFile)
                    {
                        try
                        {
                            AddedCarId = car.ID;
                            string name = carpic.FileName;//文件的名字
                            string size = carpic.PostedFile.ContentLength.ToString();
                            string last = name.Substring(name.LastIndexOf(".") + 1);//得到文件的后缀名(gif/jpg)
                            string filename = AddedCarId + "." + last;
                            string webFilePath = Server.MapPath("../images/CarImage/" + filename);
                            carpic.SaveAs(webFilePath);
                        }
                        catch (Exception ex)
                        {
                            ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('上传图片失败');</script>");
                            return;
                        }
                    }
                }
                Response.Write("<script language='javascript'>window.opener.location.reload();</script>");
                Response.Write("<script language='javascript'>window.opener=null;window.close();</script>");
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('新增失败');</script>");
                return;
            }
        }
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnNew_Click(object sender, EventArgs e)
        {
            int     AddedCarId       = 0;
            int     shipId           = Convert.ToInt32(this.ShopId.SelectedItem.Value);
            int     cartypeid        = Convert.ToInt32(this.CarTypeId.SelectedItem.Value);
            string  carname          = this.CarName.Text.Trim();
            string  carmodel         = this.CarModel.Text.Trim();
            string  basicInsure      = this.BasicInsure.Text.Trim();
            string  PreAuthorization = this.PreAuthorization.Text.Trim();
            decimal price            = Convert.ToDecimal(this.Price.Text.Trim());
            string  IsMileage        = this.IsMileage.SelectedItem.Value;
            string  Status           = this.Status.SelectedItem.Value;
            string  describe         = this.Describe.Text.Trim();
            string  remark           = this.Remark.Text.Trim();

            int     carnum     = Convert.ToInt32(this.CarNum.Text.Trim());
            string  carage     = this.CarAge.Text.Trim();
            string  derailleur = this.drpDerailleur.SelectedItem.Text;
            decimal monthprice = Convert.ToDecimal(this.MonthPrice.Text.Trim());

            try
            {
                using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
                {
                    ZLzuche.Model.Car car = new Model.Car();
                    car.ShopId           = shipId;
                    car.CarTypeId        = cartypeid;
                    car.CarName          = carname;
                    car.CarModel         = carmodel;
                    car.BasicInsure      = basicInsure;
                    car.PreAuthorization = PreAuthorization;
                    car.Price            = Convert.ToDecimal(price);
                    car.IsMileage        = IsMileage;
                    car.Status           = Status;
                    car.Describe         = describe;
                    car.Remark           = remark;

                    car.carnum     = carnum;
                    car.CarAge     = carage;
                    car.Derailleur = derailleur;
                    car.MonthPrice = monthprice;
                    entity.AddToCar(car);
                    entity.SaveChanges();

                    if (carpic.HasFile)
                    {
                        try
                        {
                            AddedCarId = car.ID;
                            string name        = carpic.FileName;                           //文件的名字
                            string size        = carpic.PostedFile.ContentLength.ToString();
                            string last        = name.Substring(name.LastIndexOf(".") + 1); //得到文件的后缀名(gif/jpg)
                            string filename    = AddedCarId + "." + last;
                            string webFilePath = Server.MapPath("../images/CarImage/" + filename);
                            carpic.SaveAs(webFilePath);
                        }
                        catch (Exception ex)
                        {
                            ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('上传图片失败');</script>");
                            return;
                        }
                    }
                }
                Response.Write("<script language='javascript'>window.opener.location.reload();</script>");
                Response.Write("<script language='javascript'>window.opener=null;window.close();</script>");
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('新增失败');</script>");
                return;
            }
        }