private void buttonApply_Click(object sender, EventArgs e) { Table<playstation_timezone> timeZoneTable = db.GetTable<playstation_timezone>(); playstation_timezone playstationTimezone = new playstation_timezone(); for (int i = 0; i < playstationsToChange.Count; i++) { timeZoneTable = db.GetTable<playstation_timezone>(); playstationTimezone = new playstation_timezone(); var matchedRecord = (from price in timeZoneTable where price.playstation_id == playstationsToChange[i] where price.timezone_name == timeZoneToFind select price).SingleOrDefault(); if (matchedRecord != null) { try { matchedRecord.timezone_cost_per_hour = (int) numericUpDownPrice.Value; db.SubmitChanges(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } } Close(); }
partial void Deleteplaystation_timezone(playstation_timezone instance);
private void button1_Click_1(object sender, EventArgs e) { if (textBoxTimeZoneName.Text == "" || textBoxTimeZoneName.Text.Length < 4) { MessageBox.Show( "Length of the name of timeZone not suit to requirments. Please inout name containing more than 4 symbols"); } else if (end_dateTimePicker.Value.Hour == start_datetimepicker.Value.Hour) { //change length MessageBox.Show("change time length "); } else { // string timeZoneName = ""; string name = textBoxTimeZoneName.Text; TimeSpan startTime = TimeSpan.Parse(start_datetimepicker.Value.Hour + ":00"); TimeSpan endTime = TimeSpan.Parse(end_dateTimePicker.Value.Hour + ":00"); try { Table<timezones_t> timeZonesT = db.GetTable<timezones_t>(); timezones_t timezones = new timezones_t(); timezones.timezone_name = name; timezones.timezone_start = startTime; timezones.timezone_end = endTime; timeZonesT.InsertOnSubmit(timezones); db.SubmitChanges(); RefreshTable(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } try { var playstations = (from q in db.GetTable<tables_t>() select new { q.playstation_id }).ToList(); Table<playstation_timezone> timeZoneTable; playstation_timezone playstationTimezone; for (int i = 0; i < playstations.Count; i++) { timeZoneTable = db.GetTable<playstation_timezone>(); playstationTimezone = new playstation_timezone { playstation_id = playstations[i].playstation_id, timezone_name = name }; timeZoneTable.InsertOnSubmit(playstationTimezone); db.SubmitChanges(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } textBoxTimeZoneName.Text = ""; ComboBoxTimeZOne.Items.Add(name); } }
partial void Updateplaystation_timezone(playstation_timezone instance);
partial void Insertplaystation_timezone(playstation_timezone instance);
private void detach_playstation_timezones(playstation_timezone entity) { this.SendPropertyChanging(); entity.timezones_t = null; }
private void attach_playstation_timezones(playstation_timezone entity) { this.SendPropertyChanging(); entity.tables_t = this; }
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!"); } }