private void AppointmentForm_FormClosing(object sender, FormClosingEventArgs e) { this.Hide(); Mainscreen mainscreen = new Mainscreen(); mainscreen.Show(); }
//Form Switch buttons private void ExitButton_Click(object sender, EventArgs e) { this.Hide(); Mainscreen mainscreen = new Mainscreen(); mainscreen.Show(); }
//Form Switch buttons private void CustomerForm_FormClosing(object sender, FormClosingEventArgs e) { this.Hide(); Mainscreen mainscreen = new Mainscreen(); CustIndx = null; mainscreen.Show(); }
//Form Switch buttons private void Loginbutton_Click(object sender, EventArgs e) { string userName = UsertextBox.Text.ToString(); string userPass = PasswordtextBox.Text.ToString(); List <string> lines = new List <string> { " " }; var userCreds = FormModel.SearchQuery("select * from user"); //called 2x in code wasnt enough to make a full method when inline lambda was faster Action <List <String> > logging = writeToLog => { foreach (string line in lines) { using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"loginlogs.txt", true)) { file.WriteLine(line); } } }; bool nameTrue = false; bool passTrue = false; foreach (DataRow row in userCreds.Rows) { if (userName == row.ItemArray[1].ToString()) { nameTrue = true; } if (userPass == row.ItemArray[2].ToString()) { passTrue = true; } if (nameTrue && passTrue) { FormModel.CurrentUserID = row.ItemArray[0].ToString(); FormModel.CurrentUser = row.ItemArray[1].ToString(); lines.Add($"UserID = \"{row.ItemArray[0].ToString()}\""); lines.Add($"UserName = \"{row.ItemArray[1].ToString()}\""); lines.Add($"Time = \"{DateTime.UtcNow}\""); lines.Add($"Success = \"True\""); lines.Add($""); logging(lines); var tempTable = FormModel.SearchQuery("select c.customerName, a.start, a.type from appointment a inner join customer c on a.customerID = c.customerID;"); foreach (DataRow nextAppt in tempTable.Rows) { if (DateTime.UtcNow.AddHours(2) >= DateTime.Parse(nextAppt.ItemArray[1].ToString()) && DateTime.UtcNow <= DateTime.Parse(nextAppt.ItemArray[1].ToString())) { MessageBox.Show($"Urgent! There is an upcoming appointment with " + $"{nextAppt.ItemArray[0].ToString()} at " + $"{nextAppt.ItemArray[1].ToString()} for " + $"{nextAppt.ItemArray[2].ToString()}."); } } this.Hide(); Mainscreen mainscreen = new Mainscreen(); mainscreen.Show(); break; } } if (!(nameTrue && passTrue)) { lines.Add($"UserName = \"{UsertextBox.Text}\""); lines.Add($"UserPass = \"{PasswordtextBox.Text}\""); lines.Add($"Time = \"{DateTime.UtcNow}\""); lines.Add($"Success = \"Failed\""); lines.Add($""); MessageBox.Show($"{Properties.Resources.BadLogin}"); logging(lines); } }