Пример #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                this.VerifyTextBoxIsEmpty();//校验控件是否为空

                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);
            }
        }
Пример #2
0
 private void btnReadCard_Click(object sender, EventArgs e)
 {
     try
     {
         this.txtSourceCardCode.Text = LBCardHelper.ReadCardCode();
     }
     catch (Exception ex)
     {
         LB.WinFunction.LBCommonHelper.DealWithErrorMessage(ex);
     }
 }