/// <summary> /// 关闭标签页显示的窗体 /// </summary> /// <param name="frmShow">显示的窗体</param> /// <param name="typeParent">父窗体类型</param> /// <param name="CloseStyle">关闭方式 1-存在父窗体则激活;2-存在父窗体则激活,不存在父窗体则重建</param> public static void CloseTabPageForm(Form frmShow, Type typeParent = null, int CloseStyle = 1) { try { if (frmShow == null || frmShow.Parent == null || !(frmShow.Parent is TabPage)) { return; } TabPage tp = frmShow.Parent as TabPage; if (tp.Parent == null || !(tp.Parent is TabControl)) { return; } if (typeParent == null) { MenuInfo menu = Login.Login_Var.lstMenu.FirstOrDefault(t => t.ProjectName == frmShow.GetType().Name); if (menu == null) { return; } MenuInfo parent = Login.Login_Var.lstMenu.FirstOrDefault(t => t.ID == menu.ParentID); if (parent == null) { return; } typeParent = frmShow.GetType().Assembly.GetType(Basic.Basic_Var.dicFormPath[parent.ProjectName]); } TabControl tc = tp.Parent as TabControl; foreach (TabPage p in tc.TabPages) { if (p.Controls != null && p.Controls.Count >= 1) { if (p.Controls[0].GetType() == typeParent) { tc.SelectedTab = p; return; } } } if (CloseStyle == 2) { Form frm = (Form)Activator.CreateInstance(typeParent); FrmMainTab frmMain = tc.TopLevelControl as FrmMainTab; frmMain.ShowForm(frm.Text, frm); } } catch (Exception ex) { ErrorMessage(ex.Message); } finally { //frmShow.Close(); } }
public static void ShowTabPageForm(Form frmParent, Form frmShow, int OpenStyle = 1) { try { object obj = frmParent.Parent.Parent.Parent.Parent.Parent; if (obj == null || obj.GetType().Name != typeof(FrmMainTab).Name) { return; } FrmMainTab frmMain = obj as FrmMainTab; frmMain.ShowForm(frmShow.Text, frmShow, OpenStyle); } catch (Exception ex) { ErrorMessage(ex.Message); } }
private void UserLogin() { try { this.Cursor = Cursors.WaitCursor; if (!CheckInput()) { return; } string MacAddress = IPHelper.GetMacByWMI(); string strError = string.Empty; UserInfo user = new UserInfo(); user.UserNo = txtAccount.Text.Trim(); user.Password = Basic.Basic_Func.JiaMi(txtPassword.Text.Trim()); //UFSoft.U8.Framework.Login.UI.clsLogin netLogin = new UFSoft.U8.Framework.Login.UI.clsLogin(); //user.Password = txtPassword.Text.Trim();// netLogin.EnPassWord(txtPassword.Text.Trim()); user.LoginIP = string.Format("PC:{0}", MacAddress); user.LoginDevice = IPHelper.GetUserName(); //string strUserJson; //user.Password = (txtPassword.Text.Trim()); //strUserJson = Login_Func.ObjectToJson<UserInfo>(user); //strUserJson = Login_Func.UserLoginForAndroid(strUserJson); ////string strUpdTime = Login_Func.UpdateLoginTimeForAndroid(strUserJson); ////string strClrTime = Login_Func.ClearLoginTimeForAndroid(strUserJson); ////string strChangePwd = Login_Func.ChangeUserPasswordForAndroid(strUserJson); ////string strTaskJson = Login_Func.GetTaskInfo(strUserJson, ""); //return; if (Login_Func.UserLogin(ref user, ref strError)) { Common.Common_Var.CurrentUser = user; if (user.Password == Basic.Basic_Func.JiaMi(Common_Var.DefaultPwd)) { MessageBox.Show(string.Format("您当前使用默认密码【{0}】登陆,请先修改密码!", Common_Var.DefaultPwd), "登陆提示"); FrmChangePwd frm = new FrmChangePwd(); DialogResult dr = frm.ShowDialog(); Application.Exit(); } } else { MessageBox.Show(strError, "登陆提示"); if (strError.IndexOf("用户") >= 0) { Focus_txtAccount(); } else { Focus_txtPassword(); } return; } this.Opacity = 0; this.Hide(); Application.DoEvents(); Login_Var.lstMenu = user.lstMenu; //五分钟后每十分钟更新一次登录时间 Login_Var.tLoginTime = new System.Threading.Timer(new System.Threading.TimerCallback(UpdateLoginTime), Common.Common_Var.CurrentUser, 300000, 600000); FrmMainTab frmMain = new FrmMainTab(); frmMain.Show(); } catch (Exception ex) { Common.Common_Func.ErrorMessage(ex.Message, "程序异常"); } finally { this.Cursor = Cursors.Default; } }