コード例 #1
0
        private bool GetCardBalance(string sCardID, ref int iBalance, ref int iTrade, ref string sErrMsg)
        {
            //银石后台
            objHttp = new EbHttpClass();
            bool bRst = objHttp.QryCard(sCardID, ref iBalance, ref iTrade, ref sErrMsg);

            return(bRst);
        }
コード例 #2
0
        private void button_Card_Old_Click(object sender, EventArgs e)
        {
            //读卡号
            ReadCardNo(MyStart.gszCardYtbFirst, button_Card_Old, textBox_Card_Old);

            //银石后台读余额
            EbHttpClass objHttp = new EbHttpClass();
            int         iVal    = 0;
            string      szErr   = "";
            bool        bRst    = objHttp.QryCard(textBox_Card_Old.Text, ref iVal, ref miUncofirmVal, ref szErr);

            if (!bRst)
            {
                MessageBox.Show("后台换卡失败( " + szErr + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            textBox_Val.Text = ((decimal)iVal / 100).ToString("#0.00");
        }
コード例 #3
0
ファイル: frm_Card_AddVal.cs プロジェクト: wl2019/EB_for_YTB
        private void button_CheckCard_Click(object sender, EventArgs e)
        {
            string  szInf   = "";
            string  sCardID = "";
            DataSet odt     = null;

            if (!frm_Main.bHaveRd)
            {
                MessageBox.Show("没有连接读写器,不能执行充值功能!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!myRdr.ComOpen(frm_Main.sRdPort))
            {
                MessageBox.Show("打开串口失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                myRdr.ComClose();
                return;
            }

            ((Button)sender).Enabled = false;
            if (!myRdr.ReadCardInf(out szInf))
            {
                if (textBox_CardID.Text.Trim() != "")
                {
                    sCardID = textBox_CardID.Text;
                }
                else
                {
                    MessageBox.Show("读卡失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    ((Button)sender).Enabled = true;
                    myRdr.ComClose();
                    return;
                }
            }
            else
            {
                sCardID = szInf.Substring(0, 16);
            }
            myRdr.ComClose();
            ((Button)sender).Enabled = true;
            textBox_CardID.Text      = sCardID;

            if (sCardID.Substring(0, 1) == MyStart.gszCardFirmFirst)
            {
                MessageBox.Show("不接受商户卡的充值,请换卡!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            odt = null;
            string sErrMsg = "";
            string sSql    = "";

            try
            {
                sSql = "SELECT * FROM base_ucard WHERE user_card = '" + sCardID + "'";

                int iRst = MyStart.oMyDb.ReadData(sSql, "TableA", ref odt, ref sErrMsg);
                if (iRst != 0)
                {
                    MessageBox.Show("后台查询卡余额失败( " + sErrMsg + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    goto Eend;
                }

                if (odt.Tables[0].Rows.Count <= 0)
                {
                    MessageBox.Show("没有此用户卡的信息,请更换。", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    goto Eend;
                }
                sUserName = odt.Tables[0].Rows[0]["user_name"].ToString().Trim();

                //银石后台
                objHttp = new EbHttpClass();
                string szErr       = "";
                int    CardBalance = 0;
                int    iTrade      = 0;

                bool bRst = objHttp.QryCard(sCardID, ref CardBalance, ref iTrade, ref szErr);
                if (!bRst)
                {
                    MessageBox.Show("后台查询卡余额失败( " + szErr + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    goto Eend;
                }

                float fi = CardBalance;
                fi = fi / 100;
                textBox_OldBalance.Text = fi.ToString("0.00");

                groupBox_FirstStep.Enabled  = false;
                groupBox_SecondStep.Visible = true;
                button_Retry.Enabled        = true;
                textBox_Value.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show("查询卡片余额失败( " + ex.Message + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

Eend:
            if (odt != null)
            {
                odt.Clear();
            }

            MyStart.oMyDb.Close();
        }
コード例 #4
0
ファイル: frm_Card_QryVal.cs プロジェクト: wl2019/EB_for_YTB
        private void button_CheckCard_Click(object sender, EventArgs e)
        {
            string  szInf   = "";
            string  sCardID = "";
            DataSet odt     = null;
            string  sErrMsg = "";

            if (!frm_Main.bHaveRd)
            {
                if (textBox_CardID.Text.Trim() != "")
                {
                    sCardID = textBox_CardID.Text;
                }
                else
                {
                    MessageBox.Show("没有连接读写器,也没有输入卡号,不能执行查询余额功能!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                if (!myRdr.ComOpen(frm_Main.sRdPort))
                {
                    myRdr.ComClose();
                    if (textBox_CardID.Text.Trim() != "")
                    {
                        sCardID = textBox_CardID.Text;
                    }
                    else
                    {
                        MessageBox.Show("打开串口失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                else
                {
                    if (!myRdr.ReadCardInf(out szInf))
                    {
                        if (textBox_CardID.Text.Trim() != "")
                        {
                            sCardID = textBox_CardID.Text;
                        }
                        else
                        {
                            MessageBox.Show("读卡失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            myRdr.ComClose();
                            goto Eend;
                        }
                    }
                    else
                    {
                        sCardID = szInf.Substring(0, 16);
                    }
                }
                myRdr.ComClose();
            }
            textBox_CardID.Text = sCardID;

            if (sCardID.Substring(0, 1) == MyStart.gszCardFirmFirst)
            {
                MessageBox.Show("不接受商户卡查询余额,请换卡!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                goto Eend;
            }

            try
            {
                string sSql = "";
                if (mszFlag.ToUpper() == "FIRM_CARD")
                {
                    sSql = "SELECT * FROM mng_card WHERE STORE_CARD = '" + sCardID + "' AND card_type = 3";
                }
                else  // if (mszFlag.ToUpper() == "USER_CARD")
                {
                    sSql = "SELECT * FROM base_ucard WHERE user_card = '" + sCardID + "'";
                }

                int iRst = MyStart.oMyDb.ReadData(sSql, "TableA", ref odt, ref sErrMsg);
                if (iRst != 0)
                {
                    MessageBox.Show("后台查询卡余额失败( " + sErrMsg + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    goto Eend;
                }

                if (odt.Tables[0].Rows.Count <= 0)
                {
                    if (mszFlag.ToUpper() == "FIRM_CARD")
                    {
                        MessageBox.Show("这是错误的商户结算卡,请更换。", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else  // if (mszFlag.ToUpper() == "USER_CARD")
                    {
                        MessageBox.Show("没有此用户卡的信息,请更换。", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    goto Eend;
                }

                if (mszFlag.ToUpper() == "FIRM_CARD")
                {
                    sUserName = odt.Tables[0].Rows[0]["STORE_PERSON"].ToString().Trim();
                }
                else  // if (mszFlag.ToUpper() == "USER_CARD")
                {
                    sUserName = odt.Tables[0].Rows[0]["user_name"].ToString().Trim();
                }

                //银石后台
                objHttp = new EbHttpClass();
                string szErr       = "";
                int    iValue      = 0;
                int    iTrade      = 0;
                int    CardBalance = 0;
                float  fi          = 0.00f;

                if (mszFlag.ToUpper() == "FIRM_CARD")
                {
                    iTrade = 1;
                }
                else
                {
                    iTrade = 0;
                }

                bool bRst = objHttp.QryCard(sCardID, ref iValue, ref iTrade, ref szErr);
                if (!bRst)
                {
                    MessageBox.Show("后台查询卡余额失败( " + szErr + " )", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //return;
                }
                else
                {
                    if (mszFlag.ToUpper() == "FIRM_CARD")
                    {
                        fi = iValue;
                        fi = fi / 100;
                        textBox_FinishBalance.Text = fi.ToString("0.00");

                        if (iTrade > 0)
                        {
                            fi = iTrade;
                        }
                        else
                        {
                            fi = 0;
                        }
                        fi = fi / 100;
                        textBox_UnFinishBalance.Text = fi.ToString("0.00");

                        CardBalance             = iValue + iTrade;
                        fi                      = CardBalance;
                        fi                      = fi / 100;
                        textBox_OldBalance.Text = fi.ToString("0.00");
                        MyFunc.WriteToDbLog("卖方资金-余额查询", " ", "MSG", MyStart.giUserID);
                    }
                    else
                    {
                        textBox_FinishBalance.Text   = "";
                        textBox_UnFinishBalance.Text = "";
                        fi = iValue;
                        fi = fi / 100;
                        textBox_OldBalance.Text = fi.ToString("0.00");
                        MyFunc.WriteToDbLog("买方资金-余额查询", " ", "MSG", MyStart.giUserID);
                    }

                    if (checkBox1.Checked)
                    {
                        int i = 0;
                        // 打印票据
                        MyTools.sPrintTopic = "余额查询票据";
                        MyTools.sPrintID    = "";

                        MyTools.oPrintData      = new string[10];
                        MyTools.oPrintData[i++] = "卡片号码:" + textBox_CardID.Text;
                        MyTools.oPrintData[i++] = "持卡人名:" + sUserName;
                        MyTools.oPrintData[i++] = "--------------------------------------";
                        MyTools.oPrintData[i++] = "可取金额:" + textBox_FinishBalance.Text;
                        MyTools.oPrintData[i++] = "未结余额:" + textBox_UnFinishBalance.Text;
                        MyTools.oPrintData[i++] = "合计余额:" + textBox_OldBalance.Text;

                        MyTools.iPrintData = i;
                        MyTools.PrintTicket();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("查询失败 = " + ex.Message, "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

Eend:
            if (odt != null)
            {
                odt.Clear();
            }
            MyStart.oMyDb.Close();

            button_CheckCard.Focus();
        }