通讯平台登陆代码

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;

using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;

namespace PrintStock
{
    public partial class Login : Form
    {
        public Login()
        {
            InitializeComponent();
        }

        private void Login_Load(object sender, EventArgs e)
        {
            this.Height = 180;
            //通讯平台地址
            ipBox1.Text = SetConfig.GetConfigString("", "ConnIP");
            //通讯平台端口
            txtPort.Text = SetConfig.GetConfigString("", "ConnPort");
        }
        /// <summary>
        /// 打开配置 按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSet_Click(object sender, EventArgs e)
        {
            if (this.Height == 180)
            {
                this.Height = 320;
                btnSet.Text = "关闭配置";
            }
            else
            {
                this.Height = 180;
                btnSet.Text = "打开配置";
            }
        }
        /// <summary>
        /// 登录按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtUserName.Text.Trim()))//判断操作员是否为空
            {
                if (!string.IsNullOrEmpty(txtPwd.Text.Trim()))//判断密码是否为空
                {
                    //passWord用来接收从数据库中读取的加密过的密码
                    string passWord = TradeDAL.Stock.GetSQL_GetOperatorPwd(Convert.ToInt32(txtUserName.Text.Trim()));
                    //调用CallDll程序集中的方法进行判断此操作员系信息是否在数据库中记录
                    //MessageBox.Show("密码:"+passWord+"\n帐号:" + txtUserName.Text + "\n密码:" + txtPwd.Text + "\n返回结果:" + CallDll.Form1.CheckPassword1(short.Parse(txtUserName.Text.Trim()), txtPwd.Text.Trim(), passWord));
                    if (CallDll.Form1.CheckPassword1(short.Parse(txtUserName.Text.Trim()), txtPwd.Text.Trim(), passWord) == 100)
                    {
                        PrintStockList fo = new PrintStockList();
                        fo.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("密码错误!");
                    }
                }
                else
                {
                    MessageBox.Show("请输入密码!");
                }
            }
            else
            {
                MessageBox.Show("请输入操作员!");
            }
        }
        /// <summary>
        /// 取消按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        /// <summary>
        /// 通讯平台端口  输入
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtPort_KeyPress(object sender, KeyPressEventArgs e)
        {
            Regex reg = new Regex(@"\d");//正则判断是数字
            if (!reg.IsMatch(e.KeyChar.ToString()))//判断输入的是否匹配数字
                e.Handled = true;
        }
        /// <summary>
        /// 通讯平台地址输入完毕后
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ipBox1_Leave(object sender, EventArgs e)
        {
            SetConfig.SetConfigKeyValue("appSettings", "ConnIP", ipBox1.Text);
        }
        /// <summary>
        /// 当在通讯平台端口输入完毕后
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtPort_Leave(object sender, EventArgs e)
        {
            SetConfig.SetConfigKeyValue("appSettings", "ConnPort", txtPort.Text);
        }


        //private byte[] GetDesSourceCode(int op_code, string password, char[] ret_code)
        //{

            //char[] original_data = new char[2048];
            //char[] target_data = new char[2048];
            //string szCmd = "";
            //string source = "中华人民共和国中央人民广播电台";
            //original_data = password.ToCharArray();
            //long num = 0;
            //for (int i = 0; i < password.Length; i++)
            //{ 
            //    szCmd
            //}
        //}
    }
}


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值