コード例 #1
0
        //Проверка на соответсвие с другими записями существующей БД
        private bool CheckAllTextBox(ref ParkCard parkCard)
        {
            try
            {
                AcceptFirstAndSecondNAme(First_NameTextBox.Text, Second_NameTextBox.Text);
                AcceptNumAuto(Car_NumTextBox.Text);
                for (int j = 0; j < parking.ParkCards.Length; j++)
                {
                    if (Car_NumTextBox.Text == parking.ParkCards[j].CarNum)
                    {
                        Car_NumTextBox.Foreground = Brushes.Red;
                        throw new Exception("Car is in the base");
                    }

                    if (First_NameTextBox.Text == parking.ParkCards[j].FirstName && Second_NameTextBox.Text == parking.ParkCards[j].SecondName)
                    {
                        parkCard = parking.ParkCards[j];
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
                return(false);
            }
            return(true);
        }
コード例 #2
0
        private void ListBoxProducts_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string          getInf   = listBoxProducts.SelectedItem.ToString();
            string          pattern  = @"\d{16}-\w{2,20}.\w{1}";
            Regex           regex    = new Regex(pattern);
            MatchCollection matches  = null;
            MatchCollection matches1 = null;
            MatchCollection matches2 = null;

            if (regex.IsMatch(getInf))
            {
                matches  = Regex.Matches(getInf, @"(\d{16})");
                matches1 = Regex.Matches(getInf, @"(\D{2,20})");
                matches2 = Regex.Matches(getInf, @".(\w{1})$");
            }
            if (matches == null && matches1 == null && matches2 == null)
            {
                return;
            }
            ParkCard temp = null;

            foreach (ParkCard item in parking)
            {
                if (item.ID == matches[0].Value.ToString() && item.SecondName == matches1[0].Value.ToString().Remove(0, 1).Remove(matches1[0].Value.Length - 3, 2) && item.FirstName.StartsWith(matches2[0].Value.ToString().Remove(0, 1)))
                {
                    temp = item;
                    break;
                }
            }
            textBlockInfo.Text = temp.FileString();
        }
コード例 #3
0
        //Метод добавления новой записи
        private void AddButtonMethof()
        {
            BlackFontTextBoxes();//проверка на отсутствие ошибок в вводе
            bool result;

            if (result = !TestNull())
            {
                return;                      //проверка на нулевые строки в textboxes
            }
            result = false;
            ParkCard temp = null;

            result = CheckAllTextBox(ref temp);//проверка на соответсвие с другими записями существующей БД
            if (!result)
            {
                return;
            }

            ParkCard tempParkcard = null;

            if (temp != null)
            {
                tempParkcard = new ParkCard(temp.ID, parking.GetFreeParkPLace(), First_NameTextBox.Text, Second_NameTextBox.Text, bool.Parse(Paid_Or_NoComboBox.Text), Car_ModelTextBox.Text, Car_NumTextBox.Text);
            }
            else
            {
                tempParkcard = new ParkCard(ParkCard.RandomID(this.parking), parking.GetFreeParkPLace(), First_NameTextBox.Text, Second_NameTextBox.Text, bool.Parse(Paid_Or_NoComboBox.Text), Car_ModelTextBox.Text, Car_NumTextBox.Text);
            }

            NumberTextBox.Text = tempParkcard.ParkPlace.ToString();
            IDTextBox.Text     = tempParkcard.ID.ToString();

            XElement newPropduct = ParkCard.GetXElement(IDTextBox, NumberTextBox, First_NameTextBox, Second_NameTextBox, Paid_Or_NoComboBox, Car_ModelTextBox, Car_NumTextBox);

            AddNewXElemetInXMLDocument(newPropduct);
            SaveXDocument();
            UpDateListBoxProducts();
            UpDateParkCards();
            DatagridTableUpDate();
        }
コード例 #4
0
        //Обновление записи
        private void UpDateMethod()
        {
            bool result = false;

            try { result = TestNull(); } catch (Exception exception) { MessageBox.Show(exception.Message); }
            if (!result)
            {
                return;
            }
            XElement selProduct  = (XElement)listboxPropducts.SelectedItem;
            XElement newPropduct = ParkCard.GetXElement(IDTextBox, NumberTextBox, First_NameTextBox, Second_NameTextBox, Paid_Or_NoComboBox, Car_ModelTextBox, Car_NumTextBox);

            if (selProduct != null)
            {
                try { selProduct.Remove(); } catch (NullReferenceException nullexception) { MessageBox.Show(nullexception.Message); }
            }
            SaveXDocument();
            AddNewXElemetInXMLDocument(newPropduct);
            UpDateListBoxProducts();
            DatagridTableUpDate();
            UpDateParkCards();
        }