コード例 #1
0
        public int addRegister(MySqlConnection conn, registers register)
        {
            string sql = "INSERT INTO register (s_id, register_date, register_time, deregister_date, deregister_time)"
                         + " VALUES (" + register.S_id + "  ,'" + register.Register_date.ToString("yyyy-MM-dd") + "   ', '" + register.Register_time
                         + "   ', '" + register.Deregister_date.ToString("yyyy-MM-dd") + "   ', '" + register.Deregister_time + "')";

            MySqlCommand sqlComm = new MySqlCommand(sql, conn);

            return(sqlComm.ExecuteNonQuery());
        }
コード例 #2
0
        public List <registers> getAllRegister(MySqlConnection conn)
        {
            List <registers> listregister = new List <registers>();
            string           sql          = "SELECT * FROM register";
            MySqlCommand     sqlComm      = new MySqlCommand(sql, conn);
            MySqlDataReader  myReader;

            myReader = sqlComm.ExecuteReader();
            while (myReader.Read())
            {
                registers registers = new registers();
                registers.Register_id     = (int)myReader.GetValue(0);
                registers.S_id            = (int)myReader.GetValue(1);
                registers.Register_date   = (DateTime)myReader.GetValue(2);
                registers.Register_time   = (string)myReader.GetValue(3);
                registers.Deregister_date = (DateTime)myReader.GetValue(4);
                registers.Deregister_time = (string )myReader.GetValue(5);
                listregister.Add(registers);
            }
            return(listregister);
        }
コード例 #3
0
ファイル: Register.cs プロジェクト: qnzldmad/BedSysrtemGroup1
        private void registerPictureBox_Click(object sender, EventArgs e)
        {
            DatabaseConnertor databaseConnertor = new DatabaseConnertor();

            databaseConnertor.connect();

            registers register = new registers();

            register.S_id            = int.Parse(LoginIdLabel.Text);
            register.Register_date   = this.datePicker.Value;
            register.Register_time   = tbTime.Text;
            register.Deregister_date = this.datePicker1.Value;
            register.Deregister_time = tbDtime.Text;

            registerHandler registerHandler = new registerHandler();
            int             recordCnt1      = registerHandler.addRegister(databaseConnertor.getconn(), register);

            MessageBox.Show(recordCnt1 + " record has been inserted !!");

            this.Close();
            Register register1 = new Register();

            register1.Show();
        }