public int openT6 = -1;//0 社保卡是否正常打开 0正常 非0不正常++++++++++ #region 加载事件 private void MainForm_Load(object sender, EventArgs e) { AppContext.Session.openStatus = false; cmd.ShowOpaqueLayer(0f); String deptName = "无"; if (AppContext.Session.deptList.Count > 0) { deptName = AppContext.Session.deptList[0].name; } labBottomLeft.Text = deptName + " | " + AppContext.Session.name + " | " + System.DateTime.Now.ToString(); this.timer1.Start(); tmHeartbeat.Enabled = true; //获取父级为1的菜单 List <MenuEntity> menuList = new List <MenuEntity>(); for (int i = 0; i < AppContext.Session.menuList.Count(); i++) { MenuEntity menu = AppContext.Session.menuList[i]; if (menu.parentId.Equals("1")) { menuList.Add(menu); } } //排序菜单 menuList = menuList.OrderBy(x => x.sort).ToList(); //循环添加菜单 panMenuBar.Controls.Clear(); foreach (MenuEntity menu in menuList) { AddContextMenu(menu.id, menu.name, menu.href, panMenuBar); } cmd.ShowOpaqueLayer(0f, "初始化读卡器..."); this.DoWorkAsync(500, (o) => //耗时逻辑处理(此处不能操作UI控件,因为是在异步中) { //Thread.Sleep(1000); //初始化T6 有线程延迟 openT6 = HardwareInitialClass.OpenDevice(); if (openT6 != 0) { LogClass.WriteLog("社保读卡器初始化失败:"); } else { LogClass.WriteLog("社保读卡器初始化成功"); } return(null); }, null, (data) => //显示结果(此处用于对上面结果的处理,比如显示到界面上) { //显示欢迎页 WelcomeForm form = new WelcomeForm(); AaddUserControl(form, "Welcome", "欢迎页"); cmd.HideOpaqueLayer(); }); //AppContext.Session.waitControl = xtraTabControl1; }
public int readCard() { ////读取社保卡数据 byte[] cardMeassageByte = new byte[225]; int temR = HardwareInitialClass.GetPosInfo(cardMeassageByte);//等待刷卡 if (temR == 0) { message_type = Encoding.ASCII.GetString(cardMeassageByte, 0, 1).Trim(); user_id = Encoding.Default.GetString(cardMeassageByte, 1, 8).Trim(); company_code = Encoding.Default.GetString(cardMeassageByte, 9, 15).Trim(); holder_id = Encoding.Default.GetString(cardMeassageByte, 24, 19).Trim(); name = Encoding.Default.GetString(cardMeassageByte, 43, 10).Trim(); if (Encoding.Default.GetString(cardMeassageByte, 53, 1).Trim() == "0") { sex = "1"; } else { sex = "2"; } user_id = Encoding.Default.GetString(cardMeassageByte, 1, 8).Trim(); //LogClass.WriteLog("user_id:" + user_id); birthday = Encoding.Default.GetString(cardMeassageByte, 54, 8).Trim(); //LogClass.WriteLog("birthday:" + birthday); user_type = Encoding.Default.GetString(cardMeassageByte, 62, 2).Trim(); //LogClass.WriteLog("user_type:" + user_type); telephone = Encoding.Default.GetString(cardMeassageByte, 64, 12).Trim(); // LogClass.WriteLog("telephone:" + telephone); blood_type = Encoding.Default.GetString(cardMeassageByte, 76, 1).Trim(); //LogClass.WriteLog("blood_type:" + blood_type); ill_history = Encoding.Default.GetString(cardMeassageByte, 77, 14).Trim(); //LogClass.WriteLog("ill_history:" + ill_history); h_ill_history = Encoding.Default.GetString(cardMeassageByte, 91, 12).Trim(); //LogClass.WriteLog("h_ill_history:" + h_ill_history); address1 = Encoding.Default.GetString(cardMeassageByte, 103, 40).Trim(); //LogClass.WriteLog("address1:" + address1); post_id = Encoding.Default.GetString(cardMeassageByte, 143, 6).Trim(); //LogClass.WriteLog("post_id:" + post_id); linkman = Encoding.Default.GetString(cardMeassageByte, 149, 10).Trim(); //LogClass.WriteLog("linkman:" + linkman); area_code = Encoding.Default.GetString(cardMeassageByte, 159, 2).Trim(); //LogClass.WriteLog("area_code:" + area_code); cs_amount = Encoding.Default.GetString(cardMeassageByte, 161, 12).Trim(); //LogClass.WriteLog("cs_amount:" + cs_amount); sb_amount = Encoding.Default.GetString(cardMeassageByte, 173, 12).Trim(); //LogClass.WriteLog("sb_amount:" + sb_amount); sp_amount = Encoding.Default.GetString(cardMeassageByte, 185, 12).Trim(); //LogClass.WriteLog("sp_amount:" + sp_amount); zfu_amount = Encoding.Default.GetString(cardMeassageByte, 197, 12).Trim(); //LogClass.WriteLog("zfu_amount:" + zfu_amount); card = Encoding.Default.GetString(cardMeassageByte, 209, 16).Trim(); //LogClass.WriteLog("card:" + card); //LogClass.WriteLog("个账金额:" + sb_amount); } else { StringBuilder msg = new StringBuilder(); HardwareInitialClass.GetErrorMsg(msg); return_msg = "社保读卡失败:" + temR + "|" + msg; //Xr.Log4net.LogHelper.Info(return_msg); //LogClass.WriteLog("社保读卡失败:" + temR + "|" + msg); int resetR = HardwareInitialClass.ResetDev();//读卡失败时,进行复位 //Xr.Log4net.LogHelper.Info("复位结果:" + resetR); //LogClass.WriteLog("复位结果:" + resetR); } return(temR); }
private void MainForm_Load(object sender, EventArgs e) { AppContext.Session.openStatus = false; cmd.ShowOpaqueLayer(0f); var deptName = "无"; if (AppContext.Session.deptList.Count > 0) { deptName = AppContext.Session.deptList[0].name; } labBottomLeft.Text = deptName + " | " + AppContext.Session.name + " | " + System.DateTime.Now.ToString(); timer1.Start(); tmHeartbeat.Enabled = true; var menuList = new List <MenuEntity>(); for (var i = 0; i < AppContext.Session.menuList.Count(); i++) { var menu = AppContext.Session.menuList[i]; if (menu.parentId.Equals("1")) { menuList.Add(menu); } } menuList = menuList.OrderBy(x => x.sort).ToList(); panMenuBar.Controls.Clear(); foreach (MenuEntity menu in menuList) { AddContextMenu(menu.id, menu.name, menu.href, panMenuBar); } cmd.ShowOpaqueLayer(0f, "初始化读卡器..."); DoWorkAsync(500, (o) => { openT6 = HardwareInitialClass.OpenDevice(); if (openT6 != 0) { Xr.Log4net.LogHelper.Info("社保读卡器初始化失败:"); } else { Xr.Log4net.LogHelper.Info("社保读卡器初始化成功"); } return(null); }, null, (data) => { var form = new WelcomeForm(); AaddUserControl(form, "Welcome", "欢迎页"); cmd.HideOpaqueLayer(); }); }
public bool cexiao(string liushuihao) { StringBuilder tem = new StringBuilder(); tem.Append(liushuihao); int aa = HardwareInitialClass.SaleVoid(tem); if (aa != 0) { HardwareInitialClass.GetErrorMsg(tem); return_msg = tem + ""; Xr.Log4net.LogHelper.Info("撤销失败:" + liushuihao); Xr.Log4net.LogHelper.Info("撤销失败:" + liushuihao); return(false); } else { return(true); } }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { if (MessageBoxUtils.Show("你确定退出系统吗?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, this) == DialogResult.OK) { var url = AppContext.AppConfig.serverUrl + "logout"; var data = HttpClass.httpPost(url); var objT = JObject.Parse(data); if (string.Compare(objT["state"].ToString(), "true", true) == 0) { try { //退出社保读卡器 openT6 = HardwareInitialClass.CloseDevice(); if (openT6 != 0) { Xr.Log4net.LogHelper.Info("社保读卡器退出失败:"); } else { Xr.Log4net.LogHelper.Info("社保读卡器退出成功"); } } catch { } AppContext.Unload(); e.Cancel = false; } else { MessageBoxUtils.Show("会话登出失败:" + objT["message"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, this); } } else { e.Cancel = true; } }
public bool kougezhang(PosTranClass posTran) { StringBuilder tem = new StringBuilder(); tem.Append(posTran.message_type); tem.Append(posTran.ill_code); tem.Append(posTran.q_amount); tem.Append(posTran.p_amount); tem.Append(posTran.f_amount); tem.Append(posTran.s_amount); tem.Append(posTran.c_amount); tem.Append(posTran.e_amount); tem.Append(posTran.yy_code); tem.Append(posTran.flag); tem.Append(posTran.datetime); Xr.Log4net.LogHelper.Info("个帐参数:" + tem.ToString()); int aa = HardwareInitialClass.SendPosInfo(tem); Xr.Log4net.LogHelper.Info("回参:" + tem); string[] resultValue = tem.ToString().Split('|'); string result = resultValue[0]; if (result != "30") { posTran = null; StringBuilder error = new StringBuilder(); aa = HardwareInitialClass.GetErrorMsg(error); Xr.Log4net.LogHelper.Info("扣个账失败原因:" + error.ToString()); return_msg = "扣个账失败原因:" + error.ToString(); return(false); } else { string temm = "没有流水号"; if (resultValue.Length > 1 && resultValue[1] != null) { temm = resultValue[1]; } posTran.liushuihao = temm; posTran.GRZHKKQYE = sb_amount; posTran.GRZHZF = posTran.s_amount; posTran.GWYTCXEYE = posTran.e_amount; posTran.TSBZKFQYE = sp_amount; posTran.JFLB = posTran.flag; posTran.ZFLJ = temm; posTran.liushuihao = temm; return(true); } //StringBuilder tem = new StringBuilder(); //tem.Append("1"); //tem.Append(" "); //tem.Append("000000000001"); //tem.Append("000000000000"); //tem.Append("000000000001"); //tem.Append("000000000002"); //tem.Append("000000000000"); //tem.Append("000000000000"); //tem.Append(" "); //tem.Append("1"); //tem.Append("20170307152323"); //int aa = HardwareInitialClass.SendPosInfo(tem); //string result = (tem.ToString().Split('|'))[0]; ; //if (result != "30") // posTran = null; }
public int cancelReadCard() { return(HardwareInitialClass.CancelAccept());//取消刷卡 }