private void btnSave_Click(object sender, EventArgs e) { try { int iReadSerialBaud = LBConverter.ToInt32(this.txtReadSerialBaud.Text); string strReadSerialName = this.txtReadSerialName.SelectedValue == null?"": this.txtReadSerialName.SelectedValue.ToString(); string strWriteSerialName = this.txtWriteSerialName.SelectedValue == null ? "" : this.txtWriteSerialName.SelectedValue.ToString(); LBDbParameterCollection parmCol = new LBDbParameterCollection(); parmCol.Add(new LBParameter("ReadCardSerialCOM", enLBDbType.String, strReadSerialName)); parmCol.Add(new LBParameter("WriteCardSerialCOM", enLBDbType.String, strWriteSerialName)); parmCol.Add(new LBParameter("ReadCardBaud", enLBDbType.Int32, iReadSerialBaud)); parmCol.Add(new LBParameter("MachineName", enLBDbType.String, LoginInfo.MachineName)); parmCol.Add(new LBParameter("UseReadCard", enLBDbType.Int32, (this.cbUseReadCard.Checked?1:0))); parmCol.Add(new LBParameter("UseWriteCard", enLBDbType.Int32, (this.cbUseWriteCard.Checked ? 1 : 0))); parmCol.Add(new LBParameter("ConnectType", enLBDbType.Int32, (this.rbNet.Checked ? 1 : 0))); parmCol.Add(new LBParameter("IPAddress", enLBDbType.String, this.txtIPAddress.Text)); parmCol.Add(new LBParameter("IPPort", enLBDbType.Int32, LBConverter.ToInt32(this.txtPort.Text))); DataSet dsReturn; Dictionary <string, object> dictValue; ExecuteSQL.CallSP(20503, parmCol, out dsReturn, out dictValue); LBCardHelper.StartSerial(enCardType.ReadCard); LB.WinFunction.LBCommonHelper.ShowCommonMessage("保存成功!"); } catch (Exception ex) { LB.WinFunction.LBCommonHelper.DealWithErrorMessage(ex); } }
private void btnSave_Click(object sender, EventArgs e) { try { if (txtCardCode.Text.TrimEnd() == "") { throw new Exception("【编辑卡片】不能为空!"); } string strCrrentCardCode = LBCardHelper.ReadCardCode(); if (strCrrentCardCode == "") { throw new Exception("请将卡片放置读卡器上,否则无法保存!"); } if (strCrrentCardCode != this.txtCardCode.Text) { if (LB.WinFunction.LBCommonHelper.ConfirmMessage("当前设置的卡号为【" + strCrrentCardCode + "】,是否确认改写为【" + this.txtCardCode.Text + "】?", "提示", MessageBoxButtons.YesNo) == DialogResult.No) { return; } else { //将卡号写入卡片 string strMsg; bool bolSuccess = LBCardHelper.WriteCardCode(this.txtCardCode.Text, out strMsg); if (!bolSuccess) { throw new Exception("卡号写入失败,失败原因:" + strMsg); } } } int iSPType = 20500; if (mlCardID > 0) { iSPType = 20501; } LBDbParameterCollection parmCol = new LBDbParameterCollection(); parmCol.Add(new LBParameter("CardID", enLBDbType.Int64, mlCardID)); parmCol.Add(new LBParameter("CardName", enLBDbType.String, this.txtCardName.Text)); parmCol.Add(new LBParameter("CardCode", enLBDbType.String, this.txtCardCode.Text)); DataSet dsReturn; Dictionary <string, object> dictValue; ExecuteSQL.CallSP(iSPType, parmCol, out dsReturn, out dictValue); if (dictValue.ContainsKey("CardID")) { mlCardID = LBConverter.ToInt64(dictValue["CardID"]); } LB.WinFunction.LBCommonHelper.ShowCommonMessage("保存成功!"); SetButtonStatus(); } catch (Exception ex) { LB.WinFunction.LBCommonHelper.DealWithErrorMessage(ex); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); LBCardHelper.StartSerial(enCardType.WriteCard);//开启打开器端口 ReadFieldValue(); SetButtonStatus(); }
private void btnReadCard_Click(object sender, EventArgs e) { try { this.txtSourceCardCode.Text = LBCardHelper.ReadCardCode(); } catch (Exception ex) { LB.WinFunction.LBCommonHelper.DealWithErrorMessage(ex); } }
protected override void OnClosing(CancelEventArgs e) { base.OnClosing(e); LBCardHelper.ClosePort(); }