public PersonInfoDialog(PersonBasicInfo basicinfo, bool isReadOnly)
        {
            InitializeComponent();


            IsReadOnly = isReadOnly;

            PersonModel model = new PersonModel();

            info = model.GetPersonBasicInfos("", basicinfo.NAMEID, "")[0];
            //info = basicinfo;

            this.grid_main.DataContext = info;

            if (IsReadOnly == true)
            {
                this.grid_detail.IsEnabled = false;
                this.btnSave.IsEnabled     = false;
                this.btnCancel.IsEnabled   = false;
            }
            else
            {
                IsModify = true;
            }
        }
        private void DefaultStage(DetectResult detectResult)
        {
            if (detectResult.face.Count == 1)
            {
                VerifyResult person = fs.Recognition_VerifyByName(detectResult.face[0].face_id, userName.Text);
                status.Content = "Hello " + userName.Text + ", What would you like to do?";

                if (person == null)
                {
                    PersonBasicInfo info = fs.Person_Create(userName.Text, detectResult.face[0].face_id);
                    AsyncResult     a    = fs.Train_VerifyById(info.person_id);
                }
                else
                {
                    if (!person.is_same_person)
                    {
                        status.Content = "NO! You are not " + userName.Text;
                    }
                    else
                    {
                        lockFile.IsEnabled   = true;
                        UnlockFile.IsEnabled = true;
                        Increase.IsEnabled   = true;
                    }
                }
            }
            else
            {
                status.Content = "No face detected";
            }
        }
        public ActionResult PersonMoreInfo(PersonMoreInfo personData, string previousBtn, string nextBtn)
        {
            Person obj = GetPerson();

            if (previousBtn != null)
            {
                PersonBasicInfo pBasicInfo = new PersonBasicInfo();
                pBasicInfo.FirstName = obj.FirstName;
                pBasicInfo.LastName  = obj.LastName;
                return(PartialView("PersonBasicInfo", pBasicInfo));
            }

            if (nextBtn != null)
            {
                if (ModelState.IsValid)
                {
                    obj.street     = personData.street;
                    obj.city       = personData.city;
                    obj.state      = personData.state;
                    obj.country    = personData.country;
                    obj.postalcode = personData.postalcode;
                    obj.phone      = personData.phone;
                    return(PartialView("PersonInfo", obj));
                }
            }
            return(PartialView());
        }
        /// <summary>
        /// 插入人员信息
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>

        public bool InsertPersonBasicInfo(PersonBasicInfo info)
        {
            bool isresult = false;

            if (info.PHOTO != null && info.PHOTO.Length > 0)
            {
                info.PHOTO = ImageHelper.YaSuo(info.PHOTO);

                ////保存图片
                //string filename = AppDomain.CurrentDomain.BaseDirectory + "\\Images\\" + info.NAMEID;
                //string fileFullname = ImageHelper.CreateImageFromBytes(filename, info.PHOTO);

                //string md5Code = ImageHelper.GetMD5HashFromByte(info.PHOTO);

                //info.A1 = md5Code;

                //info.A2 = fileFullname.Replace(AppDomain.CurrentDomain.BaseDirectory,"");
            }



            using (OleDbConnection connection = new OleDbConnection(DbHelperACE.connectionString))
            {
                OleDbCommand command = new OleDbCommand();
                command.Connection  = connection;
                command.CommandText = @"Insert INTO PersonBasicInfo (NAMEID,NAME,SEX,BIRTHDATE,NATION,ENLISTMENTDATE,MILITARYRANK,ORIGINPLACE,ARMYSEAT,MAJOR,EDUCATION,POLITICAL,PARTYTIME,HJQK,BLOODTYPE,IDCARD,HOBBY,CHARACTERTYPE,QQID,HOMEADDRESS,PHONE,SPOUSENAME,SPOUSEMARRIAGETIME,SPOUSESUNIT,SPOUSESHOMEADDRESS,SPOUSESPHONE,CHILDRENNAME,CHILDRENSEX,CHILDRENBIRTH,ENLISTINGRESUME,TRAININGSITUATION,REWARDSPUNISHMENTS,FAMILYMEMBER,A1,A2,A3 ,PHOTO) values ('" + info.NAMEID + "','" + info.NAME + "','" + info.SEX + "','" + info.BIRTHDATE + "','" + info.NATION + "','" + info.ENLISTMENTDATE + "','" + info.MILITARYRANK + "','" + info.ORIGINPLACE + "','" + info.ARMYSEAT + "','" + info.MAJOR + "','" + info.EDUCATION + "','" + info.POLITICAL + "','" + info.PARTYTIME + "','" + info.HJQK + "','" + info.BLOODTYPE + "','" + info.IDCARD + "','" + info.HOBBY + "','" + info.CHARACTERTYPE + "','" + info.QQID + "','" + info.HOMEADDRESS + "','" + info.PHONE + "','" + info.SPOUSENAME + "','" + info.SPOUSEMARRIAGETIME + "','" + info.SPOUSESUNIT + "','" + info.SPOUSESHOMEADDRESS + "','" + info.SPOUSESPHONE + "','" + info.CHILDRENNAME + "','" + info.CHILDRENSEX + "','" + info.CHILDRENBIRTH + "','" + info.ENLISTINGRESUME + "','" + info.TRAININGSITUATION + "','" + info.REWARDSPUNISHMENTS + "','" + info.FAMILYMEMBER + "','" + info.A1 + "','" + info.A2 + "','" + info.A3 + "' , @photo1)";
                command.CommandType = CommandType.Text;
                OleDbParameter imageType = new OleDbParameter("@photo1", OleDbType.VarBinary);
                imageType.Value = info.PHOTO;
                command.Parameters.Add(imageType).Value = info.PHOTO;



                try
                {
                    connection.Open();
                    int rows = command.ExecuteNonQuery();
                    isresult = true;
                }
                catch (System.Data.OleDb.OleDbException E)
                {
                    throw new Exception(E.Message);
                }
                finally
                {
                    command.Dispose();
                    connection.Close();
                }
            }

            return(isresult);
        }
 public ActionResult PersonBasicInfo(PersonBasicInfo personData, string nextBtn)
 {
     if (nextBtn != null)
     {
         if (ModelState.IsValid)
         {
             Person obj = GetPerson();
             obj.FirstName = personData.FirstName;
             obj.LastName  = personData.LastName;
             return(PartialView("PersonMoreInfo"));
         }
     }
     return(PartialView());
 }
        private void GroupBox_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            var groupBox = (DevExpress.Xpf.LayoutControl.GroupBox)sender;

            groupBox.State = groupBox.State == GroupBoxState.Normal ? GroupBoxState.Maximized : GroupBoxState.Normal;


            if (groupBox.State == GroupBoxState.Maximized)
            {
                PersonBasicInfo binfo = groupBox.DataContext as PersonBasicInfo;

                string eventList = InitGreatEventData(binfo.NAMEID);

                binfo.GREATEVENT = eventList;
            }
        }
