private void saveBtn_Click(object sender, EventArgs e) { var tempId = 0; var name = nameIn.Text; var address = addressIn.Text; var address2 = address2In.Text; var city = cityIn.Text; switch (city) { case "Phoenix": city = "1"; break; case "New York": city = "2"; break; case "London": city = "3"; break; } var postal = postalIn.Text; var country = countryIn.Text; switch (country) { case "USA": country = "1"; break; case "United Kingdom": country = "2"; break; } var phone = phoneIn.Text.ToString(); Customers add = new Customers(tempId, name, address, address2, postal, city, country, phone); if (Repo.AddCustomer(add)) { CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); MessageBox.Show(rm.GetString("cust add", ci)); ci.ClearCachedData(); this.Close(); CustomerScreen customerScreen = new CustomerScreen(); customerScreen.Show(); ci.ClearCachedData(); } else { CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); MessageBox.Show(rm.GetString("cust not added", ci)); ci.ClearCachedData(); } }
private void timer1_Tick(object sender, EventArgs e) { try { CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); ResourceManager rm = new ResourceManager("KordellGiffordSoftwareII.Languages.Messages", typeof(Login).Assembly); titleLabel.Text = rm.GetString("title", ci); startLabel.Text = rm.GetString("start", ci); this.Text = rm.GetString("modify", ci); endLabel.Text = rm.GetString("end", ci); cancelBtn.Text = rm.GetString("cancel", ci); saveBtn.Text = rm.GetString("save", ci); locationLabel.Text = rm.GetString("location", ci); urlLabel.Text = rm.GetString("url", ci); typeLabel.Text = rm.GetString("type", ci); customerLabel.Text = rm.GetString("customers", ci); contactLabel.Text = rm.GetString("contact", ci); descriptionLabel.Text = rm.GetString("description", ci); ci.ClearCachedData(); Alert(); } catch { //intentionally open to allow display to reset without throwing errors } }
private void timer1_Tick(object sender, EventArgs e) { try { CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); ResourceManager rm = new ResourceManager("KordellGiffordSoftwareII.Languages.Messages", typeof(Login).Assembly); cName.Text = rm.GetString("title", ci); cAddress.Text = rm.GetString("address", ci); this.Text = rm.GetString("customers", ci); cAddress2.Text = rm.GetString("address2", ci); cCity.Text = rm.GetString("city", ci); cPostal.Text = rm.GetString("postal", ci); cCountry.Text = rm.GetString("country", ci); cPhone.Text = rm.GetString("phone", ci); closeBtn.Text = rm.GetString("close", ci); customerList.Columns[0].HeaderText = rm.GetString("custId", ci); customerList.Columns[1].HeaderText = rm.GetString("cust name", ci); addBtn.Text = rm.GetString("add", ci); modifyBtn.Text = rm.GetString("modify", ci); deleteBtn.Text = rm.GetString("delete", ci); ci.ClearCachedData(); Alert(); } catch { //intentionally open to allow display to reset without throwing errors } }
public static bool DeleteCustomer(int id) { try { da.OpenConnection(); var command = new MySqlCommand("DeleteCustomer", da.connectionS()); command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.Add("@id", MySqlDbType.VarChar).Value = id; command.ExecuteNonQuery(); da.CloseConnection(); return(true); } catch (Exception e) when(e.Message.ToLower().Contains("cannot delete or update a parent row: a foreign key constraint fails")) { CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); MessageBox.Show(rm.GetString("cust and apt", ci)); ci.ClearCachedData(); return(false); } catch (Exception e) { return(false); } }
private void TextFillByConsultant(DataTable dt) { CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); DataAccess da = new DataAccess(); reports.Text = rm.GetString("schedule", ci) + "\r\n\r\n"; string[] consultants = GetUsers(); foreach (string name in consultants) { reports.Text = reports.Text + name + "\r\n"; string startDate = ""; string endDate = ""; foreach (DataRow row in dt.Rows) { if (name == row["userName"].ToString()) { startDate = row["start"].ToString(); endDate = row["end"].ToString(); reports.Text = reports.Text + "\tStart:\t" + TimeZoneInfo.ConvertTimeFromUtc(Convert.ToDateTime(startDate), TimeZoneInfo.Local) + "\tEnd:\t" + TimeZoneInfo.ConvertTimeFromUtc(Convert.ToDateTime(endDate), TimeZoneInfo.Local) + "\r\n\r"; reports.Select(0, 0); } } } ci.ClearCachedData(); }
public void ClearCachedData() { var dt = DateTime.Now; old_culture.ClearCachedData(); // It can be any culture instance as the method should be static dt = DateTime.Now; }
public void ClearCachedDataTest() { CultureInfo ci = CultureInfo.GetCultureInfo("ja-JP"); Assert.True((object)ci == (object)CultureInfo.GetCultureInfo("ja-JP"), "Expected getting same object reference"); ci.ClearCachedData(); Assert.False((object)ci == (object)CultureInfo.GetCultureInfo("ja-JP"), "expected to get a new object reference"); }
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(); } } }
public LoginForm() { CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; cultureInfo.ClearCachedData(); local = new CultureInfo(cultureInfo.Name); InitializeComponent(); SetLoginScreenLanguage(); }
public void ClearCachedDataTest() { RemoteExecutor.Invoke(() => { CultureInfo ci = CultureInfo.GetCultureInfo("ja-JP"); Assert.True((object)ci == (object)CultureInfo.GetCultureInfo("ja-JP"), "Expected getting same object reference"); ci.ClearCachedData(); Assert.False((object)ci == (object)CultureInfo.GetCultureInfo("ja-JP"), "expected to get a new object reference"); }).Dispose(); }
private void TextFillByMonth(DataTable dt) { CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); reports.Text = rm.GetString("by month", ci) + "\r\n\r\n"; List <string> months = new List <string>(); months = CultureInfo.CurrentCulture.DateTimeFormat.MonthNames.ToList(); if (months.Count > 12) { months.RemoveAt(12); } months.ToArray(); foreach (string month in months) { reports.Text = reports.Text + month + "\r\n"; int consult = 0; int brief = 0; int review = 0; int other = 0; foreach (DataRow row in dt.Rows) { if (month == months[((DateTime)row["start"]).Month - 1]) { if (row["type"].ToString() == "Consulting") { consult++; } if (row["type"].ToString() == "Brief") { brief++; } if (row["type"].ToString() == "Review") { review++; } if (row["type"].ToString() == "Other") { other++; } } } reports.Text = reports.Text + "\tConsulting\t" + consult + "\r\n" + "\tBrief\t\t" + brief + "\r\n" + "\tReview\t\t" + review + "\r\n" + "\tOther\t\t" + other + "\r\n"; reports.Select(0, 0); } ci.ClearCachedData(); }
private void ReportsScreen_Load(object sender, EventArgs e) { CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); List <string> reportTypes = new List <string>() { rm.GetString("by month", ci), rm.GetString("by user", ci), rm.GetString("by cust", ci) }; reportType.DataSource = reportTypes; ci.ClearCachedData(); }
private void updateAptBtn_Click(object sender, EventArgs e) { if (Repo.IndexItem < 0) { CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); MessageBox.Show(rm.GetString("no apt", ci)); ci.ClearCachedData(); } else { ModifyAppointment modifyAppointment = new ModifyAppointment(); modifyAppointment.Show(); } }
private void timer1_Tick(object sender, EventArgs e) { try { CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); generateBtn.Text = rm.GetString("generate", ci); closeBtn.Text = rm.GetString("close", ci); this.Text = rm.GetString("reports", ci); ci.ClearCachedData(); Alert(); } catch { //intentionally open to allow display to reset without throwing errors } }
private void modifyBtn_Click(object sender, EventArgs e) { ModifyCustomer modifyCustomer = new ModifyCustomer(); if (Repo.Index > -1) { Repo.Index = Convert.ToInt32(customerList.SelectedRows[0].Cells[0].Value.ToString()); this.Hide(); modifyCustomer.Show(); } else { CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); MessageBox.Show(rm.GetString("cust select")); ci.ClearCachedData(); } }
private void TextFillByCustomer(DataTable dt) { CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); reports.Text = rm.GetString("by cust", ci) + "\r\n\r\n"; var customer = GetCustomers(); foreach (string name in customer) { reports.Text = reports.Text + name + "\r\n"; int consult = 0; int brief = 0; int review = 0; int other = 0; foreach (DataRow row in dt.Rows) { if (name == row["customerName"].ToString()) { if (row["type"].ToString() == "Consulting") { consult++; } if (row["type"].ToString() == "Brief") { brief++; } if (row["type"].ToString() == "Review") { review++; } if (row["type"].ToString() == "Other") { other++; } } } reports.Text = reports.Text + "\tConsulting\t" + consult + "\r\n" + "\tBrief\t\t" + brief + "\r\n" + "\tReview\t\t" + review + "\r\n" + "\tOther\t\t" + other + "\r\n"; reports.Select(0, 0); } ci.ClearCachedData(); }
private void Alert() { var alerts = Repo.Alerts(); if (alerts != null) { foreach (var item in alerts) { //This is a LINQ expression, Applying a lambda expression is a simpler and easy to read syntax. Repo.appointments1.Where(x => x.appointmentId == item.Item1).ToList().ForEach(x => x.alert = 1); Repo.alerted.Add(item.Item1); var name = item.Item2; CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); DialogResult dialogResult = MessageBox.Show($"{name}" + rm.GetString("15", 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(); } }
private void generateBtn_Click(object sender, EventArgs e) { CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); Reports r = new Reports(); if (reportType.Text == rm.GetString("by month", ci)) { TextFillByMonth(r.ReportMonthByType()); } else if (reportType.Text == rm.GetString("by user", ci)) { TextFillByConsultant(r.ReportConsultantSchedule()); } else if (reportType.Text == rm.GetString("by cust", ci)) { TextFillByCustomer(r.ReportCustomerByType()); } ci.ClearCachedData(); }
private void timer1_Tick(object sender, EventArgs e) { try { CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); ResourceManager rm = new ResourceManager("KordellGiffordSoftwareII.Languages.Messages", typeof(Login).Assembly); usernameLabel.Text = rm.GetString("username", ci); passwordLabel.Text = rm.GetString("password", ci); this.Text = rm.GetString("login", ci); loginBtn.Text = rm.GetString("login", ci); cancelBtn.Text = rm.GetString("cancel", ci); mainLabel.Text = rm.GetString("alatries", ci); ci.ClearCachedData(); } catch { //intentionally open to allow display to reset without throwing errors } }
private void timer1_Tick(object sender, EventArgs e) { try { CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); appointmentsLabel.Text = rm.GetString("appointment", ci); customerRecords.Text = rm.GetString("customers", ci); this.Text = rm.GetString("main screen", ci); reportsBtn.Text = rm.GetString("reports", ci); addAppBtn.Text = rm.GetString("add apoint", ci); updateAptBtn.Text = rm.GetString("update appoint", ci); deleteAptBtn.Text = rm.GetString("delete appoint", ci); exitBtn.Text = rm.GetString("close", ci); weekLabel.Text = rm.GetString("week view", ci); calendar.Columns[0].HeaderText = rm.GetString("sunday", ci); calendar.Columns[1].HeaderText = rm.GetString("monday", ci); calendar.Columns[2].HeaderText = rm.GetString("tuesday", ci); calendar.Columns[3].HeaderText = rm.GetString("wednesday", ci); calendar.Columns[4].HeaderText = rm.GetString("thursday", ci); calendar.Columns[5].HeaderText = rm.GetString("friday", ci); calendar.Columns[6].HeaderText = rm.GetString("saturday", ci); weekCal.Columns[0].HeaderText = rm.GetString("sunday", ci); weekCal.Columns[1].HeaderText = rm.GetString("monday", ci); weekCal.Columns[2].HeaderText = rm.GetString("tuesday", ci); weekCal.Columns[3].HeaderText = rm.GetString("wednesday", ci); weekCal.Columns[4].HeaderText = rm.GetString("thursday", ci); weekCal.Columns[5].HeaderText = rm.GetString("friday", ci); weekCal.Columns[6].HeaderText = rm.GetString("saturday", ci); appointmentsTable.Columns[1].HeaderText = rm.GetString("apt title", ci); appointmentsTable.Columns[2].HeaderText = rm.GetString("start time", ci); appointmentsTable.Columns[3].HeaderText = rm.GetString("end time", ci); ci.ClearCachedData(); Alert(); } catch { //intentionally open to allow display to reset without throwing errors } }
private void deleteBtn_Click(object sender, EventArgs e) { if (Repo.Index > -1) { try { var customerName = customerList.SelectedRows[0].Cells[1].Value.ToString(); int customerId = Convert.ToInt32(customerList.SelectedRows[0].Cells[0].Value.ToString()); CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); DialogResult dialogResult = MessageBox.Show(rm.GetString("confirm delete", ci) + $"{customerName}?", rm.GetString("confirm", ci), MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { if (Repo.DeleteCustomer(customerId)) { Display(); MessageBox.Show($"{customerName}" + rm.GetString("cust delete", ci)); } else { MessageBox.Show(rm.GetString("customer not deleted", ci)); } } ci.ClearCachedData(); } catch (Exception ex) { CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); MessageBox.Show(rm.GetString("customer not deleted", ci)); ci.ClearCachedData(); } } else { CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); MessageBox.Show(rm.GetString("cust select")); ci.ClearCachedData(); } }
private void deleteAptBtn_Click(object sender, EventArgs e) { try { if (Repo.IndexItem < 0) { CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); MessageBox.Show(rm.GetString("no apt", ci)); ci.ClearCachedData(); } else { CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); DialogResult dialogResult = MessageBox.Show(rm.GetString("confirm delete", ci), rm.GetString("confirm", ci), MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { if (Repo.DeleteAppointment(Repo.IndexItem)) { MessageBox.Show(rm.GetString("apt deleted", ci)); } else { MessageBox.Show(rm.GetString("apt not deleted", ci)); } } this.Display(); ci.ClearCachedData(); } } catch (Exception) { CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName); MessageBox.Show(rm.GetString("apt not deleted", ci)); ci.ClearCachedData(); } }
public void Dispose() { _original.ClearCachedData(); Thread.CurrentThread.CurrentCulture = _original; }