コード例 #1
0
        public static bool addJobStatus(JobStatus j)
        {
            DBConnector dbcon = new DBConnector();

            //try
            //{
            if (dbcon.openConnection())
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "INSERT INTO job_status (rank, post,em_type, contract_started_date, contract_ended_date, probation_time, probation_started_date, probation_ended_date, probation_to_permanent_status, probation_to_permanent_date, contract_to_permanent_date, employee_idemployee) VALUES (N'" + j.rank + "', N'" + j.post + "', N'" + j.em_type + "', '" + j.contract_started_date.ToString("yyyy-MM-dd") + "', '" + j.contract_ended_date.ToString("yyyy-MM-dd") + "', N'" + j.probation_time + "', '" + j.probation_started_date.ToString("yyyy-MM-dd") + "', '" + j.probation_ended_date.ToString("yyyy-MM-dd") + "', " + j.probation_to_permanent_status + ", '" + j.probation_to_permanent_date.ToString("yyyy-MM-dd") + "', '" + j.contract_to_permanent_date.ToString("yyyy-MM-dd") + "', " + Employee.employee_id + ")";
                cmd.Connection = dbcon.connection;
                cmd.Prepare();
                cmd.ExecuteNonQuery();

                dbcon.closeConnection();
                return true;
            }
            else
            {
                dbcon.closeConnection();
                return false;
            }

            /*}
            catch (MySqlException e)
            {
                int errorcode = e.Number;
                dbcon.closeConnection();
                return false;
            }*/
        }
コード例 #2
0
        public static JobStatus getJobStatus()
        {
            //try
            //{

            DBConnector dbcon = new DBConnector();

            if (dbcon.openConnection())
            {

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "SELECT * FROM job_status WHERE employee_idemployee=" + Employee.employee_id;
                cmd.Connection = dbcon.connection;

                MySqlDataReader reader = cmd.ExecuteReader();

                Console.Write(Employee.employee_id + "\n");

                JobStatus j = null;

                if (reader.Read())
                {
                    j = new JobStatus();

                    j.post = reader["post"].ToString();
                    j.rank = reader["rank"].ToString();
                    j.em_type = reader["em_type"].ToString();

                    j.probation_time = reader["probation_time"].ToString();

                    if (reader["probation_to_permanent_status"].ToString() == "True") { j.probation_to_permanent_status = true; }
                    else { j.probation_to_permanent_status = false; }

                    j.contract_started_date = Convert.ToDateTime(reader["contract_started_date"]);
                    j.contract_ended_date = Convert.ToDateTime(reader["contract_ended_date"]);
                    j.probation_started_date = Convert.ToDateTime(reader["probation_started_date"]);
                    j.probation_ended_date = Convert.ToDateTime(reader["probation_ended_date"]);
                    j.probation_to_permanent_date = Convert.ToDateTime(reader["probation_to_permanent_date"]);
                    j.contract_to_permanent_date = Convert.ToDateTime(reader["contract_to_permanent_date"]);

                }

                reader.Close();

                dbcon.closeConnection();

                return j;
            }
            else
            {

                return null;
            }

            //}
            //catch (MySqlException e)
            //{
            //int errorcode = e.Number;
            //return null;
            //}
        }
コード例 #3
0
        public static bool updateJobStatus(JobStatus j)
        {
            DBConnector dbcon = new DBConnector();

            //try
            //{
            if (dbcon.openConnection())
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "UPDATE job_status SET rank=N'" + j.rank + "', post=N'" + j.post + "', em_type=N'" + j.em_type + "', contract_started_date='" + j.contract_started_date.ToString("yyyy-MM-dd") + "', contract_ended_date='" + j.contract_ended_date.ToString("yyyy-MM-dd") + "', probation_time=N'" + j.probation_time + "', probation_started_date='" + j.probation_started_date.ToString("yyyy-MM-dd") + "', probation_ended_date='" + j.probation_ended_date.ToString("yyyy-MM-dd") + "', probation_to_permanent_status=" + j.probation_to_permanent_status + ", probation_to_permanent_date='" + j.probation_to_permanent_date.ToString("yyyy-MM-dd") + "', contract_to_permanent_date='" + j.contract_to_permanent_date.ToString("yyyy-MM-dd") + "' WHERE employee_idemployee=" + Employee.employee_id;
                cmd.Connection = dbcon.connection;
                cmd.Prepare();
                cmd.ExecuteNonQuery();

                dbcon.closeConnection();

                return true;
            }
            else
            {
                dbcon.closeConnection();
                return false;
            }

            /*}
            catch (MySqlException e)
            {
                int errorcode = e.Number;
                dbcon.closeConnection();
                return false;
            }*/
        }
コード例 #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool j_present = true;
            if (JobStatusHandler.getJobStatus() == null)
            {
                j_present = false;
            }

            JobStatus j = null;

            if (!j_present)
            {
                j = new JobStatus();
            }
            else
            {
                j = JobStatusHandler.getJobStatus();
            }

            j.post = job_post.Text;
            j.rank = job_rank.Text;
            j.em_type = job_employee_type.Text;
            j.probation_time = job_probation_time.Text;

            if (job_probation_to_permanent_status.Checked) { j.probation_to_permanent_status = true; }
            else { j.probation_to_permanent_status = false; }

            j.contract_started_date = job_contract_started_date.Value.Date;
            j.contract_ended_date = job_contract_ended_date.Value.Date;
            j.probation_started_date = job_probation_started_date.Value.Date;
            j.probation_ended_date = job_probation_ended_date.Value.Date;
            j.probation_to_permanent_date = job_probation_to_permanent_started_date.Value.Date;
            j.contract_to_permanent_date = job_contract_to_permanent_started_date.Value.Date;

            bool state;

            if (!j_present)
            {
                state = JobStatusHandler.addJobStatus(j);
            }
            else
            {
                state = JobStatusHandler.updateJobStatus(j);
            }

            if (state)
            {
                MessageBox.Show("Employee Job Status details updated succesfully...!");

            }
            else
            {
                MessageBox.Show("Updating Job Status details failed...!");
            }
        }