예제 #1
0
        //连接读卡机
        private static bool connect_card_machine(string cardType)
        {
            if (icdev > 0)
            {
                if (cardType == "SLE4442")
                {
                    IC.ic_exit(icdev);
                }
                else if (cardType == "M1")
                {
                    ICRF.rf_exit(icdev);
                }
            }

            string card_port = BathClass.get_config_by_key("card_port");
            string card_baud = BathClass.get_config_by_key("card_baud");
            string no_hint   = BathClass.get_config_by_key("no_hint");

            if ((card_port == "" || card_baud == "") && (no_hint == "" || no_hint == "false"))
            {
                CardPortBaudForm cardPortBaudForm = new CardPortBaudForm();
                if (cardPortBaudForm.ShowDialog() != DialogResult.OK)
                {
                    return(false);
                }

                card_port = cardPortBaudForm.card_port.ToString();
                card_baud = cardPortBaudForm.card_baud.ToString();
            }

            if (card_port == "" || card_baud == "")
            {
                return(false);
            }

            Int16 port = Convert.ToInt16(card_port);
            int   baud = Convert.ToInt32(card_baud);

            if (cardType == "SLE4442")
            {
                icdev = IC.ic_init(port, baud);
            }
            else if (cardType == "M1")
            {
                icdev = ICRF.rf_init(port, baud);
            }
            if (icdev <= 0)
            {
                BathClass.printErrorMsg("连接读卡器失败,请重试!");
                return(false);
            }
            return(true);
        }
예제 #2
0
        //对话框载入
        private void LogIn_Load(object sender, EventArgs e)
        {
            connectionIP = BathClass.get_config_by_key("connectionIP");
            if (connectionIP == "")
            {
                PCListForm pCListForm = new PCListForm();
                if (pCListForm.ShowDialog() != DialogResult.OK)
                {
                    this.Close();
                    return;
                }
                connectionIP = pCListForm.ip;
                BathClass.set_config_by_key("connectionIP", connectionIP);
            }

            db = new BathDBDataContext(connectionString);

            if (!db.DatabaseExists())
            {
                BathClass.printErrorMsg("连接IP不对或者网络不通,请重试!");
                connectionIP = "";
                BathClass.set_config_by_key("connectionIP", connectionIP);
                this.Close();
                return;
            }
            if (!RegisterForm.registered())
            {
                hasRegistered = false;
            }

            if (hasRegistered)
            {
                register.Visible = false;
            }
            else if (!hasRegistered && !checkTrialTimes())
            {
                okBtn.Enabled = false;
            }

            read_users();
            id.Items.AddRange(idList.ToArray());
            if (id.Items.Count != 0)
            {
                id.Text = id.Items[0].ToString();
            }
        }
예제 #3
0
        private void send_sms(string cardno)
        {
            try
            {
                //var dc = new BathDBDataContext(LogIn.connectionString);
                var ci = db.CardInfo.FirstOrDefault(x => x.CI_CardNo == cardno);
                if (ci.CI_Telephone == null || ci.CI_Telephone.Length != 11)
                {
                    return;
                }

                var mt = db.MemberType.FirstOrDefault(x => x.id == ci.CI_CardTypeNo);
                if (!BathClass.ToBool(mt.smsAfterUsing))
                {
                    return;
                }

                string msg = "尊敬的贵宾,您好!";
                msg += "您的" + mt.name + ",卡号:" + ci.CI_CardNo + ",";
                var cc            = db.CardCharge.Where(y => y.CC_CardNo == ci.CI_CardNo);
                var debit         = cc.Sum(y => y.CC_DebitSum);
                var lend          = cc.Sum(y => y.CC_LenderSum);
                var cu            = db.MemberSetting.FirstOrDefault().money;
                var balance_money = Convert.ToDouble(debit - lend);
                msg += "余额为:" + balance_money.ToString();

                if (mt.credits)
                {
                    var cexpense = db.CardCharge.Where(y => y.CC_CardNo == ci.CI_CardNo);
                    var cvs      = cexpense.Sum(y => y.expense);
                    if (cvs.HasValue)
                    {
                        double cds = cvs.Value;
                        if (ci.CI_CreditsUsed == null)
                        {
                            msg += "积分为:" + (cds / cu).ToString();
                        }
                        else
                        {
                            msg += "积分为:" + (cds / cu - ci.CI_CreditsUsed).ToString();
                        }
                    }
                }

                String TypeStr        = "";
                String CopyRightToCOM = "";
                String CopyRightStr   = "//上海迅赛信息技术有限公司,网址www.xunsai.com//";
                string smsPort        = BathClass.get_config_by_key("smsPort");
                string smsBaud        = BathClass.get_config_by_key("smsBaud");
                if (smsPort == "" || smsBaud == "")
                {
                    SMmsForm smsForm = new SMmsForm();
                    if (smsForm.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }

                    smsPort = BathClass.get_config_by_key("smsPort");
                    smsBaud = BathClass.get_config_by_key("smsBaud");
                }

                if (smsPort == "" || smsBaud == "")
                {
                    return;
                }

                //SmsClass.Sms_Disconnection();
                if (SmsClass.Sms_Connection(CopyRightStr, uint.Parse(smsPort[3].ToString()), uint.Parse(smsBaud), out TypeStr, out CopyRightToCOM) != 1)
                {
                    return;
                }

                SmsClass.Sms_Send(ci.CI_Telephone, msg);
                SmsClass.Sms_Disconnection();
            }
            catch
            {}
        }