Beispiel #1
0
        public CarEdit()
        {
            InitializeComponent();
            RentalServiceClient service = new RentalServiceClient();

            dgCar.ItemsSource = service.GetAllCars();
        }
Beispiel #2
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            Car c = new Car();

            if (tbCarID.Text != "")
            {
                MessageBoxResult result = System.Windows.MessageBox.Show("Biztos, hogy törli a(z) " + c.Manufacturer + " " + c.Model + " adatait az adatbázisból?",
                                                                         "Megerősítés",
                                                                         MessageBoxButton.YesNo,
                                                                         MessageBoxImage.Question);
                if (result == MessageBoxResult.Yes)
                {
                    c.Id = Convert.ToInt32(tbCarID.Text);
                    RentalServiceClient service = new RentalServiceClient();

                    if (service.DeleteCar(c) == 1)
                    {
                        if (tbImagePath.Text != "")
                        {
                            File.Delete(tbImagePath.Text);
                        }
                        dgCar.ItemsSource = service.GetAllCars();
                        System.Windows.MessageBox.Show("Autó törölve", "Sikeres mentés", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    else if (service.DeleteCar(c) == 0)
                    {
                        System.Windows.MessageBox.Show("Hiba történt!");
                    }
                }
            }
            else
            {
                System.Windows.MessageBox.Show("Törlés nem lehetséges, nincs kijelölve autó!", "Hiba", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #3
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            Client c = new Client();

            if (tbClientID.Text != "")
            {
                MessageBoxResult result = MessageBox.Show("Biztos, hogy törli " + c.Name + " adatait az adatbázisból?",
                                                          "Megerősítés",
                                                          MessageBoxButton.YesNo,
                                                          MessageBoxImage.Question);
                if (result == MessageBoxResult.Yes)
                {
                    c.Id = Convert.ToInt32(tbClientID.Text);
                    RentalServiceClient service = new RentalServiceClient();

                    if (service.DeleteClient(c) == 1)
                    {
                        dgClient.ItemsSource = service.GetAllClients();
                        MessageBox.Show("Ügyfél törölve", "Sikeres mentés", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    else if (service.DeleteClient(c) == 0)
                    {
                        MessageBox.Show("Hiba történt!");
                    }
                }
            }
            else
            {
                MessageBox.Show("Törlés nem lehetséges, nincs kijelölve ügyfél!", "Hiba", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #4
0
        private void btnClearSearch_Click(object sender, RoutedEventArgs e)
        {
            tbCarFilter.Text = "";
            RentalServiceClient service = new RentalServiceClient();

            dgCar.ItemsSource = service.GetAllCars();
        }
Beispiel #5
0
        public AllRentals()
        {
            InitializeComponent();
            RentalServiceClient service = new RentalServiceClient();

            dgRentals.ItemsSource = service.GetAllRentals();
        }
Beispiel #6
0
        private void btnClear_Click(object sender, RoutedEventArgs e)
        {
            RentalServiceClient service = new RentalServiceClient();

            tbLicensePlate.Text       = "";
            tbManufacturer.Text       = "";
            tbModel.Text              = "";
            tbYear.Text               = "";
            tbKmClock.Text            = "";
            cobFuel.Text              = "";
            tbColor.Text              = "";
            cbAvailable.IsChecked     = false;
            tbRentalPricePerDay.Text  = "";
            tbRentalPricePerHour.Text = "";
            tbSeats.Text              = "";
            tbVIN.Text               = "";
            tbCarFilter.Text         = "";
            tbImagePath.Text         = "";
            dgCar.SelectedIndex      = -1;
            tbCarID.Text             = Convert.ToString(service.NextCarId());
            ImageViewer.Source       = null;
            btnSave.IsEnabled        = false;
            btnDelete.IsEnabled      = false;
            btnAdd.IsEnabled         = true;
            btnDeleteImage.IsEnabled = false;
        }
Beispiel #7
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            Client c = new Client();

            try
            {
                c.Idcardnumber = tbIdCardNumber.Text;
                c.Name         = tbName.Text;
                c.Zipcode      = tbZipCode.Text;
                c.Phonenumber  = tbPhoneNumber.Text;
                c.Adress       = tbAdress.Text;
                c.Birthdate    = dpBirthDate.SelectedDate.Value;
                c.City         = tbCity.Text;

                RentalServiceClient service = new RentalServiceClient();

                if (service.AddClient(c) == 1)
                {
                    MessageBox.Show("Ügyfél hozzáadva", "Sikeres felvétel", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else if (service.AddClient(c) == 0)
                {
                    MessageBox.Show("Hozzáadás nem lehetséges, nem megfelelő adatok!", "Hiba", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            catch (System.InvalidOperationException)
            {
                MessageBox.Show("Hozzáadás nem lehetséges, nem megfelelő adatok!", "Hiba", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #8
0
        /* private void btnClear_Click(object sender, RoutedEventArgs e)
         * {
         *     tbClientID.Text = "";
         *     tbIdCardNumber.Text = "";
         *     tbName.Text = "";
         *     dpBirthDate.SelectedDate = null;
         *     tbZipCode.Text = "";
         *     tbCity.Text = "";
         *     tbAdress.Text = "";
         *     tbPhoneNumber.Text = "";
         *     tbClientFilter.Text = "";
         *     dgClient.SelectedItem = null;
         *     btnSave.IsEnabled = false;
         *     btnDelete.IsEnabled = false;
         *     btnAdd.IsEnabled = true;
         * }*/

        /* private void btnAdd_Click(object sender, RoutedEventArgs e)
         * {
         *   Client c = new Client();
         *   try {
         *       c.Idcardnumber = tbIdCardNumber.Text;
         *       c.Name = tbName.Text;
         *       c.Zipcode = tbZipCode.Text;
         *       c.Phonenumber = tbPhoneNumber.Text;
         *       c.Adress = tbAdress.Text;
         *       c.Birthdate = dpBirthDate.SelectedDate.Value;
         *       c.City = tbCity.Text;
         *   }
         *   catch (System.InvalidOperationException)
         *   {
         *
         *       MessageBox.Show("22Hozzáadás nem lehetséges, nem megfelelő adatok!", "Hiba", MessageBoxButton.OK, MessageBoxImage.Error);
         *   }
         *
         *   RentalServiceClient service = new RentalServiceClient();
         *
         *   if (service.AddClient(c) == 1)
         *   {
         *       dgClient.ItemsSource = service.GetAllClients();
         *       MessageBox.Show("Ügyfél hozzáadva", "Sikeres felvétel", MessageBoxButton.OK, MessageBoxImage.Information);
         *
         *   }
         *   else if (service.AddClient(c) == 0)
         *   {
         *       MessageBox.Show("Hozzáadás nem lehetséges, nem megfelelő adatok!", "Hiba", MessageBoxButton.OK, MessageBoxImage.Error);
         *
         *   }
         *
         * }*/


        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Client c = new Client();
                c.Id           = Convert.ToInt32(tbClientID.Text);
                c.Idcardnumber = tbIdCardNumber.Text;
                c.Name         = tbName.Text;
                c.Zipcode      = tbZipCode.Text;
                c.Phonenumber  = tbPhoneNumber.Text;
                c.Adress       = tbAdress.Text;
                if (dpBirthDate.SelectedDate.Value != null)
                {
                    c.Birthdate = dpBirthDate.SelectedDate.Value;
                }
                c.City = tbCity.Text;

                RentalServiceClient service = new RentalServiceClient();

                if (service.UpdateClient(c) == 1)
                {
                    dgClient.ItemsSource = service.GetAllClients();
                    MessageBox.Show("Ügyfél módosítva", "Sikeres mentés", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else if (service.UpdateClient(c) == 0)
                {
                    MessageBox.Show("Hozzáadás nem lehetséges, nem megfelelő adatok!", "Hiba", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            catch (System.InvalidOperationException)
            {
                MessageBox.Show("Hozzáadás nem lehetséges, nem megfelelő adatok!", "Hiba", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #9
0
        private void btnClearSearch_Click(object sender, RoutedEventArgs e)
        {
            tbClientFilter.Text = "";
            RentalServiceClient service = new RentalServiceClient();

            dgClient.ItemsSource = service.GetAllClients();
            btnDelete.IsEnabled  = false;
            btnSave.IsEnabled    = false;
        }
Beispiel #10
0
        public RentalReportViewer()
        {
            InitializeComponent();
            reportViewer.Reset();
            RentalServiceClient service = new RentalServiceClient();
            DataTable           dt      = service.GetReportData(RentalEdit.rentalId).RentalsTable;
            ReportDataSource    ds      = new ReportDataSource("DataSet1", dt);

            reportViewer.LocalReport.DataSources.Add(ds);
            reportViewer.LocalReport.ReportEmbeddedResource = "CarRental.RentalReport.rdlc";
            reportViewer.RefreshReport();
        }
Beispiel #11
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            Car c = new Car();
            RentalServiceClient service = new RentalServiceClient();

            c.Id = Convert.ToInt32(tbCarID.Text);

            // var d = new System.Windows.DataObject(System.Windows.DataFormats.Bitmap, ImageViewer.Source, true);
            // var bmp = d.GetData("System.Drawing.Bitmap") as byte[];
            if (imgLocation != "")
            {
                string path = "C:/CarRentalImages/" + c.Id.ToString() + System.IO.Path.GetExtension(imgLocation);
                System.IO.File.Copy(imgLocation, path, true);
                c.Image = path;
                service.UpdateCarImage(c);
            }

            //  byte[] image = null;
            // FileStream stream = new FileStream(imgLocation, FileMode.Open, FileAccess.Read);
            // BinaryReader br = new BinaryReader(stream);
            //  image = br.ReadBytes((int)stream.Length);
            //  c.Image = image;



            c.Licenseplate       = tbLicensePlate.Text;
            c.Manufacturer       = tbManufacturer.Text;
            c.Model              = tbModel.Text;
            c.Year               = Convert.ToInt32(tbYear.Text);
            c.Kmclock            = Convert.ToInt32(tbKmClock.Text);
            c.Fuel               = cobFuel.Text;
            c.Color              = tbColor.Text;
            c.Seats              = Convert.ToInt32(tbSeats.Text);
            c.Vin                = tbVIN.Text;
            c.Rentalpriceperday  = Convert.ToInt32(tbRentalPricePerDay.Text);
            c.Rentalpriceperhour = Convert.ToInt32(tbRentalPricePerHour.Text);
            c.Available          = Convert.ToBoolean(cbAvailable.Content);

            if (service.UpdateCar(c) == 1)
            {
                dgCar.ItemsSource = service.GetAllCars();
                System.Windows.MessageBox.Show("Autó módosítva", "Sikeres mentés", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else if (service.UpdateCar(c) == 0)
            {
                System.Windows.MessageBox.Show("Hozzáadás nem lehetséges, nem megfelelő adatok!", "Hiba", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #12
0
        public RentalEdit()
        {
            InitializeComponent();
            rbPerDay.IsChecked = true;
            RentalServiceClient service = new RentalServiceClient();

            clientList = service.GetAllClients();
            carList    = service.GetAllCars();
            rentalId   = service.NextRentalId();
            service.Close();

            dtpDateOut.IsEnabled = false;
            tbBalance.IsEnabled  = false;
            tbDiscount.IsEnabled = false;
            tbCost.IsEnabled     = false;
            //  tbKmIn.IsEnabled = false;
            tbKmOut.IsEnabled    = false;
            tbKmDriven.IsEnabled = false;
            tbBalance.IsEnabled  = false;
            tbPaid.IsEnabled     = false;
            tbDuration.IsEnabled = false;
            tbTotal.IsEnabled    = false;
            rbPerDay.IsEnabled   = false;
            rbPerHour.IsEnabled  = false;
            // rbPerDay.IsChecked = true;


            //  dtpDateIn.IsEnabled = false;
            //  tbKmIn.IsEnabled = false;
            // tbKmDriven.IsEnabled = false;

            //  tbCost.IsEnabled = false;

            /*  if (isCarSelected && isClientSelected)
             * {
             *    tbCost.IsEnabled = true;
             *
             * }*/

            cobClients.ItemsSource       = clientList;
            cobClients.DisplayMemberPath = "Idcardnumber";

            cobCars.ItemsSource       = carList;
            cobCars.DisplayMemberPath = "Licenseplate";

            dtpDateOut.Value = DateTime.Now;
        }
Beispiel #13
0
        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            RentalServiceClient service = new RentalServiceClient();

            if (service.Login(tbUserName.Text, pwbPassword.Password) == 1)
            {
                MainWindow mw = new MainWindow();
                userLoggedIn        = service.GetUserByeUserName(tbUserName.Text);
                mw.lblLogin.Content = "Bejelentkezve: " + userLoggedIn.Fullname;
                mw.Show();
                Close();
            }
            else
            {
                MessageBox.Show("Hibás felhasználónév vagy jelszó!");
            }
        }
Beispiel #14
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            Car c = new Car();

            try
            {
                c.Licenseplate       = tbLicensePlate.Text;
                c.Manufacturer       = tbManufacturer.Text;
                c.Model              = tbModel.Text;
                c.Year               = Convert.ToInt32(tbYear.Text);
                c.Kmclock            = Convert.ToInt32(tbKmClock.Text);
                c.Fuel               = cobFuel.Text;
                c.Color              = tbColor.Text;
                c.Seats              = Convert.ToInt32(tbSeats.Text);
                c.Vin                = tbVIN.Text;
                c.Rentalpriceperday  = Convert.ToInt32(tbRentalPricePerDay.Text);
                c.Rentalpriceperhour = Convert.ToInt32(tbRentalPricePerHour.Text);
                c.Available          = Convert.ToBoolean(cbAvailable.Content);
                c.Image              = "";


                RentalServiceClient service = new RentalServiceClient();

                if (service.AddCar(c) == 1)
                {
                    if (imgLocation != "")
                    {
                        string path = "C:/CarRentalImages/" + tbCarID.Text + System.IO.Path.GetExtension(imgLocation);
                        System.IO.File.Copy(imgLocation, path, true);
                        c.Id    = Convert.ToInt32(tbCarID.Text);
                        c.Image = path;
                        service.UpdateCarImage(c);
                    }
                    dgCar.ItemsSource = service.GetAllCars();
                    System.Windows.MessageBox.Show("Autó hozzáadva", "Sikeres felvétel", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else if (service.AddCar(c) == 0)
                {
                    System.Windows.MessageBox.Show("Hozzáadás nem lehetséges, nem megfelelő adatok!", "Hiba", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ex + "Hozzáadás nem lehetséges, nem megfelelő adatok!", "Hiba", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #15
0
        private void tbClientFilter_TextChanged(object sender, TextChangedEventArgs e)
        {
            /*   RentalServiceClient service = new RentalServiceClient();
             * if (tbClientFilter.Text != "")
             * {
             *     List<Client> clientList = new List<Client>();
             *     Client c = new Client();
             *
             *     // c.Id = Convert.ToInt32(tbClientFilter.Text);
             *     c.Name = tbClientFilter.Text;
             *
             *     //clientList.Add(service.SearchClientByName(c));
             *     dgClient.ItemsSource = service.SearchClientByName();
             * }
             * else
             * {
             *     dgClient.ItemsSource = service.GetAllClients();
             * }*/
            dgClient.SelectedItem = null;
            btnDelete.IsEnabled   = false;
            btnSave.IsEnabled     = false;

            if (tbClientFilter.Text != "")
            {
                TextBox         textBoxName = (TextBox)sender;
                string          filterText  = textBoxName.Text;
                ICollectionView cv          = CollectionViewSource.GetDefaultView(dgClient.ItemsSource);

                if (!string.IsNullOrEmpty(filterText))
                {
                    cv.Filter = o =>
                    {
                        /* change to get data row value */
                        Client c = o as Client;
                        return(c.Name.ToUpper().Contains(filterText.ToUpper()));
                        /* end change to get data row value */
                    };
                }
            }
            else
            {
                RentalServiceClient service = new RentalServiceClient();
                dgClient.ItemsSource = service.GetAllClients();
            }
        }
Beispiel #16
0
        private void btnDeleteImage_Click(object sender, RoutedEventArgs e)
        {
            /* Car c = new Car();
             * byte[] images = null;
             * FileStream stream = new FileStream(imgLocation, FileMode.Open,FileAccess.Read);
             * BinaryReader br = new BinaryReader(stream);
             * images = br.ReadBytes((int)stream.Length);
             * c.Image = images;
             * RentalServiceClient service = new RentalServiceClient();
             * service.UpdateCar(c);*/
            //  ImageViewer.Source = tbModel.Text;

            /* if (tbImagePath.Text!="")
             * {
             *   ImageViewer.Source = new BitmapImage(new Uri(tbImagePath.Text));
             * }
             * else
             * {
             *   ImageViewer.Source = null;
             *   tbImagePath.Text = "";
             * }*/
            RentalServiceClient service = new RentalServiceClient();
            Car c = new Car();

            c.Id           = Convert.ToInt32(tbCarID.Text);
            c.Manufacturer = tbManufacturer.Text;
            c.Model        = tbModel.Text;

            MessageBoxResult result = System.Windows.MessageBox.Show("Biztos, hogy törli a(z) " + c.Manufacturer + " " + c.Model + " autó képét?",
                                                                     "Megerősítés",
                                                                     MessageBoxButton.YesNo,
                                                                     MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                ImageViewer.Source = null;
                imgLocation        = "";
                File.Delete(tbImagePath.Text);
                //tbImagePath.Text = "";
                c.Image = "";
                service.UpdateCarImage(c);
                dgCar.ItemsSource = service.GetAllCars();
            }
        }
Beispiel #17
0
        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            string columnName = "";

            dgClient.SelectedItem = null;
            btnDelete.IsEnabled   = false;
            btnSave.IsEnabled     = false;
            switch (cobColumn.Text)
            {
            case "Azonosító":
                columnName = "ClientID";
                break;

            case "Név":
                columnName = "Name";
                break;

            case "Szig. szám":
                columnName = "IdCardNumber";
                break;
            }
            try
            {
                RentalServiceClient service = new RentalServiceClient();
                if (service.SearchClient(columnName, tbClientFilter.Text) != null)
                {
                    dgClient.ItemsSource = service.SearchClient(columnName, tbClientFilter.Text);
                }
                else
                {
                    System.Windows.MessageBox.Show("Keresés sikertelen, nem megfelelő adatok!", "Hiba", MessageBoxButton.OK, MessageBoxImage.Error);
                    tbClientFilter.Text  = "";
                    dgClient.ItemsSource = service.GetAllClients();
                }
            }
            catch (Exception)
            {
                System.Windows.MessageBox.Show("Keresés sikertelen, nem megfelelő adatok!", "Hiba", MessageBoxButton.OK, MessageBoxImage.Error);
                tbClientFilter.Text = "";
            }
        }
 public SalesController()
 {
     serviceProxy = new RentalServiceClient();
 }
Beispiel #19
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            Rental r = new Rental();
            RentalServiceClient service = new RentalServiceClient();

            try
            {
                r.Clientid = clientList[cobClients.SelectedIndex].Id;
                r.Carid    = carList[cobCars.SelectedIndex].Id;
                r.Datetime = DateTime.Now;
                r.Dateout  = (DateTime)dtpDateOut.Value;
                // r.Datein = (DateTime) dtpDateIn.Value;
                r.Kmout = carList[cobCars.SelectedIndex].Kmclock;
                // r.Kmin = Convert.ToInt32(tbKmIn.Text);
                // r.Kmsdriven = r.Kmin - r.Kmout;
                r.Duration = Convert.ToInt32(tbDuration.Text);
                if (rbPerDay.IsChecked == true)
                {
                    r.Cost     = Convert.ToInt32(r.Duration * carList[cobCars.SelectedIndex].Rentalpriceperday);
                    r.Renttype = "Day";
                }
                else
                {
                    r.Cost     = Convert.ToInt32(r.Duration * carList[cobCars.SelectedIndex].Rentalpriceperhour);
                    r.Renttype = "Hour";
                }
                if (tbDiscount.Text != "")
                {
                    r.Discount = Convert.ToInt32(tbDiscount.Text);
                }
                else
                {
                    r.Discount = 0;
                }
                r.Total = r.Cost - r.Discount;
                if (tbPaid.Text != "")
                {
                    r.Advance = Convert.ToInt32(tbPaid.Text);
                }
                else
                {
                    r.Advance = 0;
                }
                r.Balance = r.Total - r.Advance;
                r.Issueby = Login.userLoggedIn.Id;
                r.Status  = false;



                if (service.AddRental(r) == 1)
                {
                    carList[cobCars.SelectedIndex].Available = false;
                    service.UpdateCar(carList[cobCars.SelectedIndex]);
                    System.Windows.MessageBox.Show("Kölcsönzés hozzáadva", "Sikeres felvétel", MessageBoxButton.OK, MessageBoxImage.Information);
                    btnPrint.IsEnabled = true;
                }
                else if (service.AddRental(r) == 0)
                {
                    System.Windows.MessageBox.Show("Hozzáadás nem lehetséges, nem megfelelő adatok!", "Hiba", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            catch (System.InvalidOperationException)
            {
                System.Windows.MessageBox.Show("Hozzáadás nem lehetséges, nem megfelelő adatok!", "Hiba", MessageBoxButton.OK, MessageBoxImage.Error);
            }


            /* if (cobCars.SelectedItem != null)
             * {
             *   tbCost.Text = carList[cobCars.SelectedIndex].Id.ToString();
             * }*/
        }
Beispiel #20
0
 public SalesController()
 {
     serviceProxy = new RentalServiceClient();
 }
Beispiel #21
0
        private void dgRentals_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            try
            {
                if (sender != null)
                {
                    DataGrid grid = sender as DataGrid;
                    if (grid != null && grid.SelectedItems != null && grid.SelectedItems.Count == 1)
                    {
                        //This is the code which helps to show the data when the row is double clicked.
                        // DataGridRow dgr = grid.ItemContainerGenerator.ContainerFromItem(grid.SelectedItem) as DataGridRow;
                        //  DataRowView dr = (DataRowView)dgr.Item;

                        //  DataRowView dataRow = (DataRowView)dgRentals.SelectedItem;
                        // int index = dgRentals.CurrentCell.Column.DisplayIndex;
                        //  window.tbDuration.Text = dataRow.Row.ItemArray[14].ToString();

                        RentalEdit          window  = new RentalEdit();
                        RentalServiceClient service = new RentalServiceClient();
                        var  selectedItem           = dgRentals.SelectedItem.ToString();
                        Type t = dgRentals.SelectedItem.GetType();
                        System.Reflection.PropertyInfo[] props = t.GetProperties();

                        string rentalid = props[0].GetValue(dgRentals.SelectedItem).ToString();
                        Rental rental   = service.GetRentalById(Convert.ToInt32(rentalid));

                        //  string clientid = props[2].GetValue(dgRentals.SelectedItem).ToString();
                        //  string carid = props[1].GetValue(dgRentals.SelectedItem).ToString();
                        Client client = service.SearchClientById(Convert.ToInt32(rental.Clientid));
                        Car    car    = service.SearchCarById(Convert.ToInt32(rental.Carid));
                        window.cobClients.Text      = client.Idcardnumber;
                        window.cobClients.IsEnabled = false;
                        window.cobCars.Text         = car.Licenseplate;
                        window.cobCars.IsEnabled    = false;

                        window.dtpDateOut.Value    = rental.Dateout;
                        window.dtpDateIn.Value     = rental.Datein;
                        window.tbTotal.Text        = rental.Total.ToString();
                        window.tbKmIn.Text         = rental.Kmin.ToString();
                        window.tbKmOut.Text        = rental.Kmout.ToString();
                        window.tbDuration.Text     = rental.Duration.ToString();
                        window.tbDiscount.Text     = rental.Discount.ToString();
                        window.tbBalance.Text      = rental.Balance.ToString();
                        window.tbCost.Text         = rental.Cost.ToString();
                        window.tbPaid.Text         = rental.Advance.ToString();
                        window.rbPerDay.IsEnabled  = true;
                        window.rbPerHour.IsEnabled = true;
                        string type = rental.Renttype.ToString().Trim();
                        if (type == "Hour")
                        {
                            window.rbPerHour.IsChecked = true;
                        }
                        else
                        {
                            window.rbPerDay.IsChecked = true;
                        }
                        //  window.tbKmOut.Text = rental.Kmout.ToString();
                        window.dtpDateIn.IsEnabled  = true;
                        window.tbKmIn.IsEnabled     = true;
                        window.tbKmDriven.IsEnabled = true;
                        window.btnAdd.IsEnabled     = false;
                        window.btnSave.IsEnabled    = true;
                        window.btnClose.IsEnabled   = true;
                        window.btnPrint.IsEnabled   = true;

                        window.lblRentralId.Content = "Kölcsönzési azonosító: R-" + rental.Id.ToString();
                        if (rental.Status == false)
                        {
                            window.lblStatus.Content = "Sztátusz: Függőben";
                        }
                        else
                        {
                            window.lblStatus.Content  = "Sztátusz: Lezárt ";
                            window.btnSave.IsEnabled  = false;
                            window.btnClose.IsEnabled = false;
                        }
                        window.lblLastUpdated.Content = "Utolsó módosítás: " + rental.Datetime;

                        RentalEdit.rentalId = rental.Id;

                        /*      ing Path = Carid}
                         * "/>
                         *    nding Path = Clientid}
                         * "/>
                         *    inding Path = Dateout}"/>
                         *      = "{Binding Path=Datein}" /
                         *      nding Path = Kmout}"/>
                         *    nding Path = Kmin}"/>
                         *    "{Binding Path=Kmsdriven}
                         *    {Binding Path = Duration}"/
                         *    ding Path = Renttype}"/>
                         *    Binding Path = Cost}"/>
                         *    "{Binding Path=Discount}"
                         *    {Binding Path = Total}"/>
                         *    Binding Path = Balance}"/>
                         *    nding Path = Issueby}"/>
                         *    ding Path = Datetime}"/>
                         *    Binding Path = Status}"/>
                         */


                        //   window.dtpDateOut.Value = (DateTime) props[3].GetValue(dgRentals.SelectedItem);
                        //  window.dtpDateIn.Value = null;
                        //  window.tbDuration.Text = props[16].GetValue(dgRentals.SelectedItem).ToString();



                        // window.tbDuration.Text = dr[14].ToString();
                        window.Show();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
Beispiel #22
0
        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            string columnName = "";

            dgCar.SelectedItem  = null;
            btnDelete.IsEnabled = false;
            btnAdd.IsEnabled    = false;
            btnSave.IsEnabled   = false;
            switch (cobColumn.Text)
            {
            case "Azonosító":
                columnName = "CarID";
                break;

            case "Márka":
                columnName = "Manufacturer";
                break;

            case "Típus":
                columnName = "Model";
                break;

            case "Üzemanyag":
                columnName = "Fuel";
                break;

            case "Rendszám":
                columnName = "LicensePlate";
                break;

            case "Elérhető":
                columnName = "Available";
                break;
            }
            try
            {
                RentalServiceClient service = new RentalServiceClient();
                if (service.SearchCar(columnName, tbCarFilter.Text) != null)
                {
                    // List<Car> carList = new List<Car>();
                    // Car c = new Car();

                    // c.Id = Convert.ToInt32(tbClientFilter.Text);
                    //c.Name = tbClientFilter.Text;

                    //clientList.Add(service.SearchClientByName(c));

                    dgCar.ItemsSource = service.SearchCar(columnName, tbCarFilter.Text);
                }
                else
                {
                    System.Windows.MessageBox.Show("Keresés sikertelen, nem megfelelő adatok!", "Hiba", MessageBoxButton.OK, MessageBoxImage.Error);
                    tbCarFilter.Text  = "";
                    dgCar.ItemsSource = service.GetAllCars();
                }
            }
            catch (Exception)
            {
                System.Windows.MessageBox.Show("Keresés sikertelen, nem megfelelő adatok!", "Hiba", MessageBoxButton.OK, MessageBoxImage.Error);
                tbCarFilter.Text = "";
            }
        }
Beispiel #23
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            RentalServiceClient service = new RentalServiceClient();
            Rental r = service.GetRentalById(rentalId);


            r.Datein    = (DateTime)dtpDateIn.Value;
            r.Kmin      = Convert.ToInt32(tbKmIn.Text);
            r.Kmsdriven = r.Kmin - r.Kmout;
            r.Duration  = Convert.ToInt32(tbDuration.Text);
            if (rbPerDay.IsChecked == true)
            {
                r.Cost     = Convert.ToInt32(r.Duration * carList[cobCars.SelectedIndex].Rentalpriceperday);
                r.Renttype = "Day";
            }
            else
            {
                r.Cost     = Convert.ToInt32(r.Duration * carList[cobCars.SelectedIndex].Rentalpriceperhour);
                r.Renttype = "Hour";
            }
            if (tbDiscount.Text != "")
            {
                r.Discount = Convert.ToInt32(tbDiscount.Text);
            }
            else
            {
                r.Discount = 0;
            }
            r.Total = r.Cost - r.Discount;
            if (tbPaid.Text != "")
            {
                r.Advance = Convert.ToInt32(tbPaid.Text);
            }
            else
            {
                r.Advance = 0;
            }
            r.Balance  = r.Total - r.Advance;
            r.Issueby  = Login.userLoggedIn.Id;
            r.Datetime = DateTime.Now;
            if (r.Kmin < carList[cobCars.SelectedIndex].Kmclock)
            {
                System.Windows.MessageBox.Show("A Km óra állása nem lehet kevesebb!", "Hiba", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            if (r.Dateout >= (DateTime)dtpDateIn.Value)
            {
                System.Windows.MessageBox.Show("A visszahozatal dátuma nem lehett előbb mint a kikölcsönzés!", "Hiba", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                carList[cobCars.SelectedIndex].Kmclock   = r.Kmin;
                carList[cobCars.SelectedIndex].Available = true;
                service.UpdateCar(carList[cobCars.SelectedIndex]);
                if (service.UpdateRental(r) == 1)
                {
                    System.Windows.MessageBox.Show("Kölcsönzés adatai módosítva!", "Sikeres mentés", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else if (service.UpdateRental(r) == 0)
                {
                    System.Windows.MessageBox.Show("Módosítás, nem megfelelő adatok!", "Hiba", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }