Example #1
0
        public static string CollectorValidateString(Collector collector)
        {
            string checkBug = String.Empty;
            bool IsOK;

            if (!ContainsLetters(collector.CollectorId))
                checkBug += IdentityValidation.CheckId(collector.CollectorId) ? LangPL.InsertFormLang["textBoxCCID"] : String.Empty;
            else
                checkBug += LangPL.InsertFormLang["textBoxCCID"];

            checkBug += (IsOK = CityNameValidation(collector.Name)) ? String.Empty : LangPL.InsertFormLang["textBoxName"];
            if (IsOK)
                collector.Name = UppercaseFirst(collector.Name);

            checkBug += (IsOK = CityNameValidation(collector.LastName)) ? String.Empty : LangPL.InsertFormLang["textBoxLastName"];
            if (IsOK)
                collector.LastName = UppercaseFirst(collector.LastName);

            checkBug += PostalCodeValidation(collector.PostalCode) ? String.Empty : LangPL.InsertFormLang["textBoxPostalCode"];

            checkBug += (IsOK = CityNameValidation(collector.City)) ? String.Empty : LangPL.InsertFormLang["textBoxCity"];
            if (IsOK)
                collector.City = UppercaseFirst(collector.City);

            checkBug += (EmptyString(collector.Address)) ? LangPL.InsertFormLang["textBoxAddress"] : String.Empty;
            checkBug += PhoneValidation(collector.PhoneNumber) ? String.Empty : LangPL.InsertFormLang["textBoxPhoneNumber"];

            return checkBug;
        }
Example #2
0
        /// <summary>
        /// Generuje inkasentów losowo dobierając wartości pól i dodaje ich do bazy.
        /// </summary>
        static void GenerateCollectors()
        {
            Random rnd = new Random();
            string[] nameAndLastName;
            string[] postalCodeAndCity;
            Collector collector;
            int tpmGender = 0;

            for (int i = 0; i < numberOfCollectors; i++)
            {
                collector = new Collector();
                tpmGender = rnd.Next(0, 9);
                collector.CollectorId = GenerateRandomPesel("Collector", tpmGender);
                nameAndLastName = GenerateNameAndLastName(tpmGender);
                collector.Name = nameAndLastName[0];
                collector.LastName = nameAndLastName[1];
                postalCodeAndCity = GeneratePostalCodeAndCity();
                collector.PostalCode = postalCodeAndCity[0];
                collector.City = postalCodeAndCity[1];
                collector.Address = SampleDataSource.streets[rnd.Next(0, SampleDataSource.streets.Length)] + ' ' + rnd.Next(1, 100).ToString();
                collector.PhoneNumber = GeneratePhoneNumber();

                collector.InsertIntoDB();
            }
        }
Example #3
0
        /// <summary>
        /// Wywoływana po naciśnięciu przycisku "Zapisz". Zapisuje zmiany i zamyka formularz, jeśli wprowadzone zmiany są poprawnie.
        /// </summary>
        /// <param name="sender">Przycisk "Zapisz".</param>
        /// <param name="e">Argumenty zdarzenia.</param>
        private void btSave_Click(object sender, EventArgs e)
        {
            int Parse;

            switch (Table)
            {
                case Tables.Collectors:
                    if (Auxiliary.IsCurrentValueOK(ControlToBool_Dict))
                    {
                        Collector modifiedCollector = new Collector();
                        modifiedCollector.CollectorId = this.Controls.Find("CollectorId", true)[0].Text;
                        modifiedCollector.Name = this.Controls.Find("Name", true)[0].Text;
                        modifiedCollector.LastName = this.Controls.Find("LastName", true)[0].Text;
                        modifiedCollector.PostalCode = this.Controls.Find("PostalCode", true)[0].Text;
                        modifiedCollector.City = this.Controls.Find("City", true)[0].Text;
                        modifiedCollector.Address = this.Controls.Find("Address", true)[0].Text;
                        modifiedCollector.PhoneNumber = this.Controls.Find("PhoneNumber", true)[0].Text;
                        modifiedCollector.ModifyRecord(ids.ElementAt(0));
                        modified = true;
                        this.Close();
                    }
                    else
                        MessageBox.Show(LangPL.InsertFormLang["Fill in all fields"]);
                    break;

                case Tables.Customers:
                    if (Auxiliary.IsCurrentValueOK(ControlToBool_Dict))
                    {
                        Customer modifiedCustomer = new Customer();
                        modifiedCustomer.CustomerId = this.Controls.Find("CustomerId", true)[0].Text;
                        modifiedCustomer.Name = this.Controls.Find("Name", true)[0].Text;
                        modifiedCustomer.LastName = this.Controls.Find("LastName", true)[0].Text;
                        modifiedCustomer.PostalCode = this.Controls.Find("PostalCode", true)[0].Text;
                        modifiedCustomer.City = this.Controls.Find("City", true)[0].Text;
                        modifiedCustomer.Address = this.Controls.Find("Address", true)[0].Text;
                        modifiedCustomer.PhoneNumber = this.Controls.Find("PhoneNumber", true)[0].Text;
                        modifiedCustomer.ModifyRecord(ids.ElementAt(0));
                        modified = true;
                        this.Close();
                    }
                    else
                        MessageBox.Show(LangPL.InsertFormLang["Fill in all fields"]);
                    break;

                case Tables.Areas:
                    if (Auxiliary.IsCurrentValueOK(ControlToBool_Dict))
                    {
                        Area modifiedArea = new Area();
                        modifiedArea.AreaId = new Guid(this.Controls.Find("AreaId", true)[0].Text);
                        modifiedArea.Street = this.Controls.Find("Street", true)[0].Text;
                        if (CBConfigs[0].ReturnForeignKey() == "")
                            modifiedArea.CollectorId = "";
                        else
                            modifiedArea.CollectorId = CBConfigs[0].ReturnForeignKey();
                        modifiedArea.ModifyRecord(ids.ElementAt(0));
                        modified = true;
                        this.Close();
                    }
                    else
                        MessageBox.Show(LangPL.InsertFormLang["Fill in all fields"]);
                    break;

                case Tables.Counters:
                    if (Auxiliary.IsCurrentValueOK(ControlToBool_Dict))
                    {
                        Counter modifiedCounter = new Counter();

                        modifiedCounter.CounterNo = Convert.ToInt32(this.Controls.Find("CounterNo", true)[0].Text);
                        Int32.TryParse(this.Controls.Find("CircuitNo", true)[0].Text, out Parse);
                        modifiedCounter.CircuitNo = Parse;

                        if (CBConfigs[0].comboBox.SelectedIndex != 0) //jeśli w jednym comboboxie index jest różny od 0, to w drugim też
                        {
                            modifiedCounter.AddressId = new Guid(CBConfigs[0].ReturnForeignKey());
                            modifiedCounter.CustomerId = CBConfigs[1].ReturnForeignKey();
                        }
                        else
                        {
                            modifiedCounter.AddressId = null;
                            modifiedCounter.CustomerId = null;
                        }

                        modifiedCounter.ModifyRecord(ids.ElementAt(0));
                        modified = true;
                        this.Close();
                    }
                    else
                        MessageBox.Show(LangPL.InsertFormLang["Fill in all fields"]);
                    break;

                case Tables.Addresses:
                    if (Auxiliary.IsCurrentValueOK(ControlToBool_Dict))
                    {
                        Address modifiedAddress = new Address();
                        modifiedAddress.AddressId = new Guid(this.Controls.Find("AddressId", true)[0].Text);
                        Int32.TryParse(this.Controls.Find("HouseNo", true)[0].Text, out Parse);
                        modifiedAddress.HouseNo = Parse;
                        Int32.TryParse(this.Controls.Find("FlatNo", true)[0].Text, out Parse);
                        if (Parse > 0)
                            modifiedAddress.FlatNo = Parse;
                        else
                            modifiedAddress.FlatNo = null;
                        modifiedAddress.AreaId = new Guid(CBConfigs[0].ReturnForeignKey());
                        modifiedAddress.ModifyRecord(ids.ElementAt(0));
                        modified = true;
                        this.Close();
                    }
                    else
                        MessageBox.Show(LangPL.InsertFormLang["Fill in all fields"]);
                    break;
            }
        }
Example #4
0
        private bool InsertCollector()
        {
            Collector c = new Collector();
            c.CollectorId = tbCollectorID.Text;
            c.Name = tbCollectorFirstName.Text;
            c.LastName = tbCollectorLastName.Text;
            c.PostalCode = tbCollectorPostalCode.Text;
            c.City = tbCollectorCity.Text;
            c.Address = tbCollectorAddress.Text;
            c.PhoneNumber = tbCollectorPhoneNumber.Text;

            if (Auxiliary.IsCurrentValueOK(Current_ControlToBool_Dict))
            {
                c.InsertIntoDB();
                modified = true;
                InsertedTo = Tables.Collectors;
                return true;
            }
            else
            {
                MessageBox.Show(LangPL.InsertFormLang["Fill in all fields"]);
                return false;
            }
        }