Exemple #7
0
        public void dataGridTemplate_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                DataGridRow dgr = DataGridRow.GetRowContainingElement(e.OriginalSource as FrameworkElement);
                if (dgr != null)
                {
                    PersonBasicInfo personBasicInfo = dgr.DataContext as PersonBasicInfo;
                    if (personBasicInfo != null)
                    {
                        PersonInfoDialog dialog = new PlanDatabase.PersonInfoDialog(personBasicInfo, true);

                        dialog.Show();
                    }
                }
            }
        }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            PersonBasicInfo bi = this.cb_PersonList.SelectedItem as PersonBasicInfo;

            info.NAMEID = bi.NAMEID;
            info.NAME   = bi.NAME;


            CodeDicItem cdI = this.cb_type.SelectedItem as CodeDicItem;

            info.INCIDENT = cdI.CODE;



            PersonRewardPunishInfoModel model = new PersonRewardPunishInfoModel();

            bool isresult = false;

            if (IsModify == false)
            {
                isresult = model.InsertPersonRewardPunishInfo(info);
            }
            else
            {
                isresult = model.ModifyPersonRewardPunishInfo(info);
            }
            if (isresult)
            {
                MessageBox.Show("保存人员量化考核信息成功!");

                this.Close();
            }
            else
            {
                MessageBox.Show("保存人员量化考核信息失败 请确认后再进行保存!");
            }
        }
        private static void GetPersonPic(object obj)
        {
            PersonBasicInfo fpb = obj as PersonBasicInfo;

            if (string.IsNullOrEmpty(fpb.A2) == false && File.Exists(AppDomain.CurrentDomain.BaseDirectory + fpb.A2) == true)
            {
                string md5code = DataManager.Public.ImageHelper.GetMD5HashFromFile(AppDomain.CurrentDomain.BaseDirectory + fpb.A2);

                if (md5code.Equals(fpb.A1))
                {
                    fpb.PHOTO = DataManager.Public.ImageHelper.BitmapToBytes(new System.Drawing.Bitmap(AppDomain.CurrentDomain.BaseDirectory + fpb.A2));
                }
            }
            else
            {
                PersonModel model = new PersonModel();

                fpb = model.GetPersonBasicInfos("", fpb.NAMEID, "")[0];


                //fpb.PHOTO = DataManager.Public.ImageHelper.YaSuo(fpb.PHOTO);

                ////保存图片
                //string filename = AppDomain.CurrentDomain.BaseDirectory + "\\Images\\" + fpb.NAMEID;
                //string fileFullname = DataManager.Public.ImageHelper.CreateImageFromBytes(filename, fpb.PHOTO);

                //string md5Code = DataManager.Public.ImageHelper.GetMD5HashFromByte(fpb.PHOTO);

                //fpb.A1 = md5Code;

                //fpb.A2 = fileFullname.Replace(AppDomain.CurrentDomain.BaseDirectory, "");


                //model.ModifyPersonBasicInfo(fpb);
            }
        }
Exemple #10
0
        private void buttonReadLib_Click(object sender, EventArgs e)
        {
            textBoxOutput.Clear();
            textBoxOutput.AppendText("请稍等。" + Environment.NewLine);

            fs.Group_DeleteByName(Env.GroupName);
            GroupBasicInfo tempGroupBasicInfo = fs.Group_CreateByIdList(Env.GroupName);
            string         libPath            = System.Environment.CurrentDirectory + Path.DirectorySeparatorChar + Env.libFolder + Path.DirectorySeparatorChar;

            if (!Directory.Exists(libPath))
            {
                MessageBox.Show("没有找到数据库 !", "错误");
                return;
            }
            string[] folders = Directory.GetFileSystemEntries(libPath);
            TrainCount = 0;

            //Every name in folder
            foreach (string singleFolder in folders)
            {
                TrainCount++;
                string[] spiltString = new string[1]
                {
                    Path.DirectorySeparatorChar.ToString()
                };
                string[] items = singleFolder.Split(spiltString, StringSplitOptions.RemoveEmptyEntries);
                string   Name  = items[items.Count() - 1];
                fs.Person_DeleteByName(Name);
                PersonBasicInfo tempPersonBasicInfo = fs.Person_Create(Name);
                long            i         = 0;
                bool            faceExist = false;
                while (File.Exists(libPath + Name + Path.DirectorySeparatorChar + i.ToString() + Env.libExtName))
                {
                    faceExist = true;
                    DetectResult res = fs.Detection_DetectImg(libPath + Name + Path.DirectorySeparatorChar + i.ToString() + Env.libExtName);
                    if (res.face.Count != 1)
                    {
                        MessageBox.Show("路径" + libPath + Name + Path.DirectorySeparatorChar + i.ToString() + Env.libExtName + "中不存在人脸!已经自动删除", "警告");
                        File.Delete(libPath + Name + Path.DirectorySeparatorChar + i.ToString() + Env.libExtName);
                        buttonReadLib_Click(sender, e);
                        return;
                    }
                    ManageResult AddFaceResult = fs.Person_AddFaceById(tempPersonBasicInfo.person_id, res.face[0].face_id);
                    if (!AddFaceResult.success)
                    {
                        MessageBox.Show("为用户添加脸部信息失败!", "错误");
                        return;
                    }
                    i++;
                }
                if (!faceExist)
                {
                    MessageBox.Show(Name + "中没有脸部数据!", "警告");
                    continue;
                }
                ManageResult tempAddPersonResult = fs.Group_AddPerson("", Env.GroupName, "", Name);
                if (!tempAddPersonResult.success)
                {
                    MessageBox.Show("添加用户信息失败!", "错误");
                    return;
                }
                AsyncResult tempAsyncResult            = fs.Train_VerifyByName(Name);
                ParameterizedThreadStart CheckFinished = new ParameterizedThreadStart(ProcessCheckAsyncVerifyByName);
                Thread CheckFinishedProcess            = new Thread(CheckFinished);
                CheckFinishedProcess.IsBackground = true;
                string[] arguementStrings = new string[] { tempAsyncResult.session_id, Name };
                CheckFinishedProcess.Start(arguementStrings);
            }


            MessageBox.Show("数据库建立完成!请等待为每一个人的人脸学习过程完成。", "信息");
        }
        /// <summary>
        /// 获取 所有人员
        /// </summary>
        /// <param name="militaryrank">军衔</param>
        /// <param name="nameid">名称id</param>
        /// <param name="orderstr">排序</param>
        /// <returns>所有人员信息</returns>
        public List <PersonBasicInfo> GetPersonBasicInfos(string militaryrank, string nameid, string orderstr, bool isShowPic = true)
        {
            if (!string.IsNullOrEmpty(militaryrank))
            {
                SelectPersonInfoListSql += "and  MILITARYRANK = '" + militaryrank + "'  ";
            }


            if (!string.IsNullOrEmpty(nameid))
            {
                SelectPersonInfoListSql += "and  NAMEID = '" + nameid + "'  ";
            }



            if (!string.IsNullOrEmpty(orderstr))
            {
                SelectPersonInfoListSql += orderstr;
            }
            else
            {
                SelectPersonInfoListSql += " order by MILITARYRANK,POLITICAL";
            }


            DataSet ds = DbHelperACE.Query(SelectPersonInfoListSql);

            List <PersonBasicInfo> list = new List <PersonBasicInfo>();
            DataRowCollection      drs  = ds.Tables[0].Rows;

            for (int i = 0; i < drs.Count; i++)
            {
                PersonBasicInfo item = new PersonBasicInfo();


                item.NAMEID             = drs[i]["NAMEID"].ToString().Trim();
                item.NAME               = drs[i]["NAME"].ToString().Trim();
                item.SEX                = drs[i]["SEX"].ToString().Trim();
                item.BIRTHDATE          = drs[i]["BIRTHDATE"].ToString().Trim();
                item.NATION             = drs[i]["NATION"].ToString().Trim();
                item.ENLISTMENTDATE     = drs[i]["ENLISTMENTDATE"].ToString().Trim();
                item.MILITARYRANK       = drs[i]["MILITARYRANK"].ToString().Trim();
                item.ORIGINPLACE        = drs[i]["ORIGINPLACE"].ToString().Trim();
                item.ARMYSEAT           = drs[i]["ARMYSEAT"].ToString().Trim();
                item.MAJOR              = drs[i]["MAJOR"].ToString().Trim();
                item.EDUCATION          = drs[i]["EDUCATION"].ToString().Trim();
                item.POLITICAL          = drs[i]["POLITICAL"].ToString().Trim();
                item.PARTYTIME          = drs[i]["PARTYTIME"].ToString().Trim();
                item.HJQK               = drs[i]["HJQK"].ToString().Trim();
                item.BLOODTYPE          = drs[i]["BLOODTYPE"].ToString().Trim();
                item.IDCARD             = drs[i]["IDCARD"].ToString().Trim();
                item.HOBBY              = drs[i]["HOBBY"].ToString().Trim();
                item.CHARACTERTYPE      = drs[i]["CHARACTERTYPE"].ToString().Trim();
                item.QQID               = drs[i]["QQID"].ToString().Trim();
                item.HOMEADDRESS        = drs[i]["HOMEADDRESS"].ToString().Trim();
                item.PHONE              = drs[i]["PHONE"].ToString().Trim();
                item.SPOUSENAME         = drs[i]["SPOUSENAME"].ToString().Trim();
                item.SPOUSEMARRIAGETIME = drs[i]["SPOUSEMARRIAGETIME"].ToString().Trim();
                item.SPOUSESUNIT        = drs[i]["SPOUSESUNIT"].ToString().Trim();
                item.SPOUSESHOMEADDRESS = drs[i]["SPOUSESHOMEADDRESS"].ToString().Trim();
                item.SPOUSESPHONE       = drs[i]["SPOUSESPHONE"].ToString().Trim();
                item.CHILDRENNAME       = drs[i]["CHILDRENNAME"].ToString().Trim();
                item.CHILDRENSEX        = drs[i]["CHILDRENSEX"].ToString().Trim();
                item.CHILDRENBIRTH      = drs[i]["CHILDRENBIRTH"].ToString().Trim();
                item.ENLISTINGRESUME    = drs[i]["ENLISTINGRESUME"].ToString().Trim();
                item.TRAININGSITUATION  = drs[i]["TRAININGSITUATION"].ToString().Trim();
                item.REWARDSPUNISHMENTS = drs[i]["REWARDSPUNISHMENTS"].ToString().Trim();
                item.FAMILYMEMBER       = drs[i]["FAMILYMEMBER"].ToString().Trim();
                item.A1 = drs[i]["A1"].ToString().Trim();
                item.A2 = drs[i]["A2"].ToString().Trim();
                item.A3 = drs[i]["A3"].ToString().Trim();


                if (isShowPic == true)
                {
                    if (drs[i]["PHOTO"] != null && !drs[i]["PHOTO"].ToString().Equals(""))
                    {
                        item.PHOTO = (byte[])drs[i]["PHOTO"];
                    }
                }
                list.Add(item);
            }
            return(list);
        }
        /// <summary>
        /// 修改人员信息
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public bool ModifyPersonBasicInfo(PersonBasicInfo info)
        {
            bool isresult = false;


            if (info.PHOTO != null && info.PHOTO.Length > 0)
            {
                //if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + info.A2) == false)
                //{


                //    info.PHOTO = ImageHelper.YaSuo(info.PHOTO);

                //    //保存图片
                //    string filename = AppDomain.CurrentDomain.BaseDirectory + "\\Images\\" + info.NAMEID;
                //    string fileFullname = ImageHelper.CreateImageFromBytes(filename, info.PHOTO);

                //    string md5Code = ImageHelper.GetMD5HashFromByte(info.PHOTO);

                //    info.A1 = md5Code;

                //    info.A2 = fileFullname.Replace(AppDomain.CurrentDomain.BaseDirectory, "");



                //}
                //else
                //{

                //    string md5file = DataManager.Public.ImageHelper.GetMD5HashFromFile(AppDomain.CurrentDomain.BaseDirectory + info.A2);

                //    string md5PhotoCode = ImageHelper.GetMD5HashFromByte(info.PHOTO);



                //    if (md5file.Equals(md5PhotoCode) == false)
                //    {

                info.PHOTO = ImageHelper.YaSuo(info.PHOTO);

                //        //保存图片
                //        string filename = AppDomain.CurrentDomain.BaseDirectory + "\\Images\\" + info.NAMEID;
                //        string fileFullname = ImageHelper.CreateImageFromBytes(filename, info.PHOTO);

                //        string md5Code = ImageHelper.GetMD5HashFromByte(info.PHOTO);

                //        info.A1 = md5Code;

                //        info.A2 = fileFullname.Replace(AppDomain.CurrentDomain.BaseDirectory, "");
                //    }
                //}
            }



            using (OleDbConnection connection = new OleDbConnection(DbHelperACE.connectionString))
            {
                OleDbCommand command = new OleDbCommand();
                command.Connection  = connection;
                command.CommandText = UpdatePersonInfoSql + @"  NAMEID = '" + info.NAMEID + "'"
                                      + @" , NAME = '" + info.NAME + "'"
                                      + @" ,  SEX = '" + info.SEX + "'"
                                      + @" ,  BIRTHDATE = '" + info.BIRTHDATE + "'"
                                      + @" ,  NATION = '" + info.NATION + "'"
                                      + @" ,  ENLISTMENTDATE = '" + info.ENLISTMENTDATE + "'"
                                      + @" ,  MILITARYRANK = '" + info.MILITARYRANK + "'"
                                      + @" ,  ORIGINPLACE = '" + info.ORIGINPLACE + "'"
                                      + @" ,  ARMYSEAT = '" + info.ARMYSEAT + "'"
                                      + @" ,  MAJOR = '" + info.MAJOR + "'"
                                      + @" ,  EDUCATION = '" + info.EDUCATION + "'"
                                      + @" ,  POLITICAL = '" + info.POLITICAL + "'"
                                      + @" ,  PARTYTIME = '" + info.PARTYTIME + "'"
                                      + @" ,  BLOODTYPE = '" + info.BLOODTYPE + "'"
                                      + @" ,  HJQK = '" + info.HJQK + "'"
                                      + @" ,  IDCARD = '" + info.IDCARD + "'"
                                      + @" ,  HOBBY = '" + info.HOBBY + "'"
                                      + @" ,  CHARACTERTYPE = '" + info.CHARACTERTYPE + "'"
                                      + @" ,  QQID = '" + info.QQID + "'"
                                      + @" ,  HOMEADDRESS = '" + info.HOMEADDRESS + "'"
                                      + @" ,  PHONE = '" + info.PHONE + "'"
                                      + @" ,  SPOUSENAME = '" + info.SPOUSENAME + "'"
                                      + @" ,  SPOUSEMARRIAGETIME = '" + info.SPOUSEMARRIAGETIME + "'"
                                      + @" ,  SPOUSESUNIT = '" + info.SPOUSESUNIT + "'"
                                      + @" ,  SPOUSESHOMEADDRESS = '" + info.SPOUSESHOMEADDRESS + "'"
                                      + @" ,  SPOUSESPHONE = '" + info.SPOUSESPHONE + "'"
                                      + @" ,  CHILDRENNAME = '" + info.CHILDRENNAME + "'"
                                      + @" ,  CHILDRENSEX = '" + info.CHILDRENSEX + "'"
                                      + @" ,  CHILDRENBIRTH = '" + info.CHILDRENBIRTH + "'"
                                      + @" ,  ENLISTINGRESUME = '" + info.ENLISTINGRESUME + "'"
                                      + @" ,  TRAININGSITUATION = '" + info.TRAININGSITUATION + "'"
                                      + @" ,  REWARDSPUNISHMENTS = '" + info.REWARDSPUNISHMENTS + "'"


                                      + @" ,  FAMILYMEMBER = '" + info.FAMILYMEMBER + "'"
                                      + @" ,  A1 = '" + info.A1 + "'"
                                      + @" ,  A2 = '" + info.A2 + "'"
                                      + @" ,  A3 = '" + info.A3 + "'"
                                      + @" ,  PHOTO = @photo1"
                                      + @" where    NAMEID = '" + info.NAMEID + "'";

                command.CommandType = CommandType.Text;
                OleDbParameter imageType = new OleDbParameter("@photo1", OleDbType.VarBinary);
                imageType.Value = info.PHOTO;
                command.Parameters.Add(imageType).Value = info.PHOTO;



                try
                {
                    connection.Open();
                    int rows = command.ExecuteNonQuery();
                    isresult = true;
                }
                catch (System.Data.OleDb.OleDbException E)
                {
                    throw new Exception(E.Message);
                }
                finally
                {
                    command.Dispose();
                    connection.Close();
                }
            }

            return(isresult);
        }