Exemplo n.º 1
0
        private void LoginButton_Click(object sender, EventArgs e)
        {
            string       loginMsg = string.Empty;
            LoginControl login    = new LoginControl();
            string       username = userNametextBox.Text.ToString();
            string       password = passWordtextBox.Text.ToString();
            DataSet      ds       = login.Login(username, password);

            if (ds != null && ds.Tables.Count > 0)
            {
                if (ds.Tables[0].Rows.Count == 0)
                {
                    loginMsg = "账户不存在或密码错误"; //账户不存在或密码错误
                    MessageBox.Show(loginMsg);
                }
                else
                {
                    int userIdNow = Convert.ToInt32(ds.Tables[0].Rows[0]["UserId"]);
                    int empId     = Convert.ToInt32(ds.Tables[0].Rows[0]["EmpId"]);
                    if (userIdNow == Convert.ToInt32(Params.User.Id))
                    {
                        MessageBox.Show("请输入其他账户进行交接班!");
                        return;
                    }

                    string            empName    = Convert.ToString(ds.Tables[0].Rows[0]["EmpName"]);
                    ChargeOnDutyModel modereturn = login.SaveChargeOnDuty(2, Convert.ToInt32(userId), workNo);
                    if (modereturn.returnResult != 1000)
                    {
                        MessageBox.Show("交接班上传数据保存失败,请联系管理员!");
                    }

                    ChargeOnDutyModel mode = login.SaveChargeOnDuty(1, userIdNow, "");

                    //2019-02-15和LoginForm一样处理
                    if (HandleLogin != null)
                    {
                        HandleLogin(empName, userIdNow, empId, mode);
                    }

                    this.Dispose();
                }
            }
        }
Exemplo n.º 2
0
        private void login_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(usernameInput.Text))
            {
                usernameInput.Focus();
                return;
            }
            if (string.IsNullOrEmpty(passwordInput.Text))
            {
                passwordInput.Focus();
                return;
            }
            string       loginMsg = string.Empty;
            LoginControl login    = new LoginControl();
            string       username = usernameInput.Text.ToString();
            string       password = passwordInput.Text.ToString();
            DataSet      ds       = login.Login(username, password);

            if (ds != null && ds.Tables.Count > 0)
            {
                if (ds.Tables[0].Rows.Count == 0)
                {
                    loginMsg = "账户不存在或密码错误"; //账户不存在或密码错误
                    MessageBox.Show(loginMsg);
                }
                else
                {
                    int               userId  = Convert.ToInt32(ds.Tables[0].Rows[0]["UserId"]);
                    int               empId   = Convert.ToInt32(ds.Tables[0].Rows[0]["EmpId"]);
                    string            empName = Convert.ToString(ds.Tables[0].Rows[0]["EmpName"]);
                    ChargeOnDutyModel mode    = login.SaveChargeOnDuty(1, userId, "");


                    //2019-02-14由固定传递Form1改为委托实现
                    if (HandleLogin != null)
                    {
                        HandleLogin(empName, userId, empId, mode);
                    }
                    this.Dispose();
                }
            }
        }