private void PrevButton_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (_currentPage != 1)
            {
                isPageSwitched = true;

                _customers.Clear();
                _rents.Clear();

                SqlDataReader reader = CarRentalDbWorker.ExecuteFormDataCommand("SelectFromCustomers", _currentPage - 1, _connection);
                _customers.Load(reader);
                reader.Close();

                PassBox.Text = _customers.Rows[0][1].ToString();
                _oldPass     = PassBox.Text;
                ////
                SqlDataReader readerRent = CarRentalDbWorker.ExecuteFormRentDataCommand(_oldPass, _connection);
                _rents.Load(readerRent);
                readerRent.Close();

                DataGrid.ItemsSource = _rents.DefaultView;
                ////
                LNameBox.Text = _customers.Rows[0][2].ToString();
                FNameBox.Text = _customers.Rows[0][3].ToString();
                MNameBox.Text = _customers.Rows[0][4].ToString();

                Title = string.Format("Клиент № {0}", _customers.Rows[0][0].ToString());
                _currentPage--;
            }
        }
예제 #2
0
        private void NextButton_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            isPageSwitched = true;
            _customers.Clear();

            if (_currentPage != _customersRowCount)
            {
                SqlDataReader reader = CarRentalDbWorker.ExecuteFormDataCommand("SelectFromCustomers", _currentPage + 1, _connection);
                _customers.Load(reader);
                reader.Close();

                PassBox.Text = _customers.Rows[0][1].ToString();
                _oldPass     = PassBox.Text;

                LNameBox.Text = _customers.Rows[0][2].ToString();
                FNameBox.Text = _customers.Rows[0][3].ToString();
                MNameBox.Text = _customers.Rows[0][4].ToString();

                Title = string.Format("Клиент № {0}", _customers.Rows[0][0].ToString());
                _currentPage++;
            }
            else
            {
                _oldPass = string.Empty;

                Title = "Новый клиент";

                PassBox.Text  = string.Empty;
                LNameBox.Text = string.Empty;
                FNameBox.Text = string.Empty;
                MNameBox.Text = string.Empty;
            }
        }
예제 #3
0
        private void ToEnd_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            isPageSwitched = true;
            _customers.Clear();

            SqlDataReader reader = CarRentalDbWorker.ExecuteFormDataCommand("SelectFromCustomers", _customersRowCount, _connection);

            _customers.Load(reader);
            reader.Close();

            Title = string.Format("Клиент № {0}", _customers.Rows[0][0].ToString());

            PassBox.Text = _customers.Rows[0][1].ToString();
            _oldPass     = PassBox.Text;

            LNameBox.Text = _customers.Rows[0][2].ToString();
            FNameBox.Text = _customers.Rows[0][3].ToString();
            MNameBox.Text = _customers.Rows[0][4].ToString();
        }
        public CustomerRentForm(SqlConnection connection)
        {
            InitializeComponent();
            CarsCatalogBlock.Visibility = Visibility.Collapsed;

            _connection  = connection;
            _customers   = new DataTable();
            _rents       = new DataTable();
            _carsCatalog = new DataTable();

            _customersRowCount   = CarRentalDbWorker.TotalFormDataRowCount(_connection, "Customers");
            _rentsRowCount       = CarRentalDbWorker.TotalFormDataRowCount(_connection, "Rent");
            _carsCatalogRowCount = CarRentalDbWorker.TotalFormDataRowCount(_connection, "Cars");

            SqlDataReader reader = CarRentalDbWorker.ExecuteFormDataCommand("SelectFromCustomers", _currentPage, _connection);

            _customers.Load(reader);
            reader.Close();

            Title = string.Format("Клиент № {0}", _customers.Rows[0][0].ToString());

            PassBox.Text = _customers.Rows[0][1].ToString();
            _oldPass     = PassBox.Text;
            ////
            SqlDataReader readerRent = CarRentalDbWorker.ExecuteFormRentDataCommand(_oldPass, _connection);

            _rents.Load(readerRent);
            readerRent.Close();

            DataGrid.ItemsSource = _rents.DefaultView;
            ////
            LNameBox.Text = _customers.Rows[0][2].ToString();
            FNameBox.Text = _customers.Rows[0][3].ToString();
            MNameBox.Text = _customers.Rows[0][4].ToString();

            Show();
        }
예제 #5
0
        public CustomersForm(SqlConnection connection)
        {
            InitializeComponent();

            _connection        = connection;
            _customers         = new DataTable();
            _customersRowCount = CarRentalDbWorker.TotalFormDataRowCount(_connection, "Customers");

            SqlDataReader reader = CarRentalDbWorker.ExecuteFormDataCommand("SelectFromCustomers", _currentPage, _connection);

            _customers.Load(reader);
            reader.Close();

            Title = string.Format("Клиент № {0}", _customers.Rows[0][0].ToString());

            PassBox.Text = _customers.Rows[0][1].ToString();
            _oldPass     = PassBox.Text;

            LNameBox.Text = _customers.Rows[0][2].ToString();
            FNameBox.Text = _customers.Rows[0][3].ToString();
            MNameBox.Text = _customers.Rows[0][4].ToString();

            Show();
        }