public void MainSchedule_Load(bool week) { DateTime filter = week ? CalcDateFilter("week") : CalcDateFilter("month"); DataTable dtRecord = SqlUpdater.FirstCal(SqlUpdater.DateSQLFormat(filter), week); ScheduleCalendar.DataSource = dtRecord; }
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 ReportButton_Click(object sender, EventArgs e) { DataRowView drv = TypeCombo.SelectedItem as DataRowView; try { string item = TypeCombo.SelectedItem.ToString(); IDictionary <string, object> dictionary = SqlUpdater.ReportAppoint(item); janResult.Text = dictionary["Jan"].ToString(); febResult.Text = dictionary["Feb"].ToString(); marResult.Text = dictionary["Mar"].ToString(); aprResult.Text = dictionary["Apr"].ToString(); mayResult.Text = dictionary["May"].ToString(); junResult.Text = dictionary["Jun"].ToString(); julResult.Text = dictionary["Jul"].ToString(); augResult.Text = dictionary["Aug"].ToString(); sepResult.Text = dictionary["Sep"].ToString(); octResult.Text = dictionary["Oct"].ToString(); novResult.Text = dictionary["Nov"].ToString(); decResult.Text = dictionary["Dec"].ToString(); } catch (Exception ex) { Console.WriteLine(ex); } }
private void ReportButton_Click(object sender, EventArgs e) { DataRowView drv = comboBox1.SelectedItem as DataRowView; int id = Convert.ToInt32(comboBox1.SelectedValue); DataTable dtRecord = SqlUpdater.Schedule(id.ToString()); userReportView.DataSource = dtRecord; }
private void SearchButton_Click(object sender, EventArgs e) { string appointmentId = SearchBox.Text; appointmentDetails = SqlUpdater.GetAppointmentDetails(appointmentId); TeamIdLabel.Text = appointmentDetails["customerId"]; TypeLabel.Text = appointmentDetails["type"]; StartLabel.Text = appointmentDetails["start"]; EndLabel.Text = appointmentDetails["end"]; }
private void SearchButton_Click(object sender, EventArgs e) { string appointmentId = SearchBar.Text; form = SqlUpdater.GetAppointmentDetails(appointmentId); TeamIdBox.Text = form["customerId"]; TypeBox.Text = form["type"]; StartTimeBox.Text = SqlUpdater.ConvertToTimezone(form["start"]); EndTimeBox.Text = (SqlUpdater.ConvertToTimezone(form["end"])); }
public static bool AppHasConflict(DateTime startTime, DateTime endTime) { foreach (var app in SqlUpdater.GetAppointments().Values) { if (startTime < DateTime.Parse(app["end"].ToString()) && DateTime.Parse(app["start"].ToString()) < endTime) { return(true); } } return(false); }
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(); } }
static public int FindUser(string userName, string password) { MySqlConnection C = new MySqlConnection(SqlUpdater.conString); C.Open(); MySqlCommand cmd = new MySqlCommand($"SELECT userId FROM user WHERE userName = '******' AND password = '******'", C); MySqlDataReader rdr = cmd.ExecuteReader(); if (rdr.HasRows) { rdr.Read(); SqlUpdater.SetCurrentUserID(Convert.ToInt32(rdr[0])); SqlUpdater.SetCurrentUserName(userName); rdr.Close(); return(SqlUpdater.GetCurrentUserID()); } return(0); }
private void SearchButton_Click(object sender, EventArgs e) { int customerId = SqlUpdater.FindCustomer(SearchBar.Text); if (customerId != 0) { customerDetails = SqlUpdater.GetCustomerDetails(customerId); nameLabel.Text = customerDetails["customerName"]; phoneLabel.Text = customerDetails["phone"]; addressLabel.Text = customerDetails["address"]; cityLabel.Text = customerDetails["city"]; zipLabel.Text = customerDetails["zip"]; countryLabel.Text = customerDetails["country"]; } else { MessageBox.Show("Unable to find team"); } }
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 = ""; } }
private void SearchButton_Click(object sender, EventArgs e) { { int customerId = SqlUpdater.FindCustomer(SearchBar.Text); if (customerId != 0) { cForm = SqlUpdater.GetCustomerDetails(customerId); TeamNameBox.Text = cForm["customerName"]; TeamPhoneBox.Text = cForm["phone"]; TeamCityBox.Text = cForm["city"]; TeamAddressBox.Text = cForm["address"]; TeamZipBox.Text = cForm["zip"]; TeamCountryBox.Text = cForm["country"]; } else { MessageBox.Show("Unable to find Team"); } } }
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); } }
private void AllButton_Click(object sender, EventArgs e) { try { IDictionary <string, object> dictionary = SqlUpdater.ReportAll(); janResult.Text = dictionary["Jan"].ToString(); febResult.Text = dictionary["Feb"].ToString(); marResult.Text = dictionary["Mar"].ToString(); aprResult.Text = dictionary["Apr"].ToString(); mayResult.Text = dictionary["May"].ToString(); junResult.Text = dictionary["Jun"].ToString(); julResult.Text = dictionary["Jul"].ToString(); augResult.Text = dictionary["Aug"].ToString(); sepResult.Text = dictionary["Sep"].ToString(); octResult.Text = dictionary["Oct"].ToString(); novResult.Text = dictionary["Nov"].ToString(); decResult.Text = dictionary["Dec"].ToString(); } catch (Exception ex) { Console.WriteLine(ex); } }