Exemple #1
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            //用户登录 获取用户的账号和密码并判断
            DataTable ret = service.UserService.UserExists(comboBox1.Text, txtPassword.Text);

            if (ret.Rows.Count == 1)
            {  //获取当前登录用户的机构
                organCode = ret.Rows[0]["organ_code"].ToString();

                name  = this.comboBox1.Text;
                passw = this.txtPassword.Text;

                bean.loginLogBean lb = new bean.loginLogBean();
                lb.name       = name;
                lb.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                lb.eventInfo  = "登录系统!";
                if (lb.name != "admin" && lb.name != "" && lb.name != null)
                {
                    lls.addCheckLog(lb);
                }
                this.Hide();

                frmMain1 main = new frmMain1();
                main.Show();
            }
            else
            {
                MessageBox.Show("用户名或密码错误!");
            }
        }
Exemple #2
0
        private void 系统退出ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("是否确认退出?", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                service.loginLogService llse = new service.loginLogService();
                bean.loginLogBean       lb   = new bean.loginLogBean();
                lb.name       = frmLogin.name;
                lb.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                lb.eventInfo  = "退出系统!";
                if (lb.name != "admin" && lb.name != "" && lb.name != null)
                {
                    llse.addCheckLog(lb);
                }
                System.Environment.Exit(0);
            }
        }
Exemple #3
0
        private void LoginSys()
        {
            loginname = this.comboBox1.Text;
            if (loginname == "admin")
            {
                DataTable sumret = service.UserService.sumUser();
                if (sumret != null && sumret.Rows.Count >= 1)
                {
                    DialogResult rr = MessageBox.Show("未初始化数据,是否继续?", "操作提示", MessageBoxButtons.YesNo);
                    int          tt = (int)rr;
                    if (tt == 7)
                    {
                        return;
                    }
                }
            }
            passw = this.txtPassword.Text;
            string md5passw = Md5.HashString(passw);
            //特殊处理下用户名
            string username = "";

            try
            {
                DataRowView dv = comboBox1.Items[comboBox1.SelectedIndex] as DataRowView;
                username = dv.Row["username"].ToString();
            }
            catch
            {
                username = comboBox1.Text;
            }
            //用户登录 获取用户的账号和密码并判断
            //DataTable ret = service.UserService.UserExists(comboBox1.Text, txtPassword.Text);
            DataTable ret = service.UserService.UserExists(username, md5passw);

            if (ret.Rows.Count > 0)
            {  //获取当前登录用户的机构
                userCode = ret.Rows[0]["user_code"].ToString();
                if (!"admin".Equals(username))
                {
                    organCode = ret.Rows[0]["organ_code"].ToString();

                    if (udao.checkOrganNameBycode(organCode) == null || udao.checkOrganNameBycode(organCode).Rows.Count <= 0)
                    {
                    }
                    else
                    {
                        organName = udao.checkOrganNameBycode(organCode).Rows[0]["organ_name"].ToString();
                    }
                }
                loginname = ret.Rows[0]["username"].ToString();
                name      = ret.Rows[0]["user_name"].ToString();
                user_Name = name;
                bean.loginLogBean lb = new bean.loginLogBean();
                lb.name       = name;
                lb.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                lb.eventInfo  = "登录系统!";
                lb.type       = "1";
                if (lb.name != "admin" && lb.name != "" && lb.name != null)
                {
                    lls.addCheckLog(lb);
                }
                /************/
                string fpath = Application.StartupPath + "\\sysstem.ini";
                sysstem.UpdateInfo(fpath);

                string   spath = Application.StartupPath + "/log.txt";
                FileInfo f     = new FileInfo(spath);
                double   fm    = f.Length / 1024.0 / 1024.0;
                if (fm >= 1)   //文件大于1M就删除掉
                {
                    File.WriteAllText(spath, string.Empty);
                }
                /*****end******/
                this.Hide();
                int m_nWindwMetricsY = GetWindwMetricsY();
                Common.m_nWindwMetricsY = m_nWindwMetricsY;
                if (m_nWindwMetricsY <= 900)
                {
                    frmMainm main = new frmMainm();
                    main.Show();
                }
                else
                {
                    frmMainmm main = new frmMainmm();
                    main.Show();
                }
            }
            else
            {
                MessageBox.Show("用户名或密码错误!");
            }
        }