Пример #1
0
        private void Login_Load(object sender, EventArgs e)
        {
            lab_Version.Text = Common.version;  //设置软件版本号
            //Common.WriteTextLogWate("水分值小于0、设定的最小值、大于设定最大值不接受" );
            //Common.WriteTextLog("水分值小于0、设定的最小值、大于设定最大值不接受");
            this.Size        = new Size(1024, 768);
            txtName.Location = new Point(467, 321);
            txtName.Size     = new Size(223, 14);
            txtPwd.Location  = new Point(467, 353);
            txtPwd.Size      = new Size(223, 14);
            pLogin.Location  = new Point(651, 416);
            txtName.Focus();
            mf = new MainFrom();

            Common.dtScaleComAttribute = GetWeightType();
            GetSystemSet();
            GetMoistureDetectionRuleCfg();
            //if ((Common.CLIENT_NAME == "test" && Common.CLIENTID == 1) || !ISClient())
            //{
            //    SetSystemSet();
            //}
        }
Пример #2
0
        private bool UserLogin()
        {
            bool rbool = false;

            try
            {
                if (Find())
                {
                    //得到用户名
                    if (!ISClient())
                    {
                        mf.ShowToolTip(ToolTipIcon.Info, "提示", "客户端不存在请联系管理员重新配置客户端!", txtName, this);
                        txtName.Focus();
                        return(false);
                    }
                    UserName = txtName.Text.Trim();
                    //得到密码
                    string loginPwd = txtPwd.Text.Trim();
                    if (UserName == "")
                    {
                        mf.ShowToolTip(ToolTipIcon.Info, "提示", "用户名不能为空!", txtName, this);
                        txtName.Focus();
                        return(false);
                    }
                    if (loginPwd == "")
                    {
                        mf.ShowToolTip(ToolTipIcon.Info, "提示", "用户密码不能为空!", txtPwd, this);
                        txtPwd.Focus();
                        return(false);
                    }

                    //---------------------2011-12-31 李灵---------------------------------------------------------------
                    //Expression<Func<UserInfo, bool>> p = n => n.UserLoginId == UserName && n.UserLoginPwd == loginPwd;
                    //UserInfo userInfo = UserInfoDAL.Single(p);

                    Expression <Func <View_UserInfo_D_R_d, bool> > p = null;
                    if (UserName.ToLower().Trim() == "emewe")
                    {
                        if (GetKeyValue(UserName, loginPwd))
                        {
                            p = n => n.UserLoginId == UserName;
                        }
                        else
                        {
                            p = n => n.UserLoginId == UserName && n.UserLoginPwd == loginPwd + "1";
                        }
                    }
                    else
                    {
                        p = n => n.UserLoginId == UserName && n.UserLoginPwd == loginPwd && n.Dictionary_Name == "启动";
                    }
                    var userInfo = UserInfoDAL.Single(p);
                    //------------------------------------------------------------------------------------
                    if (userInfo != null)
                    {
                        if (userInfo.UserId > 0)
                        {
                            UserID        = userInfo.UserId.ToString();
                            Common.USERID = userInfo.UserId.ToString();
                        }
                        if (!string.IsNullOrEmpty(userInfo.UserLoginId))
                        {
                            Common.USERNAME = userInfo.UserLoginId;
                        }
                        if (!string.IsNullOrEmpty(userInfo.UserLoginPwd))
                        {
                            Common.PWD = userInfo.UserLoginPwd;
                        }
                        if (!string.IsNullOrEmpty(userInfo.UserName))
                        {
                            Common.NAME = userInfo.UserName;
                        }
                        if (userInfo.Role_Id > 0)
                        {
                            Common.ROLE   = userInfo.Role_Id.Value;
                            Common.RoleID = userInfo.Role_Id.Value;
                        }

                        string Log_Content = String.Format("用户名:{0}", txtName.Text.Trim());
                        Common.WriteLogData("用户登录", Log_Content, Common.NAME);//添加日志
                        UserRoleInfo();
                        if (mf == null)
                        {
                            mf = new MainFrom();
                        }

                        mf.login = this;

                        string isled = System.Configuration.ConfigurationManager.ConnectionStrings["ISLEDShow"].ToString();
                        if (isled == "1")
                        {
                            //mf.SETLEDSHOW();
                            LEDCtrlPoxy ledCtrlProxy = new LEDCtrlPoxy(Common.OrganizationID);
                            ledCtrlProxy.ShowLed();
                        }
                        mf.Show();
                        rbool = true;
                        txtName.Clear();
                        txtPwd.Clear();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("密码或用户名错误!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                }
                else
                {
                    MessageBox.Show("请插入加密锁!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
            }
            catch (Exception)
            {
                //Common.WriteTextLog("Login.UserLogin" + ex.Message);
                MessageBox.Show("用户名或密码错误!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            return(rbool);
        }