//***************************************************************************** // // 中国航天科工集团第二研究院 // 北京无线电计量测试研究所 // 计量与校准国防科技重点实验室 // // 项目名称: 双目虹膜信息综合管理平台 // // 配合SY望远镜式双目注册设备使用 // //***************************************************************************** using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Runtime.InteropServices; using System.Windows.Forms; using System.Reflection; using System.Diagnostics; using IOM_cs.insertForm.service; using System.Web.Script.Serialization; using IOM_cs.insertForm.data.dto; using IOM_cs.irisDb.model; using IOM_cs.irisDb.service; using IOM_cs.irisDb.service.mySqlImpl; using IOM_cs.insertForm.service.impl; using IOM_cs.irisDb; using System.Threading; using SuperWebSocket; using System.Web; using WebSocketSharp; namespace IOM_cs { public delegate void Handled1(); public partial class FormMain : Form { #region 成员变量 private FormLogin formLogin; //登陆界面 public static User user; public static FormMain formMain = null; public static Person person = new Person(); //sys_person表实体 public static IrisDataColl irisDataColl = new IrisDataColl();//iris_data_coll表实体 public static IrisData irisData = new IrisData(); // iris_data表实体 public static PersonExt personExt = new PersonExt(); // sys_person_ext表实体 private bool devInited = false; // 虹膜采集设备初始化成功标识 private bool cardReaderInited = false; // 身份证读卡器初始化成功标识 //private iCamIrisClass m_iCamIrisClass = new iCamIrisClass(); // 编码类 private Point mouseOff; // 鼠标移动位置变量 private bool leftFlag; // 标签是否为左键 private bool isCaptureForce; // 是否强制采集标识 private bool isICSConnected=false;// 是否与ics建立连接标识 //private Thread initDevThread; public static IInsertService insertService = new InsertImpl(); private bool isReadCard = false; private bool btn_collectInfoClick = true; private bool btn_collectListClick = false; private bool btn_settinClick = false; #endregion 成员变量 IUserIrisService iUserIrisService = (IUserIrisService)DbService.getEntity("IUserIrisService"); public FormMain() { try { formMain = this; user = FormLogin.user; // 初始化控件 InitializeComponent(); // 设置双缓冲 SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.OptimizedDoubleBuffer, true); // 跨线程访问控件 CheckForIllegalCrossThreadCalls = false; } catch (Exception ex) { LogHelper.WriteLog(MethodBase.GetCurrentMethod().DeclaringType, "注册界面初始化错误:" + ex.Message); } } private void FormMain_Load(object sender, EventArgs e) { label_wellcome.Text = "欢迎您," + FormLogin.user.Name + "!"; btn_collectInfo.Back = ColorTranslator.FromHtml("#56a3f2"); tabControl_Main.Location = new Point(24, -16); } private void FormMain_Shown(object sender, EventArgs e) { initComboBoxList();//初始化下拉框数据 initInputItems();//初始化部分输入框内容 comboBox_country.SelectedIndex = -1; comboBox_nation.SelectedIndex = -1; inputBoxDisable(); btn_collectInfo.Visible = true; btn_collectList.Visible = true; btn_setting.Visible = true; } #region 导入库文件 // 搜眼与质量评估(已弃用) //[DllImport("CaptureEye_IrisKey.dll", EntryPoint = "CaptureEye_IrisKey")] //public static extern unsafe int CaptureEye_IrisKey(IntPtr Data, int* pos); //[DllImport("AssessQuality_IrisKey.dll", EntryPoint = "AssessQuality_IrisKey")] //public static extern unsafe int AssessQuality_IrisKey(IntPtr Data, int[] Pos); // 身份证读卡 [DllImport("sdtapi.dll", CallingConvention = CallingConvention.StdCall)] static extern int SDT_OpenPort(int iPort); [DllImport("sdtapi.dll", CallingConvention = CallingConvention.StdCall)] static extern int SDT_ClosePort(int iPort); [DllImport("sdtapi.dll", CallingConvention = CallingConvention.StdCall)] static extern int SDT_StartFindIDCard(int iPort, byte[] pucManaInfo, int iIfOpen); [DllImport("sdtapi.dll", CallingConvention = CallingConvention.StdCall)] static extern int SDT_SelectIDCard(int iPort, byte[] pucManaMsg, int iIfOpen); [DllImport("sdtapi.dll", CallingConvention = CallingConvention.StdCall)] static extern int SDT_ReadBaseMsg(int iPort, byte[] pucCHMsg, ref UInt32 puiCHMsgLen, byte[] pucPHMsg, ref UInt32 puiPHMsgLen, int iIfOpen); [DllImport("WltRS.dll", CallingConvention = CallingConvention.StdCall)] static extern int GetBmp(string Wlt_File, int intf); #endregion 自定义函数 #region 初始化控件及值 // 初始化各个下拉列表 private void initComboBoxList() { // 证件类型 var items = new System.Collections.ArrayList(Enum.GetValues(typeof(cardType))).ToArray(); comboBox_cardType.Items.Clear(); comboBox_cardType.Items.AddRange(items); // 国籍 items = new System.Collections.ArrayList(Enum.GetValues(typeof(country))).ToArray(); comboBox_country.Items.Clear(); comboBox_country.Items.AddRange(items); // 民族 items = new System.Collections.ArrayList(Enum.GetValues(typeof(nation))).ToArray(); comboBox_nation.Items.Clear(); comboBox_nation.Items.AddRange(items); // 采集原因(即人员类别) items = new System.Collections.ArrayList(Enum.GetValues(typeof(collReason))).ToArray(); comboBox_collReason.Items.Clear(); comboBox_collReason.Items.AddRange(items); // 采集地点 items = new System.Collections.ArrayList(Enum.GetValues(typeof(collPlace))).ToArray(); comboBox_collPlace.Items.Clear(); comboBox_collPlace.Items.AddRange(items); // 采集类型(双眼、左眼、右眼) items = new System.Collections.ArrayList(Enum.GetValues(typeof(collType))).ToArray(); comboBox_collType.Items.Clear(); comboBox_collType.Items.AddRange(items); // 缺失原因 items = new System.Collections.ArrayList(Enum.GetValues(typeof(defReason))).ToArray(); comboBox_defReason.Items.Clear(); comboBox_defReason.Items.AddRange(items); } // 设置部分输入项初始值 private void initInputItems() { inputBoxDisable(); // 输入框禁用 comboBox_cardType.SelectedItem = cardType.身份证; comboBox_collReason.SelectedItem = collReason.普通人员; comboBox_collPlace.SelectedItem = collPlace.标采室; comboBox_collType.SelectedItem = collType.双眼; comboBox_defReason.SelectedItem = defReason.正常; radio_flgForcePersonN.Checked = true; radio_flgWoN.Checked = true; radio_flgFocusN.Checked = true; txt_collType.Text = comboBox_collType.SelectedItem.ToString(); txt_defReason.Text = comboBox_defReason.SelectedItem.ToString(); label_remarks.Location = new Point(109, 228); txt_remarks.Location = new Point(180, 223); } // 重置第一步页面内容 private void resetStep1() { txt_name.Clear(); radio_female.Checked = false; radio_male.Checked = false; comboBox_nation.SelectedIndex = -1; txt_addr1.Clear(); picker_birthday.Text = ""; txt_birthday.Clear(); txt_IDCardNo.Clear(); txt_age.Clear(); txt_startTime.Clear(); txt_endTime.Clear(); comboBox_country.SelectedIndex = -1; txt_cerAuth.Text = ""; pic_IDFace.Image = null; btn_nextStep12.Enabled = true; txt_country.Clear(); txt_nation.Clear(); } // 重置第二部页面内容 private void resetStep2() { txt_tel1.Clear(); txt_tel2.Clear(); txt_addr2.Clear(); comboBox_collReason.SelectedIndex = -1; comboBox_collPlace.SelectedItem = -1; radio_flgFocusN.Checked = false; radio_flgFocusY.Checked = false; radio_flgForcePersonN.Checked = false; radio_flgForcePersonY.Checked = false; radio_flgWoN.Checked = false; radio_flgWoY.Checked = false; txt_focusEndDate.Clear(); txt_focusRemarks.Clear(); txt_remarks.Clear(); } //重置第三步页面内容 private void resetStep3() { comboBox_collType.SelectedItem = collType.双眼; comboBox_defReason.SelectedItem = defReason.正常; txt_collType.Text = comboBox_collType.SelectedItem.ToString(); txt_defReason.Text = comboBox_defReason.SelectedItem.ToString(); btn_captureForce.Enabled = false; pic_imageL1.Image = null; pic_imageR1.Image = null; label_qualityL.Text = ""; label_qualityR.Text = ""; } // 读卡输入时,输入框不可编辑 private void inputBoxDisable() { txt_name.Enabled = false; radio_female.Enabled = false; radio_male.Enabled = false; comboBox_nation.Enabled = false; txt_addr1.Enabled = false; picker_birthday.Enabled = false; txt_birthday.Enabled = false; txt_IDCardNo.Enabled = false; picker_startTime.Enabled = false; txt_startTime.Enabled = false; picker_endTime.Enabled = false; txt_endTime.Enabled = false; comboBox_country.Enabled = false; txt_cerAuth.Enabled = false; comboBox_cardType.Enabled = false; btn_DropBirth.Enabled = false; btn_dropStart.Enabled = false; btn_dropEnd.Enabled = false; btn_dropCountry.Enabled = false; btn_dropNation.Enabled = false; txt_nation.Enabled = false; txt_country.Enabled = false; txt_age.Enabled = false; pic_IDFace.Image = null; btn_nextStep12.Enabled = true; btn_dropNation.BackColor = ColorTranslator.FromHtml("#ECEEF2"); btn_dropCountry.BackColor = ColorTranslator.FromHtml("#ECEEF2"); btn_dropStart.BackColor = ColorTranslator.FromHtml("#ECEEF2"); btn_dropEnd.BackColor = ColorTranslator.FromHtml("#ECEEF2"); btn_DropBirth.BackColor = ColorTranslator.FromHtml("#ECEEF2"); } // 手动输入时,输入框可编辑 private void inputBoxEnable() { txt_name.Enabled = true; radio_female.Enabled = true; radio_male.Enabled = true; comboBox_nation.Enabled = true; txt_addr1.Enabled = true; picker_birthday.Enabled = true; txt_birthday.Enabled = true; txt_IDCardNo.Enabled = true; picker_startTime.Enabled = true; txt_startTime.Enabled = true; picker_endTime.Enabled = true; txt_endTime.Enabled = true; comboBox_country.Enabled = true; txt_cerAuth.Enabled = true; comboBox_cardType.Enabled = true; btn_dropCardType.Enabled = true; btn_DropBirth.Enabled = true; btn_dropStart.Enabled = true; btn_dropEnd.Enabled = true; btn_dropCountry.Enabled = true; btn_dropNation.Enabled = true; txt_nation.Enabled = true; txt_country.Enabled = true; txt_age.Enabled = true; pic_IDFace.Image = null; btn_nextStep12.Enabled = true; btn_dropNation.BackColor = Color.White; btn_dropCountry.BackColor = Color.White; btn_dropStart.BackColor = Color.White; btn_dropEnd.BackColor = Color.White; btn_DropBirth.BackColor = Color.White; } #endregion #region step1 // 手动输入 private void btn_input_Click(object sender, EventArgs e) { resetStep1(); comboBox_country.SelectedItem = country.中国; comboBox_nation.SelectedItem = nation.汉族; inputBoxEnable(); isReadCard = false; } // 读取证件信息 private void btn_readCard_Click(object sender, EventArgs e) { try { if (comboBox_cardType.Text == "" || (cardType)comboBox_cardType.SelectedItem == cardType.无证件) { MessageBox.Show("请先选择证件类型!"); return; } if (comboBox_cardType.Text != "身份证") { MessageBox.Show("此功能正在开发中,敬请期待!"); return; } //string icsResult = ""; //if (!isICSConnected) //与ICS服务通信 //using (var ws = new WebSocket("ws://127.0.0.1:1234")) //{ // ws.OnMessage += (sender2, e2) => // icsResult = e2.Data; // ws.Connect(); // ws.Send("ReadIdCard"); // while (true) // { // if (icsResult.Length <= 0) continue; // if (!string.IsNullOrWhiteSpace(icsResult)) // MessageBox.Show(icsResult); // icsResult = ""; // ws.Close(); // break; // } // //new Thread(new ThreadStart(() => // //{ // //})).Start(); //} // 不可手动输入 inputBoxDisable(); byte[] CardPUCIIN = new byte[255]; byte[] pucManaMsg = new byte[255]; byte[] pucCHMsg = new byte[255]; byte[] pucPHMsg = new byte[3024]; UInt32 puiCHMsgLen = 0; UInt32 puiPHMsgLen = 0; int st = 0; st = SDT_StartFindIDCard(1001, CardPUCIIN, 1); if (st == 0x9f) { st = SDT_SelectIDCard(1001, pucManaMsg, 1); if (st == 0x90) { st = SDT_ReadBaseMsg(1001, pucCHMsg, ref puiCHMsgLen, pucPHMsg, ref puiPHMsgLen, 1); if (st == 0x90) { string name = System.Text.ASCIIEncoding.Unicode.GetString(pucCHMsg, 0, 30).Trim(); string gender = System.Text.ASCIIEncoding.Unicode.GetString(pucCHMsg, 30, 2).Trim(); string nation = System.Text.ASCIIEncoding.Unicode.GetString(pucCHMsg, 32, 4).Trim(); string birthDate = System.Text.ASCIIEncoding.Unicode.GetString(pucCHMsg, 36, 16).Trim(); string address = System.Text.ASCIIEncoding.Unicode.GetString(pucCHMsg, 52, 70).Trim(); string noID = System.Text.ASCIIEncoding.Unicode.GetString(pucCHMsg, 122, 36).Trim(); string authority = System.Text.ASCIIEncoding.Unicode.GetString(pucCHMsg, 158, 30).Trim(); string startTime = System.Text.ASCIIEncoding.Unicode.GetString(pucCHMsg, 188, 16).Trim(); string endTime = System.Text.ASCIIEncoding.Unicode.GetString(pucCHMsg, 204, 16).Trim(); DateTime birthDate0 = DateTime.ParseExact(birthDate, "yyyyMMdd", null); DateTime startTime0 = DateTime.ParseExact(startTime, "yyyyMMdd", null); DateTime endTime0 = DateTime.ParseExact(endTime, "yyyyMMdd", null); string path0 = System.Windows.Forms.Application.StartupPath + "\\" + DateTime.Now.ToString("yyyyMMddhhmmss"); string path = path0 + ".wlt"; File.Delete(path); FileStream fs = File.Open(path, FileMode.Append); fs.Write(pucPHMsg, 0, (int)puiPHMsgLen); fs.Close(); int img = GetBmp(path, 2); string faceImageLoadPath = path0 + ".bmp"; ImageFormat faceImageLoadFormat = ImageFormat.Bmp; txt_name.Text = name; if (gender == "1") radio_male.Checked = true; else if (gender == "2") radio_female.Checked = true; comboBox_nation.SelectedItem = Enum.Parse(typeof(nation), nation); picker_birthday.Value = birthDate0; txt_birthday.Text = birthDate0.ToString("yyyy-MM-dd"); txt_addr1.Text = address; txt_IDCardNo.Text = noID; txt_cerAuth.Text = authority; picker_startTime.Value = startTime0; txt_startTime.Text = startTime0.ToString("yyyy-MM-dd"); picker_endTime.Value = endTime0; txt_endTime.Text = endTime0.ToString("yyyy-MM-dd"); comboBox_country.SelectedItem = country.中国; txt_age.Text = countAge(birthDate0); Image imgF = Image.FromFile(faceImageLoadPath); Image bmpF = new Bitmap(imgF); imgF.Dispose(); pic_IDFace.Image = bmpF; //File.Delete(faceImageLoadPath); } else { resetStep1(); } } isReadCard = true; } else { MessageBox.Show("读卡失败,请检查卡片放置位置。"); resetStep1(); return; } } catch (Exception ex) { string msg = "读取身份证出错:" + ex.Message; LogHelper.WriteLog(MethodBase.GetCurrentMethod().DeclaringType, msg); } } // 选择证件类型 private void comboBox_cardType_SelectedIndexChanged(object sender, EventArgs e) { txt_cardType.Text = comboBox_cardType.SelectedItem.ToString(); resetStep1(); inputBoxEnable(); comboBox_country.SelectedItem = country.中国; comboBox_nation.SelectedItem = nation.汉族; if ((cardType)comboBox_cardType.SelectedItem == cardType.无证件) { label9.Visible = false;// 无证件时,证件号码不是必填 } else { label9.Visible = true; } } // 下一步 private void btn_nextStep12_Click(object sender, EventArgs e) { try { if (txt_name.Text.Trim() == "") { MessageBox.Show(this, "姓名不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else { if (!Validation.CheckName(txt_name.Text.Trim())) { MessageBox.Show(this, "请输入真实姓名!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } if ((cardType)comboBox_cardType.SelectedItem != cardType.无证件 && txt_IDCardNo.Text.Trim() == "") { MessageBox.Show(this, "证件号码不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (comboBox_cardType.Text == "身份证" || comboBox_cardType.Text == "临时居民身份证") { if (!Validation.CheckIDCard(txt_IDCardNo.Text.Trim())) { MessageBox.Show(this, "请输入正确的身份证号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } if (!radio_male.Checked && !radio_female.Checked) { MessageBox.Show(this, "请选择性别!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else { // 与身份证号相互校验 if (comboBox_cardType.Text == "身份证" || comboBox_cardType.Text == "临时居民身份证") { if (txt_IDCardNo.Text.Length == 18) { if ((Convert.ToInt16(txt_IDCardNo.Text.Substring(16, 1)) % 2) == 1)//奇数 { radio_male.Checked = true; } else radio_female.Checked = true; } } } if (txt_birthday.Text == "") { MessageBox.Show(this, "生日不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else { if (comboBox_cardType.Text == "身份证" || comboBox_cardType.Text == "临时居民身份证") { string birth = ""; if (txt_IDCardNo.Text.Length == 15) birth = ("19" + txt_IDCardNo.Text.Substring(6, 6)).Insert(2, "-").Insert(5, "-"); else if (txt_IDCardNo.Text.Length == 18) birth = txt_IDCardNo.Text.Substring(6, 8).Insert(4, "-").Insert(7, "-"); if (birth != txt_birthday.Text) { MessageBox.Show(this, "所选生日与身份证号中的生日不一致!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } } //判断证件号码是否重复 if (txt_IDCardNo.Text.Trim() != "" && iUserIrisService.IsIDCardNoPresent(txt_IDCardNo.Text.Trim()) > 0) { MessageBox.Show("已存在该证件号码!"); return; } //收集数据 person = new Person(); person.name = txt_name.Text.Trim(); // 姓名 if (radio_male.Checked) person.sex = ((int)sex.男).ToString(); else if (radio_female.Checked) person.sex = ((int)sex.女).ToString(); // 性别 person.cardType = comboBox_cardType.SelectedItem.GetHashCode().ToString(); // 证件类型 if (txt_IDCardNo.Text.Trim() != "") person.idCardNo = txt_IDCardNo.Text.Trim(); // 证件号码 else person.idCardNo = null; person.nation = comboBox_nation.SelectedItem.GetHashCode().ToString(); // 民族 person.birthday = Convert.ToDateTime(txt_birthday.Text);//生日 personExt = new PersonExt(); personExt.column1 = comboBox_country.SelectedItem.GetHashCode().ToString(); // 国籍 if (txt_startTime.Text != "" && txt_endTime.Text != "") personExt.column6 = txt_startTime.Text + "," + txt_endTime.Text; // 证件有效期 personExt.column2 = txt_cerAuth.Text.Trim();//签发机关 personExt.column3 = txt_addr1.Text.Trim();//户籍地址 if (pic_IDFace.Image != null)//证件照 { Image img = pic_IDFace.Image; MemoryStream ms = new MemoryStream(); img.Save(ms, ImageFormat.Bmp); byte[] arr = ms.ToArray(); ms.Close(); personExt.column7 = "data:image/png;base64," + Convert.ToBase64String(arr); } //刷新步骤条状态 tabControl_Main.SelectedTab = tabControl_Main.TabPages[1]; label_step2.ForeColor = Color.Black; label_step2Text.ForeColor = Color.Black; picture_line1.BackColor = Color.Black; } catch (Exception ex) { string msg = "保存基础信息出错:" + ex.Message; LogHelper.WriteLog(MethodBase.GetCurrentMethod().DeclaringType, msg); } } // 选择生日 private void picker_birthday_ValueChanged(object sender, EventArgs e) { if (picker_birthday.Value > DateTime.Now) { MessageBox.Show("请选择正确的出生日期!"); return; } txt_birthday.Text = picker_birthday.Value.ToString("yyyy-MM-dd"); txt_age.Text = countAge(picker_birthday.Value); //年龄 //txt_birthday.Focus(); } // 选择证件有效期开始日期 private void picker_startTime_ValueChanged(object sender, EventArgs e) { if (txt_endTime.Text != "") { if (Convert.ToDateTime(txt_endTime.Text) <= Convert.ToDateTime(picker_startTime.Value.ToString("yyyy-MM-dd"))) { MessageBox.Show("起始日期必须在结束日期之前!"); return; } } if (picker_startTime.Text != "") txt_startTime.Text = picker_startTime.Value.ToString("yyyy-MM-dd"); } // 选择证件有效期结束日期 private void picker_endTime_ValueChanged(object sender, EventArgs e) { if (txt_startTime.Text != "") { if (Convert.ToDateTime(txt_startTime.Text) >= Convert.ToDateTime(picker_endTime.Value.ToString("yyyy-MM-dd"))) { MessageBox.Show("结束日期必须在起始日期之后!"); return; } } if (picker_endTime.Text != "") txt_endTime.Text = picker_endTime.Value.ToString("yyyy-MM-dd"); } // 从身份证号得到生日和性别 private void txt_IDCardNo_TextChanged(object sender, EventArgs e) { if (txt_IDCardNo.Text != "" && ((cardType)comboBox_cardType.SelectedItem == cardType.身份证 || (cardType)comboBox_cardType.SelectedItem == cardType.临时居民身份证 || (cardType)comboBox_cardType.SelectedItem == cardType.无证件)) { if (Validation.CheckIDCard(txt_IDCardNo.Text)) { string idCardNo = txt_IDCardNo.Text; string birth = ""; if (idCardNo.Length == 15) birth = "19" + idCardNo.Substring(6, 6).Insert(2, "-").Insert(5, "-"); else if (idCardNo.Length == 18) { birth = idCardNo.Substring(6, 8).Insert(4, "-").Insert(7, "-"); if ((Convert.ToInt16(idCardNo.Substring(16, 1)) % 2) == 1)//奇数 { radio_male.Checked = true; } else radio_female.Checked = true; } txt_birthday.Text = birth; txt_age.Text = countAge(Convert.ToDateTime(birth)); } } } private void btn_dropCardType_Click(object sender, EventArgs e) { comboBox_cardType.DroppedDown = true; } private void btn_dropCountry_Click(object sender, EventArgs e) { comboBox_country.DroppedDown = true; } private void btn_dropNation_Click(object sender, EventArgs e) { comboBox_nation.DroppedDown = true; } private void btn_dropStart_Click(object sender, EventArgs e) { picker_startTime.Focus(); //焦点(鼠标光标)停留在当前控件 SendKeys.Send("{F4}"); //模拟按下F4,弹出日期面板 } private void btn_dropEnd_Click(object sender, EventArgs e) { picker_endTime.Focus(); SendKeys.Send("{F4}"); //模拟按下F4,弹出日期面板 } private void btn_DropBirth_Click(object sender, EventArgs e) { picker_birthday.Focus(); SendKeys.Send("{F4}"); //模拟按下F4,弹出日期面板 } private void comboBox_country_SelectedIndexChanged_1(object sender, EventArgs e) { if (comboBox_country.SelectedIndex > -1) txt_country.Text = comboBox_country.SelectedItem.ToString(); } private void comboBox_nation_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox_nation.SelectedIndex > -1) txt_nation.Text = comboBox_nation.SelectedItem.ToString(); } #endregion #region step2 // 上一步 private void btn_lastStep21_Click(object sender, EventArgs e) { tabControl_Main.SelectedIndex = 0; label_step2.ForeColor = Color.DarkGray; label_step2Text.ForeColor = Color.DarkGray; picture_line1.BackColor = Color.DarkGray; } // 下一步 private void btn_nextStep23_Click(object sender, EventArgs e) { try { if (comboBox_collReason.Text == "") { MessageBox.Show("采集原因不能为空!"); return; } if (comboBox_collPlace.Text == "") { MessageBox.Show("采集场地不能为空!"); return; } if (txt_tel1.Text != "") { if (!Validation.CheckMobliePhone(txt_tel1.Text)) { MessageBox.Show("请输入正确的手机号1!"); return; } } if (txt_tel2.Text != "") { if (!Validation.CheckMobliePhone(txt_tel2.Text)) { MessageBox.Show("请输入正确的手机号2!"); return; } } // 收集数据 irisDataColl = new IrisDataColl(); irisDataColl.tel1 = txt_tel1.Text.Trim(); //手机号1 irisDataColl.tel2 = txt_tel2.Text.Trim(); // 手机号2 irisDataColl.collReason = comboBox_collReason.SelectedItem.GetHashCode().ToString();//采集原因 irisDataColl.collPlace = comboBox_collPlace.SelectedItem.GetHashCode().ToString();//采集地点 if (radio_flgForcePersonY.Checked) irisDataColl.flgForcePerson = "1"; else if (radio_flgForcePersonN.Checked) irisDataColl.flgForcePerson = "0"; if (radio_flgFocusY.Checked) irisDataColl.flgFocus = "1"; else if (radio_flgFocusN.Checked) irisDataColl.flgFocus = "0"; if (radio_flgWoY.Checked) irisDataColl.flgWo = "1"; else if (radio_flgWoN.Checked) irisDataColl.flgWo = "0"; if (txt_focusEndDate.Text != "") irisDataColl.focusEndDate = Convert.ToDateTime(txt_focusEndDate.Text); irisDataColl.focusRemarks = txt_focusRemarks.Text.Trim(); irisDataColl.reasonCollDesc = txt_remarks.Text.Trim(); irisDataColl.collName = FormLogin.user.Name; if (person.cardType == ((int)cardType.无证件).ToString()) //选择了无证件 { irisDataColl.isCer = "0"; } else { irisDataColl.isCer = "1"; } if (isReadCard) { irisDataColl.collWay = ((int)collWay.读卡录入).ToString(); } else { irisDataColl.collWay = ((int)collWay.手动录入).ToString(); } // personExt 已在第一步new过 personExt.column4 = txt_addr2.Text.Trim();//现住址 // 刷新步骤条状态 tabControl_Main.SelectedIndex = 2; label_step3.ForeColor = Color.Black; label_step3Text.ForeColor = Color.Black; picture_line2.BackColor = Color.Black; // 初始化step3控件 btn_captureForce.Enabled = false; } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void btn_dropCollPlace_Click(object sender, EventArgs e) { comboBox_collPlace.DroppedDown = true; } private void comboBox_collPlace_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox_collPlace.SelectedIndex > -1) txt_collPlace.Text = comboBox_collPlace.SelectedItem.ToString(); } private void btn_dropCollReason_Click(object sender, EventArgs e) { comboBox_collReason.DroppedDown = true; } private void comboBox_collReason_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox_collReason.SelectedIndex > -1) txt_collReason.Text = comboBox_collReason.SelectedItem.ToString(); } // 选择临时关注结束日期 private void picker_focusEndDate_ValueChanged(object sender, EventArgs e) { txt_focusEndDate.Text = picker_focusEndDate.Value.ToString("yyyy-MM-dd"); } private void btn_dropFocusEndDate_Click(object sender, EventArgs e) { picker_focusEndDate.Focus(); SendKeys.Send("{F4}"); //模拟按下F4,弹出日期面板 } // 选择是否“临时关注” private void radio_flgFocusY_CheckedChanged(object sender, EventArgs e) { if (radio_flgFocusY.Checked) { label4.Visible = true; txt_focusEndDate.Visible = true; picker_focusEndDate.Visible = true; label5.Visible = true; txt_focusRemarks.Visible = true; btn_dropFocusEndDate.Visible = true; btn_dropFocusEndDate.BringToFront(); label_remarks.Location = new Point(109, 228 + 50); txt_remarks.Location = new Point(180, 223 + 50); } else if (radio_flgFocusN.Checked) { label4.Visible = false; txt_focusEndDate.Visible = false; picker_focusEndDate.Visible = false; label5.Visible = false; txt_focusRemarks.Visible = false; btn_dropFocusEndDate.Visible = false; label_remarks.Location = new Point(109, 228); txt_remarks.Location = new Point(180, 223); } } #endregion #region step3 // 上一步 private void btn_lastStep32_Click(object sender, EventArgs e) { tabControl_Main.SelectedIndex = 1; label_step3.ForeColor = Color.DarkGray; label_step3Text.ForeColor = Color.DarkGray; picture_line2.BackColor = Color.DarkGray; } // 保存 private void btn_save_Click(object sender, EventArgs e) { if (pic_imageL1.Image == null && pic_imageR1.Image == null) { MessageBox.Show("请先采集虹膜图片!", "提示", MessageBoxButtons.OK); return; } btn_save.Enabled = false; try { //基础信息 person.id = BitConverter.ToInt64(Guid.NewGuid().ToByteArray(), 0); personExt.id = BitConverter.ToInt64(Guid.NewGuid().ToByteArray(), 0); personExt.targetId = person.id; if (iUserIrisService.AddPerson(person, personExt) != 0) { MessageBox.Show("保存失败,数据库异常!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //采集信息 irisDataColl.irId = BitConverter.ToInt64(Guid.NewGuid().ToByteArray(), 0); irisDataColl.sId = person.id; irisDataColl.collNum = iUserIrisService.getCollNum(); irisDataColl.collType = comboBox_collType.SelectedItem.GetHashCode().ToString();//采集类型 irisDataColl.defReason = comboBox_defReason.SelectedItem.GetHashCode().ToString();//缺失原因 irisDataColl.collTime = DateTime.Now; irisDataColl.stName = ConfigHelper.GetAppConfig("DeptName").ToString().Trim(); // 采集站点 irisDataColl.stType = ConfigHelper.GetAppConfig("DeptIndex").ToString().Trim(); // 站点类别 irisDataColl.flgUpload = "0"; if (iUserIrisService.AddIrisDataColl(irisDataColl) != 0) { MessageBox.Show("保存失败,数据库异常!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // 虹膜数据 irisData = new IrisData(); irisData.irId = irisDataColl.irId; irisData.sId = person.id; // 收集虹膜图片数据 if (pic_imageL1.Image != null)//左眼虹膜图片 { Image _img = pic_imageL1.Image; Bitmap bt = bmpTool.RgbToGrayScale(new Bitmap(_img)); Image img = (Image)bt; MemoryStream ms = new MemoryStream(); img.Save(ms, ImageFormat.Bmp); byte[] arr = ms.ToArray(); ms.Close(); irisData.imageL1Data = "data:image/bmp;base64," + Convert.ToBase64String(arr); } if (pic_imageR1.Image != null)//右眼虹膜图片 { Image _img = pic_imageR1.Image; Bitmap bt = bmpTool.RgbToGrayScale(new Bitmap(_img)); Image img = (Image)bt; MemoryStream ms = new MemoryStream(); img.Save(ms, ImageFormat.Bmp); byte[] arr = ms.ToArray(); ms.Close(); irisData.imageR1Data = "data:image/bmp;base64," + Convert.ToBase64String(arr); } if (iUserIrisService.AddIrisData(irisData) != 0) { MessageBox.Show("保存失败,数据库异常!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //语音提示注册成功 //SoundPlayer sound = new SoundPlayer("saveSuccess.wav"); //sound.Play(); DialogResult r = MessageBox.Show("保存成功!" + "\n" + "是否继续添加人员?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (r == DialogResult.No)//跳转到详情页 { //new Thread(new ThreadStart(() => //{ iUserIrisService.GetDetail(person.id, ref person, ref personExt, ref irisDataColl, ref irisData); insertService.setToFirst(panel_Insert); insertService.SetPanelControl(panel_Insert, "detail"); //})).Start(); panel4.Visible = false; panel_steps.Visible = false; panel_Insert.BringToFront(); } else //跳转到信息采集第一步 { tabControl_Main.SelectedIndex = 0; label_step3.ForeColor = Color.DarkGray; label_step3Text.ForeColor = Color.DarkGray; picture_line2.BackColor = Color.DarkGray; label_step2.ForeColor = Color.DarkGray; label_step2Text.ForeColor = Color.DarkGray; picture_line1.BackColor = Color.DarkGray; //panel_detail.Visible = false; panel4.Visible = true; panel_steps.Visible = true; } //清空界面数据 resetStep1(); resetStep2(); pic_imageL1.Image = null; pic_imageR1.Image = null; label_qualityL.Text = ""; label_qualityR.Text = ""; btn_save.Enabled = true; initInputItems(); btn_captureForce.Enabled = false; } catch (Exception ex) { //SoundPlayer sound = new SoundPlayer("saveFailure.wav"); //sound.Play(); string msg = "注册失败:" + ex.Message; LogHelper.WriteLog(MethodBase.GetCurrentMethod().DeclaringType, msg); axIrisDevCtrl1.StopCapture(); axIrisDevCtrl1.IrisClose(); } finally { btn_save.Enabled = true; } } // 开始采集 private void btn_captureIris_Click(object sender, EventArgs e) { try { comboBox_collType.Enabled = false; comboBox_defReason.Enabled = false; btn_captureIris.Enabled = false; btn_captureForce.Enabled = false; btn_dropCollType.Enabled = false; btn_dropDefReason.Enabled = false; txt_collType.Enabled = false; txt_defReason.Enabled = false; btn_dropCollType.BackColor = ColorTranslator.FromHtml("#ECEEF2"); btn_dropDefReason.BackColor = ColorTranslator.FromHtml("#ECEEF2"); //btn_captureForce.HoverForeColor = Color.DimGray; //采集设备初始化 if (devInited == false) { string initText = "{\"log\":\"0\",\"white_brightness\":\"240\"}"; int iResult = axIrisDevCtrl1.IrisInit(initText); if (iResult == 0) { devInited = true; //sResult = string.Format("虹膜采集设备初始化成功!"); } else { btn_captureIris.Enabled = true; panel_vedioImage.Visible = true; MessageBox.Show("采集设备启动失败,请重试!", "错误", MessageBoxButtons.OK); return; } } panel_vedioImage.Visible = false; // 初始化数据 label_qualityL.Text = ""; label_qualityR.Text = ""; pic_imageL1.Image = null; pic_imageR1.Image = null; // 开始采集 string collType = "{\"eyeType\":\"" + comboBox_collType.SelectedItem.GetHashCode().ToString() + "\"}"; axIrisDevCtrl1.StartCapture(collType); isCaptureForce = false; } catch (Exception ex) { MessageBox.Show(ex.Message); } } // 强制采集 private void btn_captureForce_Click(object sender, EventArgs e) { try { comboBox_collType.Enabled = false; comboBox_defReason.Enabled = false; btn_captureIris.Enabled = false; btn_captureForce.Enabled = false; btn_dropCollType.Enabled = false; btn_dropDefReason.Enabled = false; txt_collType.Enabled = false; txt_defReason.Enabled = false; btn_dropCollType.BackColor = ColorTranslator.FromHtml("#ECEEF2"); btn_dropDefReason.BackColor = ColorTranslator.FromHtml("#ECEEF2"); //btn_captureForce.HoverForeColor = Color.DimGray; //采集设备初始化 if (devInited == false) { string initText = "{\"log\":\"0\",\"white_brightness\":\"240\"}"; int iResult = axIrisDevCtrl1.IrisInit(initText); if (iResult == 0) { devInited = true; //sResult = string.Format("虹膜采集设备初始化成功!"); } else { MessageBox.Show("采集设备启动失败,请重试!", "Error", MessageBoxButtons.OK); return; } } panel_vedioImage.Visible = false; // 初始化数据 label_qualityL.Text = ""; label_qualityR.Text = ""; pic_imageL1.Image = null; pic_imageR1.Image = null; // 启动强制采集 string collType = "{\"eyeType\":\"" + comboBox_collType.SelectedItem.GetHashCode().ToString() + "\"}"; axIrisDevCtrl1.StartCaptureForce(collType); isCaptureForce = true; } catch (Exception ex) { MessageBox.Show(ex.Message); } } // 重置采集设备 private void btn_resetDev_Click(object sender, EventArgs e) { axIrisDevCtrl1.StopCapture(); axIrisDevCtrl1.IrisClose(); axIrisDevCtrl1.ReSet(); btn_captureForce.Enabled = false; btn_captureForce.ForeColor = Color.Black; } // 采集结果事件 private void axIrisDevCtrl1_OnCapture(object sender, AxIrisDevCtrlLib._DIrisDevCtrlEvents_OnCaptureEvent e) { panel_vedioImage.Visible = true; panel_vedioImage.BringToFront(); irisDataColl.devType = ""; irisDataColl.devCode = ""; irisDataColl.devFirm = ""; irisDataColl.collSpend = ""; irisDataColl.qL = 0; irisDataColl.qR = 0; irisDataColl.flgForce = "0"; comboBox_collType.Enabled = true; comboBox_defReason.Enabled = true; btn_captureIris.Enabled = true; btn_dropCollType.Enabled = true; btn_dropDefReason.Enabled = true; txt_collType.Enabled = true; txt_defReason.Enabled = true; btn_dropCollType.BackColor = Color.White; btn_dropDefReason.BackColor = Color.White; btn_captureForce.HoverForeColor = Color.White; if (e.result != 0) { label_qualityL.Text = "质量:<5"; label_qualityR.Text = "质量:<5"; label_qualityL.ForeColor = Color.OrangeRed; label_qualityR.ForeColor = Color.OrangeRed; btn_captureForce.Enabled = true; btn_captureForce.Enabled = true; //语音提示采集失败 //SoundPlayer sound = new SoundPlayer("captureFailure.wav"); //sound.Play(); return; } try { Bitmap bmpL1 = null, bmpR1 = null; string s = e.sIrisInfo; JavaScriptSerializer serializer = new JavaScriptSerializer(); Dictionary<string, object> jsonResult = (Dictionary<string, object>)serializer.DeserializeObject(e.sIrisInfo); object flgResult;//0:成功;-1:质量不合格;-2:采集超时;其他:失败; object hmzp_zy = null;//左眼虹膜图片base64编码 object hmzp_yy = null;//右眼虹膜图片base64编码 object cjtphs = null;//采集图片耗时 object sbxh = null;//设备型号 object sbbh = null;//设备编号 object zy_xxzlpf = null;//左眼图像质量评分 object yy_xxzlpf = null; //右眼图像质量评分 object sbcsdm = null; // 设备厂商代码(信用代码) jsonResult.TryGetValue("flgResult", out flgResult); jsonResult.TryGetValue("hmzp_zy", out hmzp_zy); jsonResult.TryGetValue("hmzp_yy", out hmzp_yy); jsonResult.TryGetValue("cjtphs", out cjtphs); jsonResult.TryGetValue("sbxh", out sbxh); jsonResult.TryGetValue("sbbh", out sbbh); jsonResult.TryGetValue("zy_xxzlpf", out zy_xxzlpf); jsonResult.TryGetValue("yy_xxzlpf", out yy_xxzlpf); jsonResult.TryGetValue("sbcsdm", out sbcsdm); if (flgResult.ToString() == "0") { if (comboBox_collType.Text == "双眼" || comboBox_collType.Text == "左眼") { if (hmzp_zy != null && hmzp_zy.ToString() != "") { bmpL1 = Base64StringToImage(hmzp_zy.ToString()); //显示左眼图像 if (bmpL1 != null) { Bitmap tempL1 = new Bitmap(640, 480); Graphics drawL1 = Graphics.FromImage(tempL1); drawL1.DrawImage(bmpL1, 0, 0); pic_imageL1.Image = (Image)tempL1; drawL1.Dispose(); } //编码 //Image img = bmpL1; //byte[] LQualifiedIrisBuffer = BitmapFactory.ImageToRaw8BitByteArray(img, out height, out width); //iResultL1 = m_iCamIrisClass.CreateLongIrisCode(LQualifiedIrisBuffer, out leftIrisCode1); //if (iResultL1 != 0) //{ // MessageBox.Show("左眼编码失败!"); // return; //} } else { MessageBox.Show("左眼采集失败!"); return; } } if (comboBox_collType.Text == "双眼" || comboBox_collType.Text == "右眼") { if (hmzp_yy != null && hmzp_yy.ToString() != "") { bmpR1 = Base64StringToImage(hmzp_yy.ToString()); //显示右眼图像 if (bmpR1 != null) { //, PixelFormat.Format8bppIndexed Bitmap tempR1 = new Bitmap(640, 480); Graphics drawR1 = Graphics.FromImage(tempR1); drawR1.DrawImage(bmpR1, 0, 0); pic_imageR1.Image = (Image)tempR1; drawR1.Dispose(); } //Image img = bmpR1; //byte[] RQualifiedIrisBuffer = BitmapFactory.ImageToRaw8BitByteArray(img, out height, out width); //iResultR1 = m_iCamIrisClass.CreateLongIrisCode(RQualifiedIrisBuffer, out rightIrisCode1); //if (iResultR1 != 0) //{ // MessageBox.Show("右眼编码失败!"); // return; //} } else { MessageBox.Show("右眼采集失败!"); return; } } //语音提示采集成功 //SoundPlayer sound = new SoundPlayer("captureSuccess.wav"); //sound.Play(); string zyQ = ""; string yyQ = ""; if (zy_xxzlpf != null && zy_xxzlpf.ToString() != "0") zyQ = ((double)(Convert.ToDouble(zy_xxzlpf) / 10)).ToString("0.0"); if (yy_xxzlpf != null && yy_xxzlpf.ToString() != "0") yyQ = ((double)(Convert.ToDouble(yy_xxzlpf) / 10)).ToString("0.0"); //收集数据 //irisData.irisR = (byte[])rightIrisCode1; //irisData.irisL = (byte[])leftIrisCode1; // irisDataColl已在第二步new过 if (sbxh != null) irisDataColl.devType = sbxh.ToString(); if (sbbh != null) irisDataColl.devCode = sbbh.ToString(); if (sbcsdm != null) irisDataColl.devFirm = sbcsdm.ToString(); if (cjtphs != null) irisDataColl.collSpend = cjtphs.ToString(); if (zyQ != "") irisDataColl.qL = Convert.ToDecimal(zyQ); if (yyQ != "") irisDataColl.qR = Convert.ToDecimal(yyQ); irisDataColl.flgForce = "1"; if (!isCaptureForce) { irisDataColl.flgForce = "0"; if (zyQ != "") { label_qualityL.Text = "质量:" + zyQ; label_qualityL.ForeColor = Color.LawnGreen; } if (yyQ != "") { label_qualityR.Text = "质量:" + yyQ; label_qualityR.ForeColor = Color.LawnGreen; } } } else { label_qualityL.Text = "质量:<5"; label_qualityR.Text = "质量:<5"; label_qualityL.ForeColor = Color.OrangeRed; label_qualityR.ForeColor = Color.OrangeRed; btn_captureForce.Enabled = true; } } catch (Exception ex) { //语音提示采集失败 //SoundPlayer sound = new SoundPlayer("captureFailure.wav"); //sound.Play(); MessageBox.Show("虹膜采集错误:" + ex.Message); } } // 选择采集类型,“双眼”、“左眼”、“右眼” private void comboBox_collType_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox_collType.SelectedIndex > -1) txt_collType.Text = comboBox_collType.SelectedItem.ToString(); if ((collType)comboBox_collType.SelectedItem != collType.双眼) { comboBox_defReason.Enabled = true; comboBox_defReason.SelectedItem = defReason.残缺; txt_defReason.Enabled = true; btn_dropDefReason.Enabled = true; btn_dropDefReason.BackColor = Color.White; } else { comboBox_defReason.SelectedItem = defReason.正常; comboBox_defReason.Enabled = false; txt_defReason.Enabled = false; btn_dropDefReason.Enabled = false; btn_dropDefReason.BackColor = ColorTranslator.FromHtml("#ECEEF2"); } } private void comboBox_defReason_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox_defReason.SelectedIndex > -1) txt_defReason.Text = comboBox_defReason.SelectedItem.ToString(); if ((collType)comboBox_collType.SelectedItem != collType.双眼) { if ((defReason)comboBox_defReason.SelectedItem == defReason.正常) { comboBox_defReason.SelectedItem = defReason.残缺; } } } private void btn_dropCollType_Click(object sender, EventArgs e) { comboBox_collType.DroppedDown = true; } private void btn_dropDefReason_Click(object sender, EventArgs e) { comboBox_defReason.DroppedDown = true; } #endregion #region 主页事件 #region 信息采集 private void click1() { txt_cardType.Enabled = true; comboBox_cardType.Enabled = true; btn_collectInfoClick = true; btn_collectListClick = false; btn_settinClick = false; btn_collectInfo.BringToFront(); btn_collectInfo.Back = ColorTranslator.FromHtml("#56a3f2"); btn_collectList.Back = Color.Transparent; btn_setting.Back = Color.Transparent; insertService.setToLast(panel_Insert); panel_steps.Visible = true; panel4.Visible = true; //panel_detail.Visible = false; resetStep1(); // 重置第一步 resetStep2(); // 重置第二步 resetStep3(); // 重置第三步 tabControl_Main.SelectedIndex = 0;//显示第一步 initInputItems();//初始化部分输入框的值 // 初始化步骤条状态 label_step2.ForeColor = Color.DarkGray; label_step2Text.ForeColor = Color.DarkGray; picture_line1.BackColor = Color.DarkGray; label_step3.ForeColor = Color.DarkGray; label_step3Text.ForeColor = Color.DarkGray; picture_line2.BackColor = Color.DarkGray; } private void show1() { if (!btn_collectInfoClick) { btn_collectInfo.Back = ColorTranslator.FromHtml("#56a3f2"); } } private void hide1() { if (!btn_collectInfoClick) btn_collectInfo.Back = Color.Transparent; } private void btn_collectInfo_MouseClick(object sender, MouseEventArgs e) { click1(); } private void pic_collInfo_MouseClick(object sender, MouseEventArgs e) { click1(); } private void label_collInfo_Click(object sender, EventArgs e) { click1(); } private void label_collInfo_MouseClick(object sender, MouseEventArgs e) { click1(); } private void btn_collectInfo_MouseHover(object sender, EventArgs e) { show1(); } private void btn_collectInfo_MouseLeave(object sender, EventArgs e) { hide1(); } private void pic_collInfo_MouseHover(object sender, EventArgs e) { show1(); } private void pic_collInfo_MouseLeave(object sender, EventArgs e) { hide1(); } private void label_collInfo_MouseHover(object sender, EventArgs e) { show1(); } private void label_collInfo_MouseLeave(object sender, EventArgs e) { hide1(); } # endregion #region 采集列表 private void click2() { if (txt_name.Text != "" || txt_IDCardNo.Text != "") { DialogResult r = MessageBox.Show("录入的信息还未保存,一旦离开数据将清空,确认离开当前页?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (r == DialogResult.No) { return; } } resetStep1(); btn_collectInfoClick = false; btn_collectListClick = true; btn_settinClick = false; btn_collectList.BringToFront(); btn_collectInfo.Back = Color.Transparent; btn_collectList.Back = ColorTranslator.FromHtml("#56a3f2"); btn_setting.Back = Color.Transparent; insertService.setToFirst(panel_Insert); insertService.SetPanelControl(panel_Insert, "collect"); IOM_cs.insertForm.collection.CtrlCollectionFrom.ctrlCollectionFrom.dataGridView1.ClearSelection(); } private void show2() { if (!btn_collectListClick) { btn_collectList.Back = ColorTranslator.FromHtml("#56a3f2"); } } private void hide2() { if (!btn_collectListClick) btn_collectList.Back = Color.Transparent; } private void btn_collectList_MouseClick(object sender, MouseEventArgs e) { click2(); } private void pic_collList_MouseClick(object sender, MouseEventArgs e) { click2(); } private void label_collList_MouseClick(object sender, MouseEventArgs e) { click2(); } private void btn_collectList_MouseHover(object sender, EventArgs e) { show2(); } private void btn_collectList_MouseLeave(object sender, EventArgs e) { hide2(); } private void pic_collList_MouseHover(object sender, EventArgs e) { show2(); } private void pic_collList_MouseLeave(object sender, EventArgs e) { hide2(); } private void label_collList_MouseHover(object sender, EventArgs e) { show2(); } private void label_collList_MouseLeave(object sender, EventArgs e) { hide2(); } #endregion #region 系统设置 private void click3() { //pic_sysSetting.BackColor = ColorTranslator.FromHtml("#56a3f2"); //label_sysSetting.BackColor = ColorTranslator.FromHtml("#56a3f2"); if (txt_name.Text != "" || txt_IDCardNo.Text != "") { DialogResult r = MessageBox.Show("录入的信息还未保存,一旦离开数据将清空,确认离开当前页?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (r == DialogResult.No) { return; } } resetStep1(); btn_collectInfoClick = false; btn_collectListClick = false; btn_settinClick = true; btn_setting.BringToFront(); btn_collectInfo.Back = Color.Transparent; btn_collectList.Back = Color.Transparent; btn_setting.Back = ColorTranslator.FromHtml("#56a3f2"); insertService.setToFirst(panel_Insert); insertService.SetPanelControl(panel_Insert, "sys"); } private void show3() { if (!btn_settinClick) btn_setting.Back = ColorTranslator.FromHtml("#56a3f2"); } private void hide3() { if (!btn_settinClick) btn_setting.Back = Color.Transparent; } private void btn_setting_MouseClick(object sender, MouseEventArgs e) { click3(); } private void pic_setting_MouseClick(object sender, MouseEventArgs e) { click3(); } private void label_setting_MouseClick(object sender, MouseEventArgs e) { click3(); } private void btn_setting_MouseHover(object sender, EventArgs e) { show3(); } private void btn_setting_MouseLeave(object sender, EventArgs e) { hide3(); } private void pic_setting_MouseHover(object sender, EventArgs e) { show3(); } private void pic_setting_MouseLeave(object sender, EventArgs e) { hide3(); } private void label_setting_MouseHover(object sender, EventArgs e) { show3(); } private void label_setting_MouseLeave(object sender, EventArgs e) { hide3(); } #endregion #region 按钮 //修改密码 private void btn_editPassword_Click(object sender, EventArgs e) { IOM_cs.insertForm.sysSetting.EditPassWord editPassword = new IOM_cs.insertForm.sysSetting.EditPassWord(FormLogin.user); editPassword.Show(); } private void btn_editPassword_MouseHover(object sender, EventArgs e) { label_tip1.Visible = true; } private void btn_editPassword_MouseLeave(object sender, EventArgs e) { label_tip1.Visible = false; } // 退出登录 private void btn_logout_Click(object sender, EventArgs e) { Process.Start(Application.ExecutablePath); Application.Exit(); } private void btn_logout_MouseHover(object sender, EventArgs e) { label_tip2.Visible = true; } private void btn_logout_MouseLeave(object sender, EventArgs e) { label_tip2.Visible = false; } // 最小化 private void btn_min_Click(object sender, EventArgs e) { this.WindowState = FormWindowState.Minimized; //最小化 } private void btn_min_MouseHover(object sender, EventArgs e) { label_tip3.Visible = true; } private void btn_min_MouseLeave(object sender, EventArgs e) { label_tip3.Visible = false; } // 关闭软件 private void btn_close_Click(object sender, EventArgs e) { Close(); } private void FormMain_FormClosing(object sender, FormClosingEventArgs e) { try { SDT_ClosePort(1001); string[] dirs = Directory.GetFiles(System.Windows.Forms.Application.StartupPath, "*.bmp"); foreach (string dir in dirs) { File.Delete(dir); } string[] dirs1 = Directory.GetFiles(System.Windows.Forms.Application.StartupPath + "\\TEMP\\", "*.bmp"); foreach (string dir in dirs1) { File.Delete(dir); } FormLogin.formLogin.Close(); Environment.Exit(0); string msg = "注册界面正常关闭!"; LogHelper.WriteLog(MethodBase.GetCurrentMethod().DeclaringType, msg); } catch (Exception ex) { string msg = "注册界面去初始化出错:" + ex.Message; LogHelper.WriteLog(MethodBase.GetCurrentMethod().DeclaringType, msg); } } private void btn_close_MouseHover(object sender, EventArgs e) { label_tip4.Visible = true; } private void btn_close_MouseLeave(object sender, EventArgs e) { label_tip4.Visible = false; } #endregion #region 窗体拖动 // 窗体拖动 private void panel_title_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { mouseOff = new Point(-e.X, -e.Y); //得到变量的值 leftFlag = true; //点击左键按下时标注为true; } } // 窗体拖动 private void panel_title_MouseMove(object sender, MouseEventArgs e) { if (leftFlag) { Point mouseSet = Control.MousePosition; mouseSet.Offset(mouseOff.X, mouseOff.Y); //设置移动后的位置 Location = mouseSet; } } // 窗体拖动 private void panel_title_MouseUp(object sender, MouseEventArgs e) { if (leftFlag) { leftFlag = false;//释放鼠标后标注为false; } } #endregion #endregion #region tool /// <summary> /// base64编码的文本转为图片 /// </summary> public Bitmap Base64StringToImage(string basestr) { Bitmap bitmap = null; try { String inputStr = basestr; byte[] arr = Convert.FromBase64String(inputStr); MemoryStream ms = new MemoryStream(arr); Bitmap bmp = new Bitmap(ms); ms.Close(); ms.Dispose(); bitmap = bmp; } catch (Exception ex) { //MessageBox.Show("Base64StringToImage 转换失败\nException:" + ex.Message); } return bitmap; } //计算年龄 private string countAge(DateTime birthday) { string ageS = ""; if (null != birthday) { DateTime now = DateTime.Now; int age = now.Year - birthday.Year; //再考虑月、天的因素 if (now.Month < birthday.Month || (now.Month == birthday.Month && now.Day < birthday.Day)) { age--; } ageS = age.ToString(); } return ageS; } #endregion // 解决控件加载花屏问题 //protected override CreateParams CreateParams //{ // get // { // var parms = base.CreateParams; // parms.Style &= ~0x02000000; // return parms; // } //} //protected override CreateParams CreateParams //{ // get // { // CreateParams cp = base.CreateParams; // cp.ExStyle |= 0x02000000; // return cp; // } //} } }