Beispiel #1
0
        private void LoadData()
        {
            PersonnelBindingSource.DataSource    = PersonnelManagement.GetA(PersonnelNo);
            EducationObjBindingSource.DataSource = StaticClass.ListEducation(PersonnelNo);
            EligibilityBindingSource.DataSource  = EligibilityManagement.GetAll(PersonnelNo);
            ExperiencyBindingSource.DataSource   = ExperienceManagement.GetAll(PersonnelNo);
            VoluntaryBindingSource.DataSource    = VoluntaryManagement.GetAll(PersonnelNo);
            TrainingBindingSource.DataSource     = TrainingManagement.GetAll(PersonnelNo);
            SpousBindingSource.DataSource        = SpouseManagement.GetA(PersonnelNo);
            SkillBindingSource.DataSource        = SkillManagement.GetAll(PersonnelNo);
            OrganizationBindingSource.DataSource = OrganizationManagement.GetAll(PersonnelNo);
            DistinctionBindingSource.DataSource  = DistinctionManagement.GetAll(PersonnelNo);
            QuestionBindingSource.DataSource     = QuestionManagement.GetAll(PersonnelNo);
            ReferenceBindingSource.DataSource    = ReferencesManagement.GetAll(PersonnelNo);
            DetailBindingSource.DataSource       = Details.GetAll(PersonnelNo);

            if (SpousBindingSource?.Current == null)
            {
                return;
            }
            ChildrenObjBindingSource.DataSource = StaticClass.ListChildren(((Spous)SpousBindingSource.Current).SpouseNo);

            reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
            reportViewer1.ZoomMode    = ZoomMode.Percent;
            reportViewer1.ZoomPercent = 100;

            this.reportViewer1.RefreshReport();
        }
Beispiel #2
0
 private void personnelBindingNavigatorSaveItem_Click(object sender, EventArgs e)
 {
     if (personnelBindingSource != null)
     {
         Validate();
         if (pictureBox1.Image != null)
         {
             ((Personnel)personnelBindingSource.Current).Photo = UtilityClass.ImageToByte(pictureBox1.Image);
         }
         if (_b.EncodedImage != null)
         {
             ((Personnel)personnelBindingSource.Current).BarcodeImage = UtilityClass.ImageToByte(_b.EncodedImage);
         }
         personnelBindingSource.EndEdit();
         var iResult = PersonnelManagement.Save((Personnel)personnelBindingSource.Current);
         if (iResult > 0)
         {
             MessageBox.Show(@"Record was successfully saved.", @"Save", MessageBoxButtons.OK,
                             MessageBoxIcon.Information);
             cSIdNoTextBox.Focus();
         }
         else
         {
             MessageBox.Show(@"Error occurred in saving.", @"Save", MessageBoxButtons.OK,
                             MessageBoxIcon.Error);
         }
     }
 }
Beispiel #3
0
 private void toolStripButton1_Click(object sender, EventArgs e)
 {
     Cursor.Current = Cursors.WaitCursor;
     if (toolStripTextBox1.Text.Length > 0)
     {
         personnelBindingSource.DataSource = PersonnelManagement.GetAll(toolStripTextBox1.Text);
     }
     Cursor.Current = Cursors.Default;
 }
Beispiel #4
0
 private void buttonGo_Click(object sender, EventArgs e)
 {
     Cursor.Current = Cursors.WaitCursor;
     if (textBox1.Text.Length > 0)
     {
         Personnel = PersonnelManagement.GetA(textBox1.Text);
         if (Personnel != null)
         {
             PersonnelNo = Personnel.PersonnelNo;
             LoadData();
         }
         else
         {
             MessageBox.Show(@"Record not found. Please try again.", @"Search", MessageBoxButtons.OK,
                             MessageBoxIcon.Information);
             textBox1.Focus();
         }
     }
     Cursor.Current = Cursors.Default;
 }
Beispiel #5
0
        /// <summary>
        /// 断开选择的设备
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void 断开设备toolStripButton_Click(object sender, EventArgs e)
        {
            PersonnelManagement personnelManagement = new PersonnelManagement();

            PersonnelManagement.PersonInfo person = new PersonnelManagement.PersonInfo(5);
            Stm32Sync stm32_sync = new Stm32Sync();

            stm32_sync.output_dlg = output;
            MacAddr dst_addr;

            string addr_str = dgvDeviceInfo.SelectedRows[0].Cells[2].Value.ToString();

            dst_addr = new MacAddr(addr_str);

            /* 添加用户 */
            for (int i = 0; i < personnelManagement.PersonList.Count; i++)
            {
                stm32_sync.user_add(dst_addr.Mac, personnelManagement.PersonList[i]);
            }

            /* 删除用户 */
            //stm32_sync.user_del(dst_addr.Mac, (UInt32)1);

            /* 重新加载卡号-用户号,指纹号-用户号列表 */
            stm32_sync.list_reload(dst_addr.Mac);
            return;

            int rows = dgvDeviceInfo.SelectedRows.Count;//获取选中总行数

            for (int j = 0; j < rows; j++)
            {
                if (dgvDeviceInfo.SelectedRows[j].Cells[1].Value.ToString() == "未连接")
                {
                    output("设备" + dgvDeviceInfo.SelectedRows[j].Cells[0].Value.ToString() + "未连接");
                }
                else
                {
                    dgvDeviceInfo.SelectedRows[j].Cells[1].Value = "未连接";
                }
            }
        }
        public void CreateMemberBin()
        {
            Stm32_crc           stm32_crc           = new Stm32_crc();
            PersonnelManagement personnelManagement = new PersonnelManagement();

            PersonnelManagement.PersonInfo person = new PersonnelManagement.PersonInfo(5);
            string     path = Environment.CurrentDirectory + @"\dataBase\member.bin";
            FileStream fs   = new FileStream(path, FileMode.Create);
            UInt32     crc  = 0;

            /* 获取总人数 */
            ushort rowsCount = (ushort)personnelManagement.PersonList.Count;

            /* 获取最大用户号 */
            ushort user_num_max   = (ushort)personnelManagement.max_user_id_get();
            uint   one_user_lenth = USER_PACK_SIZE;

            byte[] data = new byte[8 + user_num_max * one_user_lenth];
            byte[] person_array;
            data[0] = (byte)(rowsCount & 0xff);
            data[1] = (byte)((rowsCount & 0xff00) >> 8);
            data[2] = (byte)(user_num_max & 0xff);
            data[3] = (byte)((user_num_max & 0xff00) >> 8);

            crc     = stm32_crc.block_crc_calc(data, 0, 4);
            data[4] = (byte)((crc & 0x000000FF) >> 0);
            data[5] = (byte)((crc & 0x0000FF00) >> 8);
            data[6] = (byte)((crc & 0x00FF0000) >> 16);
            data[7] = (byte)((crc & 0xFF000000) >> 24);

            for (ushort i = 0; i < rowsCount; i++)
            {
                person       = personnelManagement.PersonList[i];
                person_array = person_array_get(person);
                Buffer.BlockCopy(person_array, 0, data, (int)((person.uID - 1) * one_user_lenth + 8), person_array.Length);
            }
            fs.Write(data, 0, data.Length);
            fs.Flush();
            fs.Close();
        }
