Exemplo n.º 1
0
 private void OperatorForm_KeyDown(object sender, KeyEventArgs e)
 {
     Config cfg = new Config();
     if (e.KeyValue.ToString() == cfg.getCancelKeyValue()) //检查是否取消了交易
     {
         this.Close();
     }
     else if (e.KeyCode == Keys.NumPad1) // 结算
     {
         do_settlement();
     }
     else if (e.KeyCode == Keys.NumPad2) // 操作员改密码
     {
         do_change_password();
     }
     else if (e.KeyCode == Keys.NumPad3) // 添加操作员
     {
         do_add_operator();
     }
 }
Exemplo n.º 2
0
        private void OthersForm_KeyDown(object sender, KeyEventArgs e)
        {
            //检查是否取消了交易
            Config cfg = new Config();
            if (e.KeyValue.ToString() == cfg.getCancelKeyValue())
            {
                this.Close();
            }

            switch (e.KeyCode)
            {
                case Keys .NumPad1:
                    do_settlement();
                    break;
                case Keys .NumPad2:
                    do_bind_member();
                    break;
            }
        }
Exemplo n.º 3
0
        private void InputForm_KeyDown(object sender, KeyEventArgs e)
        {
            Config cfg = new Config();
            if (e.KeyValue.ToString() == cfg.getCancelKeyValue()) //按下了交易取消键
            {
                MainForm.trans .Is_Canceled = true;
                this.InitPara();
                this.Close();
            }

            //根据不同的输入类型来进行不同的操作
            switch (inputType) {
                case "password": //密码
                    if (e.KeyCode == Keys.Enter)
                    {
                        MainForm.trans.Password = this.textBox1.Text.Trim();
                        this.Close();
                    }
                    else if(this.isKeyInNumRange(e)  && this.textBox1 .Text .Length < 20)
                    {
                        this.Password += this.getNumKeyFace(e);
                        this.textBox1.Text =this.Password;
                    }
                    break;
                case "newpassword": //新密码
                    if (e.KeyCode == Keys.Enter)
                    {
                        MainForm.newPasswrod = this.textBox1.Text.Trim();
                        this.Close();
                    }
                    else if(this.isKeyInNumRange(e)  && this.textBox1 .Text .Length < 20)
                    {
                        this.newpassword += this.getNumKeyFace(e);
                        this.textBox1.Text = this.newpassword;
                    }
                    break;
                case "repassword": //重新输入一遍密码
                    if (e.KeyCode == Keys.Enter)
                    {
                        MainForm.rePasswrod = this.textBox1.Text.Trim();
                        this.Close();
                    }
                    else if(this.isKeyInNumRange (e)  && this.textBox1 .Text .Length < 20)
                    {
                        this.repassword += this.getNumKeyFace(e);
                        this.textBox1.Text = this.repassword;
                    }
                    break;
                case "card": //刷卡
                    if (e.KeyCode == Keys.Enter)
                    {
                        if (this.textBox1.Text.Trim().Length == 18) //输入的卡号需是18位
                        {
                            MainForm.trans.Card_No = this.textBox1.Text.Trim();
                            this.Close();
                        }
                    }
                    break;
                case "batch_no": // 批次号输入
                    if (this.isKeyInNumRange(e))
                    {
                        this.batch_no += this.getNumKeyFace(e);
                        this.textBox1.Text = this.batch_no;
                    }
                    else if (e.KeyCode == Keys.Enter)
                    {
                        MainForm.trans.Old_Batch_No = this.textBox1.Text.Trim();
                        this.Close();
                    }
                    break;
                case "trace_no": //流水号输入
                    if (this.isKeyInNumRange(e) && this.textBox1 .Text .Length < 20)
                    {
                        this.trace_no += this.getNumKeyFace(e);
                        this.textBox1.Text = this.trace_no;
                    }
                    else if (e.KeyCode == Keys.Enter)
                    {
                        MainForm.trans.Old_Trace_No = this.textBox1 .Text .Trim ();
                        this.Close();
                    }
                    break;
                case "point": //积分输入
                    if (this.textBox1.Text.Trim() == "")
                    {  //第一个输入的字符不能是"0"
                        if (e.KeyValue >= 97 && e.KeyValue <= 105)
                        {
                            this.point += this.getNumKeyFace(e);
                            this.textBox1.Text = this.point;
                        }
                    }
                    else
                    {
                        if (this.isKeyInNumRange(e))
                        {
                            this.point += this.getNumKeyFace(e);
                            this.textBox1.Text = this.point;
                        }
                    }
                    if (e.KeyCode == Keys.Enter)
                    {
                        if (this.textBox1.Text.Trim() != "")
                        {
                            MainForm.trans.Amount = this.textBox1.Text.Trim();
                            this.Close();
                        }
                    }
                    break;
                case "amount": //金额输入
                    if (e.KeyCode == Keys.Enter)
                    {
                        if (this.textBox1.Text.Trim() != "0.00")
                        {
                            MainForm.trans.Amount = amount;
                            this.Close();
                        }
                    }
                    else if (this.isKeyInNumRange(e))
                    {
                        amount = amount + this.getNumKeyFace(e);
                        //amount  = amount.Replace(".", "").ToLower().Replace("numpad", "").Trim();
                        //检查money是否以"0"开头,如果允许以"0"开头的话则会出现"000000.00"格式的金额
                        if (amount.Substring(0, 1).ToString() == "0")
                        {
                            amount = amount.Substring(1, amount.Length - 1);
                        }
                        //每输入一个数字则清空一次输入框,并赋予其新的金额数值
                        switch (amount.Trim().Length)
                        {
                            case 0:
                                this.textBox1.Text = "0.00";
                                break;
                            case 1:
                                this.textBox1.Text = "0.0" + amount;
                                break;
                            case 2:
                                this.textBox1.Text = "0." + amount;
                                break;
                            default:
                                this.textBox1.Text = amount.Insert(amount.Length - 2, ".");
                                break;
                        }
                    }
                    break;
                case "date": //日期输入
                    if (e.KeyCode == Keys.Enter)
                    {
                        if (this.textBox1.Text.Trim().Length != 8) //长度不为8则格式不正确
                        {
                            return;
                        }
                        else
                        {
                            if (!IsDate(this.textBox1.Text.Trim().Insert(4, "-").Insert(7, "-"))) //不符合日期格式不正确
                            {
                                return;
                            }
                            else
                            {
                                MainForm.trans.Overdue_Date = this.textBox1.Text.Trim();
                                this.Close();
                            }
                        }
                    }
                    else if (this.isKeyInNumRange(e))
                    {
                        this.date += this.getNumKeyFace(e);
                        this.textBox1.Text = this.date;
                    }
                    break;
            }
        }
