Ejemplo n.º 1
0
        private void OnLogout(object sender, EventArgs e)
        {
            L3Session.Close();

            labelUser.Text             = "未登录";
            menuLogin.Enabled          = true;
            menuChangePassWord.Enabled = false;
            menuLogout.Enabled         = false;

            l3DataBoxTeamID.Text  = "";
            l3DataBoxShiftID.Text = "";

            L3DataAdapter.ReCheckAccessRights();
        }
Ejemplo n.º 2
0
 private void timer3_Tick(object sender, EventArgs e)
 {
     try
     {
         if (L3Session.Opened)
         {
             if (existms() == "否")
             {
                 timer3.Enabled = false;
                 L3Session.Close();
                 labelUser.Text             = "未登录";
                 menuLogin.Enabled          = true;
                 menuChangePassWord.Enabled = false;
                 menuLogout.Enabled         = false;
                 l3DataBoxTeamID.Text       = "";
                 l3DataBoxShiftID.Text      = "";
                 L3DataAdapter.ReCheckAccessRights();
             }
         }
     }
     catch
     {
     }
 }
Ejemplo n.º 3
0
        private void OnLogin(object sender, EventArgs e)
        {
            ConnectionStringSettings conn = frmConfigConnection.GetCurrentConnection();
            if (conn == null)
            {
                MessageBox.Show("没有配置服务!请先配置服务的连接。");
                return;
            }
            string connstr = conn.ConnectionString;

            frmLogin login = new frmLogin();
            string account = ConfigurationManager.AppSettings["LastAccount"];
            string pwd = "";
            if (!login.Login(ref account, ref pwd, LoginFlags.loginNormal))
                return;

            int iRet = L3Session.Open(connstr, account, pwd);
            //int iRet = L3Session.Open(connstr, "10910", "xgmes");
            if (iRet != 0)
            {
                string msg = string.Format("连接服务{0}失败!错误代码:{1:X}", conn.Name, iRet);
                MessageBox.Show(msg, "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            else
            {

                labelUser.Text = account;
                ConfigurationManager.AppSettings["LastAccount"] = account;
                menuLogout.Enabled = true;
                menuChangePassWord.Enabled = true;
                menuLogin.Enabled = false;

                //校对时间
                if (cmdGetServerTime.Execute() >= 0)
                {
                    string strdt = Convert.ToString(cmdGetServerTime.Command.Return);
                    if (strdt != "")
                        SynchronousTime(strdt);
                }
                L3DataAdapter.ReCheckAccessRights();

                l3dbxWarning.L3DataAdapter = L3DataAdapter;
                l3dbxWarning.LoadData();

                dsTeamID.L3DataAdapter = this.L3DataAdapter;
                dsShiftID.L3DataAdapter = this.L3DataAdapter;

                l3DataBoxTeamID.L3DataAdapter = null;
                l3DataBoxShiftID.L3DataAdapter = null;

                l3DataBoxTeamID.L3DataAdapter = this.L3DataAdapter;
                l3DataBoxShiftID.L3DataAdapter = this.L3DataAdapter;

                //add by hyh 2012-03-30  根据邢钢要求,定时修改密码,否则不应许登陆
                //try
                //{
                //    if (account.Equals("Administrator"))
                //        return;
                //    string strDateSpan = ConfigurationManager.AppSettings["PwdLockCycle"];
                //    string strCurTime = Convert.ToString(cmdGetServerTime.Command.Return);
                //    //获取上次修改密码时间
                //    cmdGetUserLastUpdPwdTime.Parameters[0].ConstantValue = account;
                //    if (pwd == "")
                //        pwd = "null";
                //    cmdGetUserLastUpdPwdTime.Parameters[1].ConstantValue = pwd;
                //    int iret = cmdGetUserLastUpdPwdTime.Execute();
                //    string strLastTime = Convert.ToString(cmdGetUserLastUpdPwdTime.Command.Return);
                //    DateTime dtCur = Convert.ToDateTime(strCurTime);
                //    DateTime dtLastTime = Convert.ToDateTime(strLastTime);
                //    TimeSpan ts = dtCur.Subtract(dtLastTime);
                //    double day = ts.TotalDays;
                //    int ttt = Convert.ToInt32(day);
                //    if (ts.TotalDays > Convert.ToDouble(strDateSpan))
                //    {
                //        MessageBox.Show("密码已过期,请联系管理员,并定期在" + strDateSpan + "天内修改密码!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                //        L3Session.Close();
                //    }
                //    else if (ttt > 54)
                //    {
                //        MessageBox.Show("距密码过期还有" + Convert.ToInt32(60 - Convert.ToInt32(day)) + "天,请及时修改密码!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                //    }
                //}
                //catch { return; }
                //end
            }
        }