private void button1_Click(object sender, EventArgs e) { Console.WriteLine(this.textBox1.Text); Console.WriteLine(this.textBox2.Text); LocalStore.currentUser = DatabaseAPI.SelectUser(this.textBox1.Text); if (LocalStore.currentUser == null) { Console.WriteLine("Invalid username."); label3.Text = "Invalid username!"; this.textBox1.Text = ""; this.textBox2.Text = ""; } else { label3.Text = ""; string hashedPassword = sha256(this.textBox2.Text); if (LocalStore.currentUser.Password == hashedPassword) { FormStorer.Add("Dashboard", new Dashboard()); FormStorer.Get("Login").Visible = false; ((Dashboard)FormStorer.Get("Dashboard")).SetCurrentUser(); FormStorer.Get("Dashboard").Visible = true; } else { Console.WriteLine("Invalid password."); label3.Text = "Invalid password!"; this.textBox1.Text = ""; this.textBox2.Text = ""; } } }
private void button2_Click(object sender, EventArgs e) { Ticket ticket = new TicketManager.Ticket() { Name = this.textBox1.Text, Department = (Department)Enum.Parse(typeof(Department), this.comboBox1.Text), ToUser = this.comboBox2.Text, Priority = (Priority)Enum.Parse(typeof(Priority), this.comboBox3.Text), Category = (Category)Enum.Parse(typeof(Category), this.comboBox5.Text), FromUser = LocalStore.currentUser.Username, Date = DateTime.Now, State = State.Assigned, Description = this.richTextBox1.Text }; Console.Write("Created ticket:\n" + ticket); DatabaseAPI.AddTicket(ticket); this.textBox1.Text = ""; this.comboBox1.Text = ""; this.comboBox2.Text = ""; this.comboBox3.Text = ""; this.comboBox5.Text = ""; this.richTextBox1.Text = ""; }
private void button3_Click(object sender, EventArgs e) { string priority; if (this.comboBox4.Text == "") { priority = ""; } else { priority = ((int)(Priority)Enum.Parse(typeof(Priority), this.comboBox4.Text)).ToString(); } if (LocalStore.currentUser.Role == Role.Admin) { filteredTickets_ = DatabaseAPI.SelectTickets( this.comboBox6.Text, this.comboBox7.Text, priority, this.comboBox8.Text, this.comboBox9.Text); } else if (LocalStore.currentUser.Role == Role.Ticket_Editor) { filteredTickets_ = DatabaseAPI.SelectTicketsToUser( this.comboBox6.Text, this.comboBox7.Text, priority, this.comboBox8.Text, this.comboBox9.Text, LocalStore.currentUser.Username); filteredTickets_.AddRange(DatabaseAPI.SelectTicketsFromUser( this.comboBox6.Text, this.comboBox7.Text, priority, this.comboBox8.Text, this.comboBox9.Text, LocalStore.currentUser.Username)); } else if (LocalStore.currentUser.Role == Role.Employee) { filteredTickets_ = DatabaseAPI.SelectTicketsFromUser( this.comboBox6.Text, this.comboBox7.Text, priority, this.comboBox8.Text, this.comboBox9.Text, LocalStore.currentUser.Username); } ClearTable(tableLayoutPanel1); foreach (Ticket t in filteredTickets_) { AddTicketToTable(t, tableLayoutPanel1); } }
public static void UpdateUsers(ArrayList userList) { Console.WriteLine("Updated users: "); foreach (User u in userList) { Console.Write(u); } users = userList; DatabaseAPI.UpdateUsers(userList); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); FormStorer.Add("Login", new Login()); Database.Instance().SetConnection("C:\\Madalin\\TicketManager\\database.mdf"); Database.Instance().ExecuteQueryFromFile("..\\..\\PopulateUsersTable.sql"); Database.Instance().ExecuteQueryFromFile("..\\..\\PopulateTicketsTable.sql"); ArrayList users = DatabaseAPI.SelectUsers(); foreach (User u in users) { Console.Write(u); } DatabaseAPI.SelectTickets(); Application.Run(FormStorer.Get("Login")); }
private void button4_Click(object sender, EventArgs e) { // gather tickets from table ArrayList gatheredTickets = new ArrayList(); for (int i = 1; i < tableLayoutPanel1.RowCount; i++) { Ticket t = new Ticket(); t.Name = tableLayoutPanel1.GetControlFromPosition(1, i).Text; t.FromUser = tableLayoutPanel1.GetControlFromPosition(2, i).Text; t.ToUser = tableLayoutPanel1.GetControlFromPosition(3, i).Text; t.Priority = (Priority)Enum.Parse(typeof(Priority), tableLayoutPanel1.GetControlFromPosition(4, i).Text); t.Department = (Department)Enum.Parse(typeof(Department), tableLayoutPanel1.GetControlFromPosition(5, i).Text); t.Category = (Category)Enum.Parse(typeof(Category), tableLayoutPanel1.GetControlFromPosition(6, i).Text); t.Date = DatabaseAPI.ParseDateFromDB(tableLayoutPanel1.GetControlFromPosition(7, i).Text); t.State = (State)Enum.Parse(typeof(State), tableLayoutPanel1.GetControlFromPosition(8, i).Text); t.Description = tableLayoutPanel1.GetControlFromPosition(9, i).Text; gatheredTickets.Add(t); } // update database with tickets DatabaseAPI.ReplaceTickets(filteredTickets_, gatheredTickets); }
public static void LoadUsersFromDB() { Console.WriteLine("Loading users from database..."); users = DatabaseAPI.SelectUsers(); }