private void checkBoxcheck() { string conn; string uid = HomeForm.getLabel(); Connector c = new Connector(); bool x = c.testConnection(); if (x) { if (SameCheckBox.Checked == true) { conn = c.getConnector(); MySqlConnection newConnection = new MySqlConnection(conn); MySqlCommand newCommand = new MySqlCommand("select * from leavedata.employee where userid='" + uid + "';", newConnection); MySqlDataReader newReader; newConnection.Open(); newReader = newCommand.ExecuteReader(); string name = "", contact = ""; while (newReader.Read()) { name = newReader.GetString(1); contact = newReader.GetString(3); } this.textBox1.Text = name; this.textBox2.Text = contact; newConnection.Close(); } } }
private void HomeButton_Click(object sender, EventArgs e) { this.Hide(); HomeForm home = new HomeForm(); string u = HomeForm.getLabel(); home.setLabel(u); home.Show(); }
private void StatusButton_Click(object sender, EventArgs e) { string conn; string s = ""; string uid = HomeForm.getLabel(); Connector c = new Connector(); bool x = c.testConnection(); if (x) { conn = c.getConnector(); MySqlConnection newConnection = new MySqlConnection(conn); MySqlCommand newCommand = new MySqlCommand("select status from leavedata.leavedata where userid='" + uid + "';", newConnection); MySqlDataReader newReader; newConnection.Open(); newReader = newCommand.ExecuteReader(); while (newReader.Read()) { s = newReader.GetString(0); } newConnection.Close(); } if (s == "pending") { MessageBox.Show("Your current request is pending"); } else if (s == "rejected") { MessageBox.Show("Your request was rejected"); } else if (s == "accepted") { MessageBox.Show("Your request was accepted"); } else { MessageBox.Show("No leave request found"); } }
private void checkDataTable() { string conn; string uid = HomeForm.getLabel(); Connector c = new Connector(); bool x = c.testConnection(); if (x) { conn = c.getConnector(); MySqlConnection newConnection = new MySqlConnection(conn); MySqlCommand newCommand = new MySqlCommand("select * from leavedata.leavedata;", newConnection); MySqlDataAdapter data = new MySqlDataAdapter(); data.SelectCommand = newCommand; DataTable dataset = new DataTable(); data.Fill(dataset); BindingSource b = new BindingSource(); b.DataSource = dataset; DataView.DataSource = b; data.Update(dataset); newConnection.Close(); } }
private void updateLeaveData() { string conn; string uid = HomeForm.getLabel(); Connector c = new Connector(); bool x = c.testConnection(); if (x) { string fromdate = DateTimeFrom.Text; string todate = DateTimeTo.Text; string reason; if (ReasonBox.Text == "Other") { reason = OtherBox.Text; } else { reason = ReasonBox.Text; } conn = c.getConnector(); MySqlConnection newConnection1 = new MySqlConnection(conn); MySqlCommand newCommand1 = new MySqlCommand("INSERT INTO leavedata(`userid`,`name`,`contact`, `fromdate`, `todate`, `reason`,`status`) VALUES ('" + uid + "','" + this.textBox1.Text + "','" + this.textBox2.Text + "', '" + this.DateTimeFrom.Text + "', '" + this.DateTimeTo.Text + "', '" + reason + "','pending')", newConnection1); newConnection1.Open(); MySqlDataReader newReader1; newReader1 = newCommand1.ExecuteReader(); MessageBox.Show("Submitted LeaveForm"); newConnection1.Close(); HomeForm h = new HomeForm(); string u = HomeForm.getLabel(); h.setLabel(u); this.Hide(); h.Show(); } }