Exemplo n.º 4
0
 private void PointsForm_KeyDown(object sender, KeyEventArgs e)
 {
     //检查是否取消了交易
     Config cfg = new Config();
     if (e.KeyValue.ToString() == cfg.getCancelKeyValue())
     {
         this.Close();
     }
     else if (e.KeyCode == Keys.NumPad1) //积分消费
     {
         do_points_payment();
     }
     else if (e.KeyCode == Keys.NumPad2) //积分充值(积分累计)
     {
         do_points_deposit();
     }
 }
Exemplo n.º 5
0
        private void SignInForm_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                String operator_no = this.textBox_operator_no.Text.Trim();
                String operator_password = this.textBox_operator_password.Text.Trim();
                if (operator_password == "")
                {
                    this.textBox_operator_password.Focus();
                    return;
                }
                if (operator_no == "")
                {
                    this.textBox_operator_no.Focus();
                    return;
                }

            //                DB db = new DB();
            //                String sql = "SELECT * FROM operators WHERE operator_no ='" + operator_no + "' AND password = '******'";
            //                SQLiteDataReader dr = db.ExecuteReturnSQL(sql);
            //                if (dr == null)
            //                {
            //                    MessageBox.Show("未知错误,请联系软件提供商");
            //                    return;
            //                }
            //                if (dr.HasRows == true)
            //                {
                    //签到交易包

                    MainForm.trans.init();
                    Config cfg = new Config();

                    MainForm.trans.Action = "singin";
                    MainForm.trans.Operator_Account = operator_no;
                    MainForm.trans.Operator_Password = CoolCard.Security.MD5Encrypt(operator_password);
                    string transString = MainForm.trans.Build_Trans_String();

                    MySocket mSocket = new MySocket();
                    string rtnString = mSocket.Send(transString);

                    //处理返回结果
                    rtnString = rtnString.Replace(@"""", "").Replace("'", "").Replace("{", "").Replace("}", "");
                    string[] tmp_arr1 = rtnString.Split(',');
                    string[] tmp_arr2;
                    Hashtable hashTable = new Hashtable();
                    for (int i = 0; i < tmp_arr1.Length; i++)
                    {
                        tmp_arr2 = tmp_arr1[i].ToString().Split(':');
                        hashTable.Add(tmp_arr2[0].ToString(), tmp_arr2[1].ToString());
                    }
                    //如果返回成功,则更新本地数据表中的交易记录状态为"s"
                    string trans_date = "";
                    string trans_time = "";
                    string result_code = "";
                    int batch_no = 0;
                    int tracte_no = 0;
                    foreach (DictionaryEntry de in hashTable)
                    {
                        if (de.Key.ToString().Trim() == "result_code")
                        {
                            result_code = de.Value.ToString().Trim();
                        }
                        if (de.Key.ToString().Trim() == "trans_date")
                        {
                            trans_date = de.Value.ToString().Trim();
                        }
                        if (de.Key.ToString().Trim() == "trans_time")
                        {
                            trans_time = de.Value.ToString().Trim();
                        }
                        if (de.Key.ToString().Trim() == "batch_no")
                        {
                            batch_no = Convert.ToInt32(de.Value.ToString());
                        }
                        if(de.Key.ToString().Trim() == "trace_no")
                        {
                            tracte_no = Convert.ToInt32(de.Value.ToString());
                        }
                    }

                    if (result_code == "0")
                    {
                        MainForm.login = true;
                        MainForm.current_operator = operator_no;
                        DB db = new DB();
                        db.ExecuteNoReturnSQL(String.Format("UPDATE settings SET val = '{0}' WHERE setting = 'current_batch_no'", batch_no.ToString()));
                        db.ExecuteNoReturnSQL(String.Format("UPDATE settings SET val = '{0}' WHERE setting = 'current_trace_no'", tracte_no.ToString()));
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show(result_code.ToString() + ":" + CoolCard .Config .GetConfig ("ERRORCODE", result_code, ""), "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
            //                }
            //                else
            //                {
            //                    MessageBox.Show("操作员不存在或密码错");
            //                }
            }
            else if (e.KeyCode == Keys.Escape)
            {
                MainForm.loginCanceled = true;
                MainForm.login = true;
                this.Close();
            }
        }