private void TeamAddButton_Click(object sender, EventArgs e) { string timestamp = SqlUpdater.CreateTimestamp(); string userName = SqlUpdater.GetCurrentUserName(); if (string.IsNullOrEmpty(TeamNameText.Text) || string.IsNullOrEmpty(TeamPhoneText.Text) || string.IsNullOrEmpty(TeamCityText.Text) || string.IsNullOrEmpty(TeamCountryText.Text) || string.IsNullOrEmpty(TeamZipText.Text) || string.IsNullOrEmpty(TeamAddressText.Text)) { MessageBox.Show("Please complete all fields"); } else { int countryId = SqlUpdater.CreateRecord(timestamp, userName, "country", $"'{TeamCountryText.Text}'"); int cityId = SqlUpdater.CreateRecord(timestamp, userName, "city", $"'{TeamCityText.Text}', '{countryId}'"); int addressId = SqlUpdater.CreateRecord(timestamp, userName, "address", $"'{TeamAddressText.Text}', '', '{cityId}', '{TeamZipText.Text}', '{TeamPhoneText.Text}'"); SqlUpdater.CreateRecord(timestamp, userName, "customer", $"'{TeamNameText.Text}', '{addressId}', '1'"); MessageBox.Show("Team created."); Close(); } }
private void SaveButton_Click(object sender, EventArgs e) { string timestamp = SqlUpdater.CreateTimestamp(); int userId = SqlUpdater.GetCurrentUserID(); string username = SqlUpdater.GetCurrentUserName(); int appointmentId = Convert.ToInt32(SearchBar.Text); int customerId = Convert.ToInt32(TeamIdBox.Text); string type = TypeBox.Text; DateTime startTime = DateTime.Parse(StartTimeBox.Text).ToUniversalTime(); DateTime endTime = DateTime.Parse(EndTimeBox.Text).ToUniversalTime(); //String st = DateTime.Parse(StartTimeBox.Text).ToUniversalTime().ToString("u"); //String et = DateTime.Parse(EndTimeBox.Text).ToUniversalTime().ToString("u"); String st = DateTime.Parse(StartTimeBox.Text).ToUniversalTime().ToString("yyyy-MM-dd hh:mm:ss"); String et = DateTime.Parse(EndTimeBox.Text).ToUniversalTime().ToString("yyyy-MM-dd hh:mm:ss"); bool pass = Validator(); if (pass) { try { if (AppHasConflict(startTime, endTime)) { throw new ScheduleException(); } else { try { if (OutsideBusinessHours(startTime, endTime)) { throw new ScheduleException(); } else { SqlUpdater.UpdateAppt(customerId, userId, st, et, type, timestamp, username, appointmentId); mainScheduleObject.UpdateCalendar(); MessageBox.Show("Update Sucessfull."); Close(); } } catch (ScheduleException ex) { ex.BusinessHours(); } } } catch (ScheduleException ex) { ex.AppOverlap(); } } else { MessageBox.Show("Add Schedule Error."); } }
private void AddButton_Click(object sender, EventArgs e) { string timestamp = SqlUpdater.CreateTimestamp(); int userId = SqlUpdater.GetCurrentUserID(); string userName = SqlUpdater.GetCurrentUserName(); DateTime startTime = DateTime.Parse(StartTimeBox.Text).ToUniversalTime(); DateTime endTime = DateTime.Parse(EndTimeBox.Text).ToUniversalTime(); string type = TypeBox.Text; int teamId = Convert.ToInt32(TeamIdBox.Text); string st = DateTime.Parse(StartTimeBox.Text).ToUniversalTime().ToString("yyyy-MM-dd hh:mm:ss"); string et = DateTime.Parse(EndTimeBox.Text).ToUniversalTime().ToString("yyyy-MM-dd hh:mm:ss"); string title = " "; string description = " "; string location = " "; string url = " "; string contact = " "; bool pass = Validator(); if (pass) { try { if (AppHasConflict(startTime, endTime)) { throw new ScheduleException(); } else { try { if (OutsideBusinessHours(startTime, endTime)) { throw new ScheduleException(); } else { SqlUpdater.CreateSchedule("appointment", teamId, st, et, type, title, description, location, url, contact, timestamp, userName, userId); mainScheduleObject.UpdateCalendar(); Close(); } } catch (ScheduleException ex) { ex.BusinessHours(); } } } catch (ScheduleException ex) { ex.AppOverlap(); } }
private void loginButton_Click_1(object sender, EventArgs e) { if (FindUser(Username.Text, Password.Text) != 0) { this.Hide(); MainForm MainForm = new MainForm { loginForm = this }; Logger.WriteUserLoginLog(SqlUpdater.GetCurrentUserName()); MainForm.Show(); } else { MessageBox.Show(errorMessage); Password.Text = ""; } }
public bool UpdateCust(Dictionary <string, string> updatedForm) { MySqlConnection c = new MySqlConnection(SqlUpdater.conString); c.Open(); string recUpdate = $"UPDATE customer" + $" SET customerName = '{updatedForm["customerName"]}', lastUpdate = '{SqlUpdater.CreateTimestamp()}', lastUpdateBy = '{SqlUpdater.GetCurrentUserName()}'" + $" WHERE customerName = '{cForm["customerName"]}'"; MySqlCommand cmd = new MySqlCommand(recUpdate, c); int customerUpdated = cmd.ExecuteNonQuery(); recUpdate = $"UPDATE address" + $" SET address = '{updatedForm["address"]}', postalCode = '{updatedForm["zip"]}', phone = '{updatedForm["phone"]}', lastUpdate = '{SqlUpdater.CreateTimestamp()}', lastUpdateBy = '{SqlUpdater.GetCurrentUserName()}'" + $" WHERE address = '{cForm["address"]}'"; cmd = new MySqlCommand(recUpdate, c); int addressUpdated = cmd.ExecuteNonQuery(); recUpdate = $"UPDATE city" + $" SET city = '{updatedForm["city"]}', lastUpdate = '{SqlUpdater.CreateTimestamp()}', lastUpdateBy = '{SqlUpdater.GetCurrentUserName()}'" + $" WHERE city = '{cForm["city"]}'"; cmd = new MySqlCommand(recUpdate, c); int cityUpdated = cmd.ExecuteNonQuery(); recUpdate = $"UPDATE country" + $" SET country = '{updatedForm["country"]}', lastUpdate = '{SqlUpdater.CreateTimestamp()}', lastUpdateBy = '{SqlUpdater.GetCurrentUserName()}'" + $" WHERE country = '{cForm["country"]}'"; cmd = new MySqlCommand(recUpdate, c); int countryUpdated = cmd.ExecuteNonQuery(); c.Close(); if (customerUpdated != 0 && addressUpdated != 0 && cityUpdated != 0 && countryUpdated != 0) { return(true); } else { return(false); } }