예제 #1
0
        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();
                }
            }
        }
예제 #2
0
        private void checkAcceptReject(string state)
        {
            string conn;

            string uid = this.UsernameBox.Text;
            Connector c = new Connector();
            bool x = c.testConnection();
            if (x)
            {

                conn = c.getConnector();
                MySqlConnection newConnection = new MySqlConnection(conn);
                MySqlCommand newCommand = new MySqlCommand("update leavedata.leavedata set status='"+ state +"' where userid='" + uid + "';", newConnection);
                MySqlDataReader newReader;
                newConnection.Open();
                newReader = newCommand.ExecuteReader();
                MessageBox.Show("Success");
                newConnection.Close();
            }
            this.checkDataTable();
        }
예제 #3
0
        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");
            }
        }
예제 #4
0
        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();
            }
        }
예제 #5
0
        private void checkLeaveForm()
        {
            string conn;
            string s = "";
            string uid = 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")
            {
                leave = true;
            }
            else if(s == "accepted" || s == "rejected")
            {
                leave = false;
                deleteflag = true;
            }
            else
            {
                deleteflag = true;
                leave = false;
            }
        }
예제 #6
0
 private void LoginQuery()
 {
     string conn;
     //bool login = false;
     Connector c = new Connector();
     bool x = c.testConnection();
     if(x)
     {
         conn = c.getConnector();
         MySqlConnection newConnection = new MySqlConnection(conn);
         MySqlCommand newCommand;
         if (loginFlag == false)
         {
             newCommand = new MySqlCommand("select * from leavedata.employee where userid='" + this.UsernameBox.Text + "' and password='******';", newConnection);
         }
         else
         {
             newCommand = new MySqlCommand("select * from leavedata.employer where userid='" + this.UsernameBox.Text + "' and password='******';", newConnection);
         }
         MySqlDataReader newReader;
         newConnection.Open();
         newReader = newCommand.ExecuteReader();
         int count = 0;
         while(newReader.Read())
         {
             count += 1;
         }
         if(count == 1)
         {
             if (loginFlag == false)
             {
                 MessageBox.Show("Logged in as " + this.UsernameBox.Text);
                 HomeForm h = new HomeForm();
                 h.setLabel(this.UsernameBox.Text);
                 this.Hide();
                 h.Show();
             }
             else
             {
                 MessageBox.Show("Logged in as " + this.UsernameBox.Text);
                 AdminForm a = new AdminForm();
                 a.setLabel(this.UsernameBox.Text);
                 this.Hide();
                 a.Show();
             }
         }
         else if(count > 1)
         {
             MessageBox.Show("Duplicate Error");
         }
         else
         {
             MessageBox.Show("Incorrect Username or Password");
         }
         newConnection.Close();
     }
 }
예제 #7
0
        private void newLeaveRequest()
        {
            string conn;

            string uid = getLabel();
            Connector c = new Connector();
            bool x = c.testConnection();
            if (x)
            {

                conn = c.getConnector();
                MySqlConnection newConnection = new MySqlConnection(conn);
                MySqlCommand newCommand = new MySqlCommand("delete from leavedata.leavedata where userid='" + uid + "';", newConnection);
                MySqlDataReader newReader;
                newConnection.Open();
                newReader = newCommand.ExecuteReader();
                newConnection.Close();
            }
        }
예제 #8
0
        private void getProfileData()
        {
            string conn;
            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.employee where userid='" + this.Username.Text + "';", newConnection);
                MySqlDataReader newReader;
                newConnection.Open();
                newReader = newCommand.ExecuteReader();

                string username = "", name = "", contact = "", address = "", city = "", postcode = "";
                while (newReader.Read())
                {
                     username = newReader.GetString(0);
                     name = newReader.GetString(1);
                     contact = newReader.GetString(3);
                     address = newReader.GetString(4);
                     city = newReader.GetString(5);
                     postcode = newReader.GetString(6);
                }
                newConnection.Close();
                Profile p = new Profile();
                p.setProfile(username, name, contact, address, city, postcode);
                this.Hide();
                p.Show();

            }
        }
예제 #9
0
        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();
            }
        }