Beispiel #7
0
 private void DeletePersonnel()
 {
     if (personnelBindingSource != null)
     {
         var dResult = MessageBox.Show(@"Delete Personnel's current record?", @"Delete", MessageBoxButtons.YesNo,
                                       MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
         if (dResult == DialogResult.Yes)
         {
             if (PersonnelManagement.Delete(((Personnel)personnelBindingSource.Current).PersonnelNo))
             {
                 MessageBox.Show(@"Record was deleted successfully.", @"Delete", MessageBoxButtons.OK,
                                 MessageBoxIcon.Information);
                 personnelBindingSource.RemoveCurrent();
             }
             else
             {
                 MessageBox.Show(@"Error on delete operation.", @"Delete", MessageBoxButtons.OK,
                                 MessageBoxIcon.Error);
                 personnelDataGridView.Focus();
             }
         }
     }
 }
 public PersonnelService()
 {
     _personnelManagement = new PersonnelManagement();
 }
        /// <summary>
        /// 将指定人员的数据从数据库读取并显示,方便编辑人员信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void 编辑ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SchoolInfoInit();
            PersonnelManagement personnelManagement = new PersonnelManagement();
            int rowIndex = dgvPerson.CurrentRow.Index;     //获取选择行号

            tbUID.Text = dgvPerson.Rows[rowIndex].Cells[0].Value.ToString();
            uint uID   = (UInt32)Convert.ToInt32(tbUID.Text);
            int  index = personnelManagement.uIDtoIndex(uID);

            if (index < 0)
            {
                output("数据库中没有指定ID用户");
                return;
            }
            tbName.Text      = personnelManagement.PersonList[index].name;
            cbSex.Text       = personnelManagement.PersonList[index].sex;
            tbStudentID.Text = personnelManagement.PersonList[index].studentID;

            string domitory = personnelManagement.PersonList[index].dormitory;
            byte   one      = (byte)domitory.LastIndexOf(")");
            string Building = domitory.Substring(0, one + 1);
            string Floor    = domitory.Substring(one + 1, 1);

            tbDomitory.Text = domitory.Substring(one + 2, 3);

            if (cbBuilding.Items.Contains(Building))
            {
                cbBuilding.DropDownStyle = ComboBoxStyle.DropDownList;
                cbBuilding.Text          = Building;
            }
            else
            {
                cbBuilding.DropDownStyle = ComboBoxStyle.Simple;
                cbBuilding.Text          = Building;
            }

            if (cbFloor.Items.Contains(Floor))
            {
                cbFloor.DropDownStyle = ComboBoxStyle.DropDownList;
                cbFloor.Text          = Floor;
            }
            else
            {
                cbFloor.DropDownStyle = ComboBoxStyle.Simple;
                cbFloor.Text          = Floor;
            }

            cbActiveState.Checked = personnelManagement.PersonList[index].activeState == 0 ? false : true;

            string authority = personnelManagement.PersonList[index].authority;

            cbAuthority = CheckBoxComboBoxOP.checkItem(cbAuthority, authority);

            string major = personnelManagement.PersonList[index].major;

            one = (byte)major.LastIndexOf(" ");
            string Institute = major.Substring(0, one);
            string Major     = major.Substring(one + 1, major.Length - one - 1);

            if (cbInstitute.Items.Contains(Institute))
            {
                cbInstitute.DropDownStyle = ComboBoxStyle.DropDownList;
                cbInstitute.Text          = Institute;
            }
            else
            {
                cbInstitute.DropDownStyle = ComboBoxStyle.Simple;
                cbInstitute.Text          = Institute;
            }

            if (cbMajor.Items.Contains(Major))
            {
                cbMajor.DropDownStyle = ComboBoxStyle.DropDownList;
                cbMajor.Text          = Major;
            }
            else
            {
                cbMajor.DropDownStyle = ComboBoxStyle.Simple;
                cbMajor.Text          = Major;
            }

            //cbInstitute.Text = major.Substring(0, one);
            //cbMajor.Text = major.Substring(one + 1, major.Length - one - 1);

            tbQQ.Text             = personnelManagement.PersonList[index].QQ;
            tbWeiXin.Text         = personnelManagement.PersonList[index].weiXin;
            tbTel.Text            = personnelManagement.PersonList[index].tel;
            dtpBirthday.Value     = DateTime.Parse(personnelManagement.PersonList[index].birthday);
            cbIsLimitTime.Checked = personnelManagement.PersonList[index].isLimitTime == 0 ? false : true;
            dtpLimitTime.Value    = DateTime.Parse(personnelManagement.PersonList[index].limitTime);

            tbRFID.Text   = personnelManagement.PersonList[index].cardID.ToString("X8");;
            tbEigen1.Text = personnelManagement.PersonList[index].eigen[0];
            tbEigen2.Text = personnelManagement.PersonList[index].eigen[1];
            tbEigen3.Text = personnelManagement.PersonList[index].eigen[2];
            tbEigen4.Text = personnelManagement.PersonList[index].eigen[3];
            tbEigen5.Text = personnelManagement.PersonList[index].eigen[4];
            fPath         = Environment.CurrentDirectory + @"\picture\" + tbUID.Text.PadLeft(4, '0') + "_" + tbName.Text + ".jpg";
            try
            {
                if (File.Exists(fPath) != true)
                {
                    output("头像不存在!"); pbPortrait.Image = null; return;
                }
                pbPortrait.Image = Image.FromFile(Environment.CurrentDirectory + @"\picture\" + tbUID.Text.PadLeft(4, '0') + "_" + tbName.Text + ".jpg");
                output("读取信息成功!");
            }
            catch (Exception ex)
            {
                output(ex.Message);
            }
        }
Beispiel #10
0
        /// <summary>
        /// 同步所有已连接设备的用户信息
        /// </summary>
        private void SyncUser()
        {
            output("同步用户信息");
            DeviceManagement    deviceManagement    = new DeviceManagement();
            PersonnelManagement personnelManagement = new PersonnelManagement();

            PersonnelManagement.PersonInfo person = new PersonnelManagement.PersonInfo(5);
            Stm32Sync stm32_sync = new Stm32Sync();
            Stm32_crc stm32_crc  = new Stm32_crc();
            UInt32    crc        = 0;
            MacAddr   dst_addr;
            UInt16    total;
            UInt16    count;
            UInt16    total_get = 0;

            byte[]   user_crc_byte;
            UInt32[] user_crc  = new UInt32[0];
            bool     err       = true;
            bool     is_change = false;

            stm32_sync.output_dlg = output;

            int row      = dgvDeviceInfo.SelectedRows.Count; /* 获取选中总行数 */
            int rowIndex = dgvDeviceInfo.CurrentRow.Index;   /* 获取选择行号 */

            for (int j = 0; j < row; j++)
            {
                if (dgvDeviceInfo.SelectedRows[j].Cells[1].Value.ToString() == "已连接")
                {
                    string addr_str = dgvDeviceInfo.SelectedRows[j].Cells[2].Value.ToString();
                    dst_addr = new MacAddr(addr_str);

                    /* 首先获取设备内所有用户信息的crc */
                    while (true)
                    {
                        /* 获取用户crc */
                        if (stm32_sync.user_crc_get(dst_addr.Mac, (UInt16)(total_get + 1), (UInt16)200, out total, out count, out user_crc_byte) != true)
                        {
                            err = false;
                            break;
                        }

                        if (total_get == 0)
                        {
                            user_crc = new UInt32[total];
                        }

                        for (int i = 0; i < count; i++)
                        {
                            crc = (UInt32)((user_crc_byte[i * 4 + 0] << 0) +
                                           (user_crc_byte[i * 4 + 1] << 8) +
                                           (user_crc_byte[i * 4 + 2] << 16) +
                                           (user_crc_byte[i * 4 + 3] << 24));
                            user_crc[i + total_get] = crc;
                        }

                        total_get += count;

                        if (total_get == total)
                        {
                            output("已获取完成所有用户crc");
                            err = true;
                            break;
                        }
                    }
                    if (err == false)
                    {
                        output("crc获取错误");
                        continue;
                    }

                    /* 同步用户信息 */
                    for (UInt32 uID = 1; uID <= user_crc.Length; uID++)
                    {
                        /* 获取用户信息 */
                        person = personnelManagement.user_get(uID);

                        /* 用户不存在上位机,删除用户 */
                        if ((person.uID != uID) && (user_crc[uID - 1] != 0))
                        {
                            is_change = true;
                            if (stm32_sync.user_del(dst_addr.Mac, uID) == false)
                            {
                                output("删除" + uID.ToString() + "号用户失败");
                                err = false;
                                break;
                            }
                            continue;
                        }

                        if (person.uID != 0)
                        {
                            /* 计算用户crc */
                            crc = stm32_sync.user_crc_calc(person);

                            /* crc不同,证明用户信息改变,添加用户 */
                            if (crc != user_crc[uID - 1])
                            {
                                is_change = true;
                                if (stm32_sync.user_add(dst_addr.Mac, person) == false)
                                {
                                    output("添加" + uID.ToString() + "号用户失败");
                                    err = false;
                                    break;
                                }
                            }
                        }
                    }

                    UInt32 user_id_max_device = (UInt32)user_crc.Length;
                    UInt32 user_id_max_db     = personnelManagement.max_user_id_get();
                    if (user_id_max_device < user_id_max_db)
                    {
                        for (UInt32 uID = (UInt32)(user_id_max_device + 1); uID <= user_id_max_db; uID++)
                        {
                            /* 获取用户信息 */
                            person = personnelManagement.user_get(uID);

                            if (person.uID == uID)
                            {
                                is_change = true;
                                if (stm32_sync.user_add(dst_addr.Mac, person) == false)
                                {
                                    output("添加" + uID.ToString() + "号用户失败");
                                    err = false;
                                }
                            }
                        }
                    }

                    if (is_change == true)
                    {
                        /* 重新加载卡号-用户号,指纹号-用户号列表 */
                        stm32_sync.list_reload(dst_addr.Mac);
                    }

                    if (err == false)
                    {
                        output("同步用户信息出错");
                        continue;
                    }
                    else
                    {
                        output("同步用户信息成功");
                    }
                }
            }

            is_child_thread_stop = 0;
        }
Beispiel #11
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Stm32Sync           stm32_sync          = new Stm32Sync();
            PersonnelManagement personnelManagement = new PersonnelManagement();

            PersonnelManagement.PersonInfo person = new PersonnelManagement.PersonInfo(5);
            MacAddr mac = new MacAddr();

            //stm32_sync.user_add(mac.Mac, personnelManagement.PersonList[2]);
            //byte[] name1 = {0x30, 0x5f, 0xd5, 0xc5, 0xbd, 0xf8, 0xbf,
            //                0xc6, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0x33,
            //                0x20, 0x31, 0x33, 0x30, 0x37, 0x35, 0x35,
            //                0x37, 0x34, 0x30, 0x33, 0x36, 0x20, 0x30,
            //                0x20, 0x30, 0x20, 0x31, 0x20, 0x33};
            //string name_str1 = Encoding.Default.GetString(name1);
            //byte[] name = Encoding.Default.GetBytes(name_str1);

            //AttendanceInfo attendanceInfo = new AttendanceInfo();
            //AttendanceInfo.AttInfo attInfo = new AttendanceInfo.AttInfo();

            //attInfo.deviceID = 4;                     /* 设备ID */
            //attInfo.deviceName = "411";               /* 设备名称 */
            //attInfo.mac = "00:00:00:00:00:04";        /* 设备mac地址 */
            //attInfo.infoID = 0;                       /* 记录ID 可重复,只作为参考 */
            //attInfo.uID = 1;                          /* 用户号 */
            //attInfo.studentID = "11307030328";        /* 学号 */
            //attInfo.name = "张进科";                  /* 姓名 */
            //attInfo.state = (char)1;                  /* 状态 0:出门 1:进门 */
            //attInfo.time = "2017年03月18日 22:34:59"; /* 时间 */
            //attendanceInfo.AddInfo(attInfo);
            //attendanceInfo.DelInfo(attInfo);


            //PersonnelManagement personnelManagement = new PersonnelManagement();
            //PersonnelManagement.PersonInfo person = new PersonnelManagement.PersonInfo(5);

            //person.uID         = 0;
            //person.cardID      = 0xFFFFFFFF;
            //person.activeState = 0;
            //person.studentID   = "11307030328";
            //person.dormitory   = "柏轩 B414";
            //person.major       = "机械工程学院 测控技术与仪器";
            //person.name        = "张进科";
            //person.sex         = "男";
            //person.birthday    = "1995年02月23日";
            //person.tel         = "15825941073";
            //person.QQ          = "799658861";
            //person.weiXin      = "zhangjinke0220";
            //person.authority   = "authority";
            //person.isLimitTime = 0;
            //person.limitTime   = "2099年12月31日23时59分59秒";
            //person.eigenNum[0] = 0;
            //person.eigenNum[1] = 1;
            //person.eigenNum[2] = 2;
            //person.eigenNum[3] = 3;
            //person.eigenNum[4] = 4;
            //person.eigen[0]    = "eigen0";
            //person.eigen[1]    = "eigen1";
            //person.eigen[2]    = "eigen2";
            //person.eigen[3]    = "eigen3";
            //person.eigen[4]    = "eigen4";
            //person.recodeDate = "2017年2月3日17时49分26秒";
            //person.resv0       = 0;
            //person.resv1       = 0;
            //person.resv2       = "";
            //person.resv3       = "";
            //person.resv4       = "";
            //personnelManagement.AddPerson(person);
            //personnelManagement.DelPerson(person);

            //school_info_init();

            Control.CheckForIllegalCrossThreadCalls = false;        //不检查跨线程的调用是否合法(不好的解决方案)
            if (!Directory.Exists(Environment.CurrentDirectory + @"\dataBase"))
            {
                Directory.CreateDirectory(Environment.CurrentDirectory + @"\dataBase");//目录不存在,建立目录
            }
            if (!Directory.Exists(Environment.CurrentDirectory + @"\picture"))
            {
                Directory.CreateDirectory(Environment.CurrentDirectory + @"\picture");//目录不存在,建立目录
            }

            DeviceManagement deviceManagement = new DeviceManagement();

            dgvDeviceInfo.Rows.Clear();                    /* 清空表格 */
            deviceManagement = new DeviceManagement();
            int count = deviceManagement.DeviceList.Count; /* 设备数量 */

            for (int idx = 0; idx < count; idx++)          /* 将设备添加到表格中 */
            {
                int index = dgvDeviceInfo.Rows.Add();
                dgvDeviceInfo.Rows[index].Cells[0].Value = deviceManagement.DeviceList[idx].name; /* 设备名称 */
                dgvDeviceInfo.Rows[index].Cells[1].Value = "未连接";                                 /* 状态 */
                dgvDeviceInfo.Rows[index].Cells[2].Value = deviceManagement.DeviceList[idx].mac;  /* mac地址 */
                dgvDeviceInfo.Rows[index].Cells[3].Value = "";                                    /* 人员数 */
            }
        }