コード例 #1
0
        public static bool addWorkingExperience(WorkingExperience we)
        {
            DBConnector dbcon = new DBConnector();

            try
            {
                if (dbcon.openConnection())
                {
                    MySqlCommand cmd = new MySqlCommand();
                    cmd.CommandText = "INSERT INTO working_experience (institute, address, telephone, email, department, contact, date_from, date_to, date_perma, resign_reason, responsibility, occupation_relevant, award, employee_idemployee) VALUES (N'" + we.institute + "', N'" + we.address + "', N'" + we.telephone + "', N'" + we.email + "', N'" + we.department + "', N'" + we.contact + "', '" + we.getDate_from().ToString("yyyy-MM-dd") + "', '" + we.getDate_to().ToString("yyyy-MM-dd") + "', '" + we.getDate_perma().ToString("yyyy-MM-dd") + "', N'" + we.resign_reason + "', N'" + we.responsibility + "', " + we.occupation_relevant + ", N'" + we.award + "', " + 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 bool updateWorkingExperience(WorkingExperience we)
        {
            //try
            //{

            DBConnector dbcon = new DBConnector();

            if (dbcon.openConnection())
            {

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "UPDATE working_experience SET institute=N'" + we.institute + "', address=N'" + we.address + "', telephone=N'" + we.telephone + "', email=" + we.email + ", department=" + we.department + ", contact=N'" + we.contact + "', date_from='" + we.getDate_from().ToString("yyyy-MM-dd") + "', date_to=N'" + we.getDate_to().ToString("yyyy-MM-dd") + "', date_perma='" + we.getDate_perma().ToString("yyyy-MM-dd") + "', resign_reason=N'" + we.resign_reason + "', responsibility=N'" + we.responsibility + "', occupation_relevant=" + we.occupation_relevant + ", award=N'" + we.award + "' WHERE employee_idemployee=" + Employee.employee_id + " AND idworking_experience=" + we.we_id;
                cmd.Connection = dbcon.connection;
                cmd.Prepare();
                cmd.ExecuteNonQuery();

                dbcon.closeConnection();

                return true;
            }
            else
            {

                return false;
            }

            //}
            //catch (MySqlException e)
            //{
            //int errorcode = e.Number;
            //return false;
            //}
        }