private void saveBtn_Click(object sender, EventArgs e) { ResourceManager rm = new ResourceManager("KordellGiffordSoftwareII.Languages.Messages", typeof(Login).Assembly); var startTime = startDate.Value.Date + this.startTime.Value.TimeOfDay; var endTime = endDate.Value.Date + this.endTime.Value.TimeOfDay; //This is a LINQ expression, Applying a lambda expression is a simpler and easy to read syntax. bool overlap = Repo.appointments1.Any(x => startTime <x.end && endTime> x.start); TimeSpan start = new TimeSpan(17, 0, 0); TimeSpan end = new TimeSpan(8, 0, 0); if (endDate.Value.Date.DayOfWeek == DayOfWeek.Sunday || endDate.Value.Date.DayOfWeek == DayOfWeek.Saturday || startDate.Value.Date.DayOfWeek == DayOfWeek.Sunday || startDate.Value.Date.DayOfWeek == DayOfWeek.Saturday || (this.startTime.Value.TimeOfDay < end || this.startTime.Value.TimeOfDay > start) || (this.endTime.Value.TimeOfDay < end || this.endTime.Value.TimeOfDay > start) || this.startDate.Value.Date > this.endDate.Value.Date) { CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); MessageBox.Show(rm.GetString("bad time", ci)); ci.ClearCachedData(); } else if (overlap) { CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); MessageBox.Show(rm.GetString("overlap", ci)); ci.ClearCachedData(); } else { var tempId = 0; var title = titleIn.Text; var location = locationIn.Text; var description = descriptionIn.Text; //This is a LINQ expression, Applying a lambda expression is a simpler and easy to read syntax. int customer = customers.Where(x => x.Item2 == customerIn.Text).Select(x => x.Item1).First(); var contact = contactIn.Text; var url = urlIn.Text; var type = typeIn.Text; Appointments add = new Appointments(tempId, customer, Repo.uId.Item1, title, description, location, contact, type, url, startTime.ToUniversalTime(), endTime.ToUniversalTime()); if (Repo.AddAppointment(add)) { this.Close(); MainScreen mainScreen = new MainScreen(); CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); MessageBox.Show(rm.GetString("apt created", ci)); mainScreen.Display(); ci.ClearCachedData(); } else { CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); MessageBox.Show(rm.GetString("apt not created", ci)); ci.ClearCachedData(); } } }
private void loginBtn_Click(object sender, EventArgs e) { ResourceManager rm = new ResourceManager("KordellGiffordSoftwareII.Languages.Messages", typeof(Login).Assembly); string username = usernameText.Text; string password = passwordText.Text; if (da.Select($"SELECT * FROM user WHERE userName='******';")) { if (da.Select($"SELECT * FROM user WHERE userName='******' AND password='******';")) { this.Hide(); da.OpenConnection(); MySqlCommand cmd = new MySqlCommand($"SELECT userId, userName, active FROM user WHERE userName = '******' AND password = '******';", da.connectionS()); using (MySqlDataReader rdr = cmd.ExecuteReader()) { while (rdr.Read()) { Repo.uId = new Tuple <int, string, int>(Convert.ToInt32(rdr["userId"]), rdr["userName"].ToString(), 1); } } da.CloseConnection(); LogUserActivity(); MainScreen mainScreen = new MainScreen(); mainScreen.Show(); CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); MessageBox.Show(rm.GetString("welcome", ci) + $"{username}!"); SetActive(); ci.ClearCachedData(); } else { CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); MessageBox.Show(rm.GetString("no match", ci)); ci.ClearCachedData(); } } else { CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); MessageBox.Show(rm.GetString("no username", ci)); ci.ClearCachedData(); } }