コード例 #1
0
ファイル: MainFrm.cs プロジェクト: wwkkww1983/WMS
        private void tmr_checkLogin_Tick(object sender, EventArgs e)
        {
            string    sql = "select top 1* from SysDatLoginDetail where userid='" + PubUtils.uContext.UserID + "' and flag='0' order by Createtime desc";
            DataTable dt  = NMS.QueryDataTable(PubUtils.uContext, sql);

            if (dt.Rows.Count == 0)
            {
                tmr_checkLogin.Stop();
                ForceOut = true;
                PubUtils.LoginLog("1", ForceOut);
                MsgBox.Error("系统登录异常,请重新登录.");
                //通过线程关闭
                System.Diagnostics.Process.GetCurrentProcess().Kill();
            }
            else
            {
                if (dt.Rows[0]["guid"].ToString() != PubUtils.Controller)
                {
                    tmr_checkLogin.Stop();
                    ForceOut = true;
                    PubUtils.LoginLog("1", ForceOut);
                    FrmLoginException frm = new FrmLoginException("用户【" + PubUtils.uContext.UserName + "】被异地登录", "主机名称【" + dt.Rows[0]["winName"].ToString() + "】 IP地址【" + dt.Rows[0]["loginip"].ToString() + "】");
                    frm.ShowDialog();
                    //MsgBox.Error("当前用户在异地登录,IP地址【" + dt.Rows[0]["loginip"].ToString() + "】");
                    System.Diagnostics.Process.GetCurrentProcess().Kill();
                }
            }
        }
コード例 #2
0
ファイル: MainFrm.cs プロジェクト: wwkkww1983/WMS
 private void MainFrm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (MsgBox.Question("确认是否关闭") == DialogResult.OK)
     {
         e.Cancel = true;
         PubUtils.LoginLog("1", ForceOut);
         e.Cancel = false;
         System.Environment.Exit(0);
     }
     else
     {
         e.Cancel = true;
     }
 }
コード例 #3
0
        private void btn_login_Click(object sender, EventArgs e)
        {
            //new PubUtils().PlayPersonSound();
            label3.Text = "";
            if (txt_Userlogin.Text.Length == 0)
            {
                label3.Text      = "提示:用户名不可为空.";
                label3.ForeColor = Color.Red;
                return;
            }
            if (txt_pawlogin.Text.Length == 0)
            {
                label3.Text      = "提示:密码不可为空.";
                label3.ForeColor = Color.Red;
                txt_pawlogin.Focus();
                return;
            }
            label3.Text = "";
            PubUtils.uContext.UserID   = userid;
            PubUtils.uContext.Password = txt_pawlogin.Text;

            string sql            = "select isnull(max(UserName),0) from SysDatUser where UserID='" + userid + "'";//获取用户姓名
            string sql_logincheck = "select top 1 * from [SysDatLoginDetail] where userid='" + userid + "' and flag='0' order by createtime desc";

            this.Waiting(delegate
            {
                try
                {
                    DataTable dt = NMS.QueryDataTable(PubUtils.uContext, sql);
                    if (dt.Rows.Count > 0)
                    {
                        PubUtils.uContext.UserName = dt.Rows[0][0].ToString().Trim();//查找数据库是否存在此条码
                        //if (NMS.LoginUser(PubUtils.uContext))
                        if (true)
                        {
                            DataTable dt_barcode = NMS.QueryDataTable(PubUtils.uContext, "select val1 from sysdatconfig where key1='barcodeanlysis'");
                            if (dt_barcode.Rows.Count > 0 && dt_barcode.Rows[0][0] != null && dt_barcode.Rows[0][0].ToString().Length > 0)
                            {
                                PubUtils.AnalysisSerPath = dt_barcode.Rows[0][0].ToString();
                            }
                            else
                            {
                                PubUtils.AnalysisSerPath = "0.0.0.0";
                            }
                            //string a = NMS.GetPnUniqueCode(PubUtils.uContext, "sfdsfds,343fds,1ewew,343fdsa,", "E808A86F-9C88-491D-824C-5B43FF3AD309");
                            //检验服务器版本信息
                            //string ver = NMS.CheckVer();
                            //string a = Application.ProductVersion;
                            //if (a.Split('.')[0] != ver.Split('.')[0])
                            //{
                            //    MsgBox.Error("客户端版本和服务器端版本不一致");
                            //    return;
                            //}
                            //判断上次登录的IP地址是否和当前登录的一致
                            //DataTable dt_login = NMS.QueryDataTable(PubUtils.uContext, sql_logincheck);
                            //if (dt_login.Rows.Count > 0)
                            //{
                            //    string LoginIP = dt_login.Rows[0]["LoginIP"].ToString();
                            //    if (CurIP == LoginIP)
                            //    {

                            //    }
                            //}
                            PubUtils.LoginLog("0", false);
                            this.Invoke(new Action(delegate
                            {
                                this.RealHide();
                                Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                                config.AppSettings.Settings["loginuser"].Value = PubUtils.uContext.UserID;
                                config.Save(ConfigurationSaveMode.Full);
                                ConfigurationManager.RefreshSection("appSettings");
                                #region 获取erp接口url nancy 2007.08.03
                                PubUtils.ERPURL = PubUtils.IsErpURL();
                                #endregion
                                try
                                {
                                    Utils.existsTable();
                                    MainFrm frm = new MainFrm();
                                    frm.ShowDialog();

                                    //MainFrm_New f = new MainFrm_New();
                                    //f.ShowDialog();

                                    //FrmSLRecordSeach frd = new FrmSLRecordSeach();
                                    //frd.ShowDialog();

                                    //test Test = new test();
                                    //Test.ShowDialog();
                                }
                                catch (Exception ex)
                                {
                                    if (MsgBox.Error("错误:" + ex.Message + "\n\t系统即将退出!") == DialogResult.OK)
                                    {
                                        Application.Exit();
                                    }
                                }
                                Application.Exit();
                            }));
                        }
                        else
                        {
                            label3.Text      = "提示:登录失败.";
                            label3.ForeColor = Color.Red;
                            //new PubUtils().ShowNoteNGMsg("登录失败", 2);
                            txt_pawlogin.Text = "";
                            txt_pawlogin.Focus();
                        }
                    }
                    else
                    {
                        this.Invoke(new Action(delegate
                        {
                            label3.Text      = "提示:不存在用户.";
                            label3.ForeColor = Color.Red;
                            txt_Userlogin.SelectAll();
                            txt_Userlogin.Focus();
                            return;
                        }));
                    }
                }
                catch (Exception ee)
                {
                    if (ee.Message.Length < 20)
                    {
                        new PubUtils().ShowNoteNGMsg(ee.Message, 1, grade.SevereError);
                    }
                }
            });
        }