Beispiel #1
0
        public static bool insert_record(string id, string info, string create_time)
        {
            bool bR = false;

            try
            {
                int      result = 0;
                object[] pars   = new object[]
                {
                    id, info, create_time
                };

                result = int.Parse(CsharpSQLiteHelper.ExecuteNonQuery(sql_insert_record, pars).ToString());
                if (result >= 1)
                {
                    bR = true;
                }
                else
                {
                    bR = false;
                }
            }
            catch (System.Exception ex)
            {
                //MessageBox.Show("出现错误:" + ex.Message);
            }
            return(bR);
        }
Beispiel #2
0
        public void change_control_state(int state, object o)
        {
            switch (state)
            {
            case 0:    //获取指纹成功
                //btnStart.Visible = true;
                this.pictureBox1.Image = global::ZkFingerDemo.Properties.Resources.business_user_accept;
                string xh = (string)index_user_list[(int)o];
                string insert_check_record = string.Format("replace into CheckRecords(record_id,checkDate,xh) values('{0}','{1}','{2}');",
                                                           this.unique_check_id, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), xh);
                CsharpSQLiteHelper.ExecuteNonQuery(insert_check_record, null);
                this.refresh_check_list();
                DataRow[] rows = this.person_list.Select(string.Format("xh='{0}'", xh));
                if (rows.Length > 0)
                {
                    string user_name = rows[0]["xm"].ToString();
                    string str       = "欢迎你," + user_name;
                    this.lblName.Text = str;
                    Program.play_voice(str);
                }
                break;

            case 1:    //获取指纹失败
                //btnStart.Visible = true;
                this.pictureBox1.Image = global::ZkFingerDemo.Properties.Resources.business_user_delete;
                string str_who_are_you = "你是谁?";
                this.lblName.Text = str_who_are_you;
                Program.play_voice("请扫描你的指纹");
                break;
            }
        }
        private void ShowPerson()
        {
            string select_all = "select p.xh \"学号\", p.xm \"姓名\","
                                + " case(f.print) when '' then '未登记' else '已登记' end \"登记状态\" "
                                + ", pe.nj_name \"年级\", pe.bj_name \"班级\", pe.tel \"电话\", pe.email \"邮箱\" "
                                + " from person_info_min as p,person_finger_print as f ,person_expand_info as pe"
                                + " where p.xh=f.xh  and p.xh=pe.xh  order  by p.xh;";
            DataTable dt = CsharpSQLiteHelper.ExecuteTable(select_all, null);

            dataGridView1.DataSource = dt;

            int iNumberofStudents = dt.Rows.Count;

            this.groupBox2.Text = "学生列表 共有学生" + iNumberofStudents.ToString() + "名";

            this.dataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
            int headerW  = this.dataGridView1.RowHeadersWidth;
            int columnsW = 0;
            DataGridViewColumnCollection columns = this.dataGridView1.Columns;

            for (int i = 0; i < columns.Count; i++)
            {
                columnsW += columns[i].Width;
            }
            if (columnsW + headerW < this.dataGridView1.Width)
            {
                int leftTotalWidht       = this.dataGridView1.Width - columnsW - headerW;
                int eachColumnAddedWidth = leftTotalWidht / columns.Count;
                for (int i = 0; i < columns.Count; i++)
                {
                    columns[i].Width += eachColumnAddedWidth;
                }
            }
        }
Beispiel #4
0
        public static serialPortConfig getDefaultConfig()
        {
            serialPortConfig config    = null;
            string           port_name = string.Empty;
            string           baut_rate = string.Empty;
            string           sql       = "select vvalue from sys_config where vkey = '{0}'";
            DataTable        dt_temp   = CsharpSQLiteHelper.ExecuteTable(sql, new object[1] {
                "port_name"
            });

            if (dt_temp.Rows.Count > 0)
            {
                port_name = dt_temp.Rows[0]["vvalue"].ToString();
            }
            sql     = "select vvalue from sys_config where vkey = '{0}'";
            dt_temp = CsharpSQLiteHelper.ExecuteTable(sql, new object[1] {
                "baut_rate"
            });
            if (dt_temp.Rows.Count > 0)
            {
                baut_rate = dt_temp.Rows[0]["vvalue"].ToString();
            }
            config = new serialPortConfig(port_name, baut_rate);

            return(config);
        }
        void HistoryCheckRecord_Shown(object sender, EventArgs e)
        {
            string    select = "SELECT record_id \"编号\",info \"备注\",create_time \"创建时间\" FROM check_record_info order by create_time desc;";
            DataTable dt     = CsharpSQLiteHelper.ExecuteTable(select, null);

            this.dataGridView1.DataSource = dt;

            this.format_dgv(this.dataGridView1);
        }
        public void set_fp_string(string tmp)
        {
            string insert_fp = string.Format("replace into person_finger_print(xh,print) values('{0}','{1}');", current_user_id, tmp);
            int    r         = CsharpSQLiteHelper.ExecuteNonQuery(insert_fp, null);

            if (r > 0)
            {
                this.ShowPerson();
                MessageBox.Show("指纹登记成功!", "提示");
            }
        }
Beispiel #7
0
        public static void saveConfig(serialPortConfig config)
        {
            string sql = "insert into sys_config(vkey,vvalue) values('{0}','{1}')";
            int    rtn = 0;

            rtn = CsharpSQLiteHelper.ExecuteNonQuery(sql, new object[2] {
                "port_name", config.portName
            });
            if (rtn <= 0)
            {
                return;
            }
            rtn = 0;
            rtn = CsharpSQLiteHelper.ExecuteNonQuery(sql, new object[2] {
                "baut_rate", config.baudRate
            });
            //if (rtn <= 0)
            //{
            //    return;
            //}
            //// accessDb4o
            //IObjectContainer db = Db4oFactory.OpenFile(serialPortConfig.configFilePath);
            //try
            //{
            //    IList<serialPortConfig> list = db.Query<serialPortConfig>(delegate(serialPortConfig cf)
            //    {
            //        return cf.configName == config.configName;
            //    }
            //                                              );
            //    if (list.Count <= 0)
            //    {
            //        db.Store(config);
            //    }
            //    else
            //    {
            //        serialPortConfig.copy(config, list[0]);
            //        db.Store(list[0]);
            //    }

            //}
            //finally
            //{
            //    db.Close();
            //}
        }
Beispiel #8
0
        public static serialPortConfig getDefaultConfig()
        {
            serialPortConfig config    = null;
            string           port_name = string.Empty;
            string           baut_rate = string.Empty;
            string           sql       = "select vvalue from sys_config where vkey = '{0}'";
            DataTable        dt_temp   = CsharpSQLiteHelper.ExecuteTable(sql, new object[1] {
                "port_name"
            });

            if (dt_temp.Rows.Count > 0)
            {
                port_name = dt_temp.Rows[0]["vvalue"].ToString();
            }
            sql     = "select vvalue from sys_config where vkey = '{0}'";
            dt_temp = CsharpSQLiteHelper.ExecuteTable(sql, new object[1] {
                "baut_rate"
            });
            if (dt_temp.Rows.Count > 0)
            {
                baut_rate = dt_temp.Rows[0]["vvalue"].ToString();
            }
            config = new serialPortConfig(port_name, baut_rate);
            //IObjectContainer db = Db4oFactory.OpenFile(serialPortConfig.configFilePath);
            //try
            //{
            //    IList<serialPortConfig> list = db.Query<serialPortConfig>(delegate(serialPortConfig cf)
            //    {
            //        return cf.configName == "default";
            //    }
            //                                              );
            //    if (list.Count > 0)
            //    {
            //        config = list[0];
            //    }

            //}
            //finally
            //{
            //    db.Close();
            //}
            return(config);
        }
Beispiel #9
0
        void frmUserIdentify_Shown(object sender, EventArgs e)
        {
            if (Program.g_zkfp_handle != -1)
            {
                Program.g_ZKFP.FreeFPCacheDB(Program.g_zkfp_handle);
                Program.g_zkfp_handle = -1;
            }
            Program.g_zkfp_handle = Program.g_ZKFP.CreateFPCacheDB();
            //加入保存的指纹模板
            index = 0;

            //List<object> keys = nsConfigDB.ConfigDB.getKeys();
            //foreach (object key in keys)
            //{
            //    string tmp = (string)nsConfigDB.ConfigDB.getConfig((string)key);
            //    index++;
            //    Program.g_ZKFP.AddRegTemplateStrToFPCacheDB(Program.g_zkfp_handle, index, tmp);
            //    index_user_list.Add(index, (string)key);
            //}

            string select_all = "select p.xh, p.xm,"
                                + " f.print "
                                + ", pe.nj \"年级\", pe.bj \"班级\", pe.tel \"电话\", pe.email \"邮箱\" "
                                + " from person_info_min as p,person_finger_print as f ,person_expand_info as pe"
                                + " where p.xh=f.xh  and p.xh=pe.xh  order  by p.xh;";

            this.person_list = CsharpSQLiteHelper.ExecuteTable(select_all, null);
            foreach (DataRow dr in this.person_list.Rows)
            {
                string id = dr["xh"].ToString();

                string tmp = dr["print"].ToString();
                index++;
                Program.g_ZKFP.AddRegTemplateStrToFPCacheDB(Program.g_zkfp_handle, index, tmp);
                index_user_list.Add(index, id);
            }
            this.refresh_check_list();

            //开始1:N识别

            Program.g_ZKFP.SetAutoIdentifyPara(true, Program.g_zkfp_handle, 8);
            this.matrixCircularProgressControl1.Start();
        }
Beispiel #10
0
        void refresh_check_list()
        {
            // 初始化待考勤人员列表
            string select_not_checked = "select p.xh \"学号\", p.xm \"姓名\" "
                                        + "from person_info_min as p  where p.xh not in(select xh from CheckRecords where record_id = '{0}');";
            DataTable dt_not_checked = CsharpSQLiteHelper.ExecuteTable(select_not_checked, new object[] { this.unique_check_id });

            this.dgvNotChecked.DataSource = dt_not_checked;
            this.gbNotChecked.Text        = string.Format("待考勤共{0}人", dt_not_checked.Rows.Count.ToString());
            //初始化已考勤人员
            string select_checked = "select p.xh \"学号\", p.xm \"姓名\" "
                                    + "from person_info_min as p  where p.xh in(select xh from CheckRecords where record_id = '{0}');";
            DataTable dt_checked = CsharpSQLiteHelper.ExecuteTable(select_checked, new object[] { this.unique_check_id });

            this.dgvChecked.DataSource = dt_checked;
            this.gbChecked.Text        = string.Format("已考勤共{0}人", dt_checked.Rows.Count.ToString());

            this.format_dgv(this.dgvChecked);
            this.format_dgv(this.dgvNotChecked);
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            string            message = "确定要删除学号为【" + txtId.Text + "】的学生记录吗?";
            string            caption = "删除确认";
            MessageBoxButtons buttons = MessageBoxButtons.YesNo;
            DialogResult      result;

            // Displays the MessageBox.
            result = MessageBox.Show(message, caption, buttons);

            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                string strID = txtId.Text;
                this.bRefreshParentForm = true;

                string delete_person = string.Format("delete from person_info_min where xh='{0}';"
                                                     + "delete from person_finger_print where xh='{0}';"
                                                     + "delete from person_expand_info where xh='{0}';", strID);
                int r = CsharpSQLiteHelper.ExecuteNonQuery(delete_person, null);
                //bDeleted = rfidCheck_CheckOn.PersonDelete(new Person(txtId.Text,
                //                                                    txtName.Text,
                //                                                    txtTel.Text,
                //                                                    txtMail.Text,
                //                                                    txtbj.Text,
                //                                                    txtnj.Text,
                //                                                    null));
                if (r > 0)
                {
                    ShowPerson();
                    SetLabelContent();
                    MessageBox.Show("学号" + txtId.Text +
                                    "已经删除!!");
                }
                else
                {
                    MessageBox.Show("数据删除时出现异常!", "异常提示");
                }
            }
        }
Beispiel #12
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string strID = txtId.Text;

            if (strID.Length < 0)
            {
                MessageBox.Show("请输入学号!");
                return;
            }
            //if (strID.Length < 0 || strID.Length > 6 || !Regex.IsMatch(strID, "[0-9]{6}"))
            //{
            //    MessageBox.Show("学号应为六位数字!");
            //    return;
            //}

            Func <string, bool> check_id_exists = id =>
            {
                string    select_id = "select xh from person_info_min where xh={0}";
                DataTable dt        = CsharpSQLiteHelper.ExecuteTable(select_id, new object[] { id });
                return(dt.Rows.Count > 0 ? true : false);
            };

            if (check_id_exists(strID))
            {
                MessageBox.Show
                    ("已存在学号为" + strID + "的学生!");
                return;
            }
            else
            {
                string name          = txtName.Text;
                string nj            = txtnj.Text;
                string bj            = txtbj.Text;
                string tel           = txtTel.Text;
                string email         = txtMail.Text;
                string insert_person = string.Format("insert into person_info_min values('{0}','{1}');", strID, name)
                                       + string.Format("insert into person_expand_info(xh,nj_name,bj_name,tel,email) values('{0}','{1}','{2}','{3}', '{4}');",
                                                       strID, nj, bj, tel, email)
                                       + string.Format("insert into person_finger_print values('{0}','');", strID);
                int r = CsharpSQLiteHelper.ExecuteNonQuery(insert_person, null);
                if (r > 0)
                {
                    MessageBox.Show("学号为" + txtId.Text +
                                    "的学生新增完成!");
                }
            }
            ShowPerson();
            SetLabelContent();

            //if (writeData)
            //{
            //    rfidCheck_CheckOn.PersonAdd(new Person(txtId.Text,
            //                                            txtName.Text,
            //                                            txtTel.Text,
            //                                            txtMail.Text,
            //                                            txtbj.Text,
            //                                            txtnj.Text,
            //                                            null));

            //    MessageBox.Show("学号为" + txtId.Text +
            //        "的学生新增完成!");

            //    this.bRefreshParentForm = true;
            //}
            //dataGridView1.DataSource = myDataSet.Tables["student"];
        }