Exemple #1
0
 partial void Deletetables_t(tables_t instance);
Exemple #2
0
 partial void Inserttables_t(tables_t instance);
Exemple #3
0
 partial void Updatetables_t(tables_t instance);
        private void buttonCreateConsoleName_Click(object sender, EventArgs e)
        {
            bool repeat = false;
            if (!String.IsNullOrEmpty(textBoxNameOfNewConsole.Text))
            {
                foreach (TablesMyClass console in _consolesList)
                {
                    if (console.PlaystationId.Equals(textBoxNameOfNewConsole.Text))
                    {
                        repeat = true;
                        MessageBox.Show("This name is unavailable, because it already exists!/nPlease choose another one.");
                    }
                }
                if (!repeat)
                {
                    int times = 5;
                    while (true)
                    {
                        try
                        {
                            Table<tables_t> consolesT = _db.GetTable<tables_t>();
                            tables_t console = new tables_t
                            {
                                playstation_id = textBoxNameOfNewConsole.Text,
                                playstation_state = "free",
                                order_time = new DateTime(2000, 1, 1, 0, 0, 0)
                            };

                            consolesT.InsertOnSubmit(console);
                            foreach (TimezonesMyClass t in _timezoneList)
                            {
                                Table<playstation_timezone> playstationPricesT = _db.GetTable<playstation_timezone>();
                                playstation_timezone timezonePrice = new playstation_timezone
                                {
                                    playstation_id = textBoxNameOfNewConsole.Text,
                                    timezone_cost_per_hour = 0,
                                    timezone_name = t.TimezoneName
                                };

                                playstationPricesT.InsertOnSubmit(timezonePrice);
                            }
                            _db.SubmitChanges();

                            Height = 330;
                            textBoxNameOfNewConsole.Enabled = false;
                            buttonCreateConsoleName.Enabled = false;
                            break;
                        }
                        catch (Exception)
                        {
                            --times;
                            if (times <= 0)
                            {
                                MessageBox.Show("Can't create console!", "Error", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                            }
                        }
                    }
                }
                UpdateListBoxOfTimezones();
                CheckListOfTimezonesOnFilledPrices();
            }
            else
            {
                MessageBox.Show("Enter name of new console point!");
            }
        }