Ejemplo n.º 1
0
 private void HouseTextBox_Enter(object sender, EventArgs e)
 {
     if (StreetChanged)
     {
         if (city == null)
         {
             return;
         }
         StreetChanged = false;
         street        = (from s in streets where s.Name == StreetTextBox.Text select s).FirstOrDefault();
         if (street == null)
         {
             return;
         }
         houses = street.House;
         AutoCompleteStringCollection autoCompleteStringCollection = new AutoCompleteStringCollection();
         autoCompleteStringCollection.AddRange((from h in houses select h.Number).ToArray());
         HouseTextBox.AutoCompleteCustomSource = autoCompleteStringCollection;
     }
 }
Ejemplo n.º 2
0
 public static _Street Trans(Street street) => new _Street
 {
     Id = street.Id, Name = street.Name, CityId = street.City.Id
 };
Ejemplo n.º 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            Customer customer;

            if (radioButton2.Checked)
            {
                if (!Checker.IsFIO(NameTextBox.Text))
                {
                    MessageBox.Show("Неверное ФИО заказчика");
                    return;
                }
                if (!Checker.IsPhoneNumber(PhoneNumberTextBox.Text))
                {
                    MessageBox.Show("Неверный номер телефона");
                    return;
                }
                if (!Checker.IsPassportNumber(PassportTextBox.Text))
                {
                    MessageBox.Show("Неверный номер пасспорта");
                    return;
                }
                if (!BCompany)
                {
                    if (!Operations.AddCustomer(NameTextBox.Text, PassportTextBox.Text, PhoneNumberTextBox.Text, out string Res))
                    {
                        MessageBox.Show(Res);
                        return;
                    }
                    customer = (from c in Operations.cont.CustomerSet where !(c is Company) && c.Passport == PassportTextBox.Text select c).First();
                }
                else
                {
                    if (!Checker.IsName(CompanyNameTextBox.Text))
                    {
                        MessageBox.Show("Неверная строка названия компании");
                        return;
                    }
                    if (!Checker.IsINN(INNTextBox.Text))
                    {
                        MessageBox.Show("Неверный ИНН компании");
                        return;
                    }
                    if (!Operations.AddCompany(NameTextBox.Text, PassportTextBox.Text, PhoneNumberTextBox.Text, CompanyNameTextBox.Text, INNTextBox.Text, out string Res))
                    {
                        MessageBox.Show(Res);
                        return;
                    }
                    customer = (from c in Operations.cont.CustomerSet where c is Company && (c as Company).INN == INNTextBox.Text select c).First();
                }
            }
            else
            {
                int id = int.Parse(CustomerDataGridView[Program.FindTitle(CustomerDataGridView, "Id"), CustomerDataGridView.SelectedRows[0].Index].Value.ToString());
                if (!BCompany)
                {
                    customer = Operations.FindCustomer(id);
                }
                else
                {
                    customer = Operations.FindCompany(id);
                }
            }
            if (city == null)
            {
                if (!Checker.IsName(CityTextBox.Text))
                {
                    MessageBox.Show("Неверное название города");
                    return;
                }
                if (!Operations.AddCity(CityTextBox.Text, out string Res))
                {
                    MessageBox.Show(Res);
                    return;
                }
                city = (from p in Operations.cont.CitySet where p.Name == CityTextBox.Text select p).First();
            }
            if (street == null)
            {
                if (!Checker.IsName(StreetTextBox.Text))
                {
                    MessageBox.Show("Неверное название улицы");
                    return;
                }
                if (!Operations.AddStreet(StreetTextBox.Text, city, out string Res1))
                {
                    MessageBox.Show(Res1);
                    return;
                }
                street = (from p in city.Street where p.Name == StreetTextBox.Text select p).First();
            }
            if (house == null)
            {
                if (!Checker.IsHouseNumber(HouseTextBox.Text))
                {
                    MessageBox.Show("Неверный номер дома");
                    return;
                }
                if (!Operations.AddHouse(HouseTextBox.Text, street, out string res2))
                {
                    MessageBox.Show(res2);
                    return;
                }
                house = (from p in street.House where p.Number == HouseTextBox.Text select p).First();
            }
            if (address == null)
            {
                if (!Checker.IsNumber(AddressTextBox.Text))
                {
                    MessageBox.Show("Неверный номер квартиры");
                    return;
                }
                if (!Operations.AddAddress(int.Parse(AddressTextBox.Text), house, out string Res4))
                {
                    MessageBox.Show(Res4);
                    return;
                }
                address = (from p in house.Address where p.Flat == int.Parse(AddressTextBox.Text) select p).First();
            }
            if (!Operations.AddOrder(CurrentUser, customer, address, out string res, out int order))
            {
                MessageBox.Show(res);
                return;
            }
            foreach (_OrderEntry o in OrderEntryList)
            {
                if (!Operations.AddOrderEntry(Operations.FindOrder(order), o.startTime, o.endTime, o.RegNum, Operations.FindMeter(o.MeterId), null, Operations.FindStatus(1), out string Res2))
                {
                    MessageBox.Show(Res2);
                    return;
                }
            }
            MessageBox.Show("Успешно добавлен заказ №" + order);
        }