Exemple #1
0
        private void btnRegister_Click(object sender, EventArgs e)
        {
            string user_id  = txtUser.Text.Trim();
            string user_pwd = Program.md5(txtPwd.Text);
            string ip_addr  = txtIp_addr.Text.Trim();
            string mac_addr = txtMac_addr.Text.Trim();
            UserinfoServiceSoapClient us = new UserinfoServiceSoapClient();

            try
            {
                string message = us.Register(user_id, user_pwd, ip_addr, mac_addr);
                if (message == "true")
                {
                    MessageBox.Show("恭喜,注册成功!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("注册信息格式不正确", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (FaultException)
            {
                MessageBox.Show("用户名已经注册过啦", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                // MessageBox.Show(faultEx.Message, "异常");
            }
        }
Exemple #2
0
        public void UpdateDate(string user_id)
        {
            //DateTime DT = System.DateTime.Now;
            string dt = System.DateTime.Now.ToString();
            UserinfoServiceSoapClient us = new UserinfoServiceSoapClient();

            us.UpdateDate(dt, user_id);
        }
Exemple #3
0
        public string GetLastDate(string user_id)
        {
            UserinfoServiceSoapClient us = new UserinfoServiceSoapClient();
            string dt = us.GetLastDate(user_id);

            if (dt == "")
            {
                return("此次为首次登录");
            }
            return(dt);
        }
Exemple #4
0
        private static void Res(string user_id, string user_pwd, string ip_addr, System.ComponentModel.BackgroundWorker backgroundWorker)
        {
            //加密
            user_pwd = Commons.EncodeHelper.AES_Encrypt(user_pwd);

            //实例化
            UserinfoServiceSoapClient us = new UserinfoServiceSoapClient();
            string message = us.Register(user_id, user_pwd, ip_addr);

            MessageBox.Show(message, "信息提示", MessageBoxButton.OK, MessageBoxImage.Information);
        }
Exemple #5
0
        private static bool Login(string user_id, string user_pwd, int IDtype, System.ComponentModel.BackgroundWorker backgroundWorker)
        {
            //获取本机ip地址

            string      ip_addr  = string.Empty;
            string      HostName = Dns.GetHostName();//得到主机名;
            IPHostEntry IpEntry  = Dns.GetHostEntry(HostName);

            for (int i = 0; i < IpEntry.AddressList.Length; i++)
            {
                if (IpEntry.AddressList[i].AddressFamily == AddressFamily.InterNetwork)
                {
                    ip_addr = IpEntry.AddressList[i].ToString();
                }
            }

            //加密
            user_pwd = Commons.EncodeHelper.AES_Encrypt(user_pwd);
            //数据库验证
            UserinfoServiceSoapClient us = new UserinfoServiceSoapClient();
            string message = "";

            if (IDtype == 0)
            {
                message = us.Login(user_id, user_pwd, ip_addr);
            }
            else
            {
                message = us.LoginSal(user_id, user_pwd);
            }
            if (string.IsNullOrEmpty(message))
            {
                if (IDtype == 0)
                {
                    WpfMain.user_type = "管理员";
                    WpfMain.user_id   = user_id;
                }
                else
                {
                    WpfMain.user_type = "员工";
                    WpfMain.user_id   = user_id;
                }

                return(true);
                //DialogResult = Convert.ToBoolean(1);
            }
            else
            {
                MessageBox.Show(message, "信息提示", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
        }
        private void btnEnter_Click(object sender, EventArgs e)
        {
            string user_id = textUser.Text.Trim();

            string user_pwd = textPwd.Text;
            UserinfoServiceSoapClient us = new UserinfoServiceSoapClient();
            bool flag = us.Register(user_id, user_pwd, "");

            if (flag)
            {
                MessageBox.Show("注册成功", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("注册失败,用户名或密码错误", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #7
0
        public static string user_id;//保存用户名
        private void Login()
        {
            user_id = txtUser.Text.Trim();
            string user_pwd = Program.md5(txtPwd.Text);
            //获取本地IP地址
            string      ip_addr  = string.Empty;      //局部变量记得赋值
            string      HostName = Dns.GetHostName(); //得到主机名
            IPHostEntry IpEntry  = Dns.GetHostEntry(HostName);

            for (int i = 0; i < IpEntry.AddressList.Length; i++)
            {
                //从IP地址列表筛选出IPv4类型的IP地址
                //AddressFamily.InterNetwork表示为Ipv4
                //AddressFamily.InterNetworkV6表示IPv6
                if (IpEntry.AddressList[i].AddressFamily == AddressFamily.InterNetwork)
                {
                    ip_addr = IpEntry.AddressList[i].ToString();
                }
            }

            UserinfoServiceSoapClient us = new UserinfoServiceSoapClient();
            string flag;

            flag = us.Login(user_id, user_pwd, ip_addr);
            //FrmMain.user_group = "A";
            if (flag == "true")
            {
                // FrmMain.user_id = user_id;
                MessageBox.Show("登陆成功", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
            else
            {
                if (flag == "login_false")
                {
                    MessageBox.Show("登陆失败,用户名或密码错误", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("IP地址受限,登录失败", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemple #8
0
        //登录按钮
        private void button1_Click(object sender, EventArgs e)
        {
            string user_id = txtUser.Text.Trim();//读取user_id不包含空格

            string user_pwd = txtPwd.Text;
            UserinfoServiceSoapClient us = new UserinfoServiceSoapClient();
            bool flag = us.Login(user_id, user_pwd);

            if (flag)
            {
                //MessageBox.Show("登录成功","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
                FrmMain frm = new FrmMain();//跳转到主界面
                frm.Show();
                //this.Close();
            }
            else
            {
                MessageBox.Show("登录失败,用户名或密码错误", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }