//削除
        private void btn_del_user_Click(object sender, EventArgs e)
        {
            //MessageBox.Show("btn_del_user_click");
            if (uid != "0" && user != "")
            {
                int    result = 0;
                string sql    = "";

                //デリート
                sql    = "delete from parsonal where uid = '" + uid + "'";
                result = mdb.executeNonQuery(sql);

                //バックアップ
                sql    = "insert into timedata_backup select * from timedata where uid = '" + uid + "'";
                result = mdb.executeNonQuery(sql);

                //削除
                sql    = "delete from timedata where uid = '" + uid + "'";
                result = mdb.executeNonQuery(sql);

                MessageBox.Show("削除しました。");
            }
            this.Close();
        }
Exemple #2
0
        //登録
        private void btn_regist_user_Click(object sender, EventArgs e)
        {
            //MessageBox.Show("btn_regist_user_Click");
            if (tbox_user.Text != "")
            {
                //DB登録
                int             result;
                OleDbDataReader reader;

                reader = mdb.executeQuery("select count(1) from parsonal where uid = '" + this.lbl_11.Text + "'");
                reader.Read();
                result = (int)reader.GetValue(0);
                if (result == 0)
                {
                    string sql = "insert into parsonal values ("
                                 + " '" + this.lbl_11.Text + "'"
                                 + ",'" + this.lbl_12.Text + "'"
                                 + ",'" + this.lbl_13.Text + "'"
                                 + ",'" + this.lbl_14.Text + "'"
                                 + ",'" + this.lbl_15.Text + "'"
                                 + ",'" + this.tbox_user.Text + "')";
                    result = mdb.executeNonQuery(sql);

                    MessageBox.Show("登録しました。");
                    //フォームクローズ
                    this.Close();
                }
                else if (result > 0)
                {
                    MessageBox.Show("既に登録済みです。");
                }
            }
            else
            {
                MessageBox.Show("名前を入力してください。");
            }
        }
        private void timer_add_Tick(object sender, EventArgs e)
        {
            if (nfc.IsCurrentCard && this.timer_lock == false)
            {
                try
                {
                    int             result;
                    string          user;
                    OleDbDataReader reader;
                    DateTime        addDate;
                    timer_lock = true;
                    byte[] recv;
                    byte[] send = null;
                    //UID
                    send = new byte[] { 0xff, 0xca, 0x00, 0x00 };
                    recv = nfc.SendCommand2(send);
                    uid  = BitConverter.ToString(recv).Replace("-", "");
                    Debug.WriteLine("CARD_UID:" + uid);

                    string sql = "select count(1) from parsonal where uid = '" + uid + "'";
                    reader = mdb.executeQuery(sql);
                    reader.Read();
                    result = (int)reader.GetValue(0);
                    if (result > 0)
                    {
                        foreach (UserInval v in user_list)
                        {
                            if (v.uid == uid)
                            {
                                Debug.WriteLine("時間内DB追加無し");
                                return;
                            }
                        }

                        sql    = "select user from parsonal where uid = '" + uid + "'";
                        reader = mdb.executeQuery(sql);
                        reader.Read();
                        user = (string)reader.GetValue(0);

                        addDate = DateTime.Now;
                        sql     = "select count(1) from timedata where uid = '" + uid + "'";
                        reader  = mdb.executeQuery(sql);
                        reader.Read();
                        result = (int)reader.GetValue(0);

                        sql = "insert into timedata values ("
                              + "'" + uid + "',"
                              + (result + 1) + ","
                              + "'" + DateTime.Now + "')";
                        result = mdb.executeNonQuery(sql);
                        if (result > 0)
                        {
                            //正常登録
                            this.lbl_name.Text          = user;
                            this.lbl_timer2.Text        = addDate.ToLongTimeString();
                            this.lbl_timer2.ForeColor   = Color.Red;
                            this.timer.Enabled          = false;
                            this.timer_interval.Enabled = true;
                            Debug.WriteLine("正常登録:" + uid);
                            Debug.WriteLine("");

                            user_list.Add(new UserInval(uid, DateTime.Now));
                        }
                    }
                }
                catch (ApplicationException)
                {
                    //null
                    Debug.WriteLine("ApplicationException:MainForm");
                }
            }
            if (nfc.IsReaderRemoved == true)
            {
                this.sttl_status.Text = "カードリーダーが接続されていません";
                app_failed            = true;
            }
            else if (nfc.IsNfcFaild == true)
            {
                this.Close();
            }
            else
            {
                if (app_failed == false)
                {
                    this.sttl_status.Text = "ポーリング中";
                }
            }

            timer_lock = false;
        }