コード例 #1
0
        public static bool addReAppointment(ReAppointment ra)
        {
            DBConnector dbcon = new DBConnector();

            //try
            //{
            if (dbcon.openConnection())
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "INSERT INTO reappointment (rank, post, suspension__system, suspension_reason, suspension_approved_note, rejoining_date, notes, employee_idemployee) VALUES (N'" + ra.rank + "', N'" + ra.post + "', N'" + ra.suspension__system + "', N'" + ra.suspension_reason + "', N'" + ra.suspension_approved_note + "', '" + ra.rejoining_date.ToString("yyyy-MM-dd") + "', N'" + ra.notes + "', " + 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
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool ra_present = true;
            if (ReAppointmentHandler.getReAppointment() == null)
            {
                ra_present = false;
            }

            ReAppointment ra = null;

            if (!ra_present)
            {
                ra = new ReAppointment();
            }
            else
            {
                ra = ReAppointmentHandler.getReAppointment();
            }

            ra.post = reappointment_post.Text;
            ra.rank = reappointment_rank.Text;
            ra.notes = reappointment_notes.Text;
            ra.rejoining_date = reappointment_rojoining_date.Value.Date;
            ra.suspension__system = reappointment_suspension__system.Text;
            ra.suspension_approved_note = reappointment_suspension_approved_note.Text;
            ra.suspension_reason = reappointment_suspension_reason.Text;

            bool state;

            if (!ra_present)
            {
                state = ReAppointmentHandler.addReAppointment(ra);
            }
            else
            {
                state = ReAppointmentHandler.updateReAppointment(ra);
            }

            if (state)
            {
                MessageBox.Show("Employee Re-Appointment details updated succesfully...!");

            }
            else
            {
                MessageBox.Show("Updating Re-Appointment details failed...!");
            }
        }
コード例 #3
0
        public static ReAppointment getReAppointment()
        {
            //try
            //{

            DBConnector dbcon = new DBConnector();

            if (dbcon.openConnection())
            {

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

                MySqlDataReader reader = cmd.ExecuteReader();

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

                ReAppointment ra = null;

                if (reader.Read())
                {
                    ra = new ReAppointment();

                    ra.post = reader["post"].ToString();
                    ra.rank = reader["rank"].ToString();
                    ra.notes = reader["notes"].ToString();
                    ra.suspension__system = reader["suspension__system"].ToString();
                    ra.suspension_approved_note = reader["suspension_approved_note"].ToString();
                    ra.suspension_reason = reader["suspension_reason"].ToString();

                    ra.rejoining_date = Convert.ToDateTime(reader["rejoining_date"]);

                }

                reader.Close();

                dbcon.closeConnection();

                return ra;
            }
            else
            {

                return null;
            }

            //}
            //catch (MySqlException e)
            //{
            //int errorcode = e.Number;
            //return null;
            //}
        }
コード例 #4
0
        public static bool updateReAppointment(ReAppointment ra)
        {
            DBConnector dbcon = new DBConnector();

            //try
            //{
            if (dbcon.openConnection())
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "UPDATE reappointment SET rank=N'" + ra.rank + "', post=N'" + ra.post + "', suspension__system=N'" + ra.suspension__system + "', suspension_reason=N'" + ra.suspension_reason + "', suspension_approved_note=N'" + ra.suspension_approved_note + "', rejoining_date='" + ra.rejoining_date.ToString("yyyy-MM-dd") + "', notes=N'" + ra.notes + "' 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;
            }*/
        }