using System; using System.Collections.Generic; using System.Text; using Stone.Common; using System.Windows.Forms; using System.Data; namespace Stone.User { public class UserInfo { public static int UserID = 0; public static string UserName = ""; public static string Password = ""; public static DataTable Authority = null; public static bool isLogin = false; /// /// 登录系统 /// public static DialogResult Login() { frmLogin dialog = new frmLogin(); DialogResult dr = dialog.ShowDialog(); dialog.Dispose(); return dr; } /// /// 操作员管理 /// public static void UserManager() { frmUserManager dialog = new frmUserManager(); dialog.ShowDialog(); dialog.Dispose(); } /// /// 修改操作员密码 /// public static void AlterPassword() { frmPassword dialog = new frmPassword(); dialog.ShowDialog(); dialog.Dispose(); } /// /// 判断是否有指定的权限 /// /// 权限字串,请在数据库中的“t_UserAuthority”表中添加 /// public static bool UserVerify(string authority) { bool result = false; if(Authority.Select("[Code]='" + authority + "'").Length > 0) { result = true; } return result; } /// /// 获取SQL连接字符串 /// /// public static string sqlconnstring() { string sql = "uid=" + MyAppconfig.ReadValue("SqlUser") + ";pwd=" + MyStrings.DecryptStr(MyAppconfig.ReadValue("SqlPwd")) + ";initial catalog=" + MyAppconfig.ReadValue("SqlDataBase") + ";data source=" + MyAppconfig.ReadValue("SqlServer") + ";TimeOut=" + MyAppconfig.ReadValue("SqlTimeOut"); return sql; } /// /// 取得最后一次登录的操作员名 /// /// internal static string GetLastLoginUsername() { return MyAppconfig.ReadValue("LastLoginUser"); } /// /// 保存最后一次登录的操作员名 /// internal static void PutLastLoginUsername() { MyAppconfig.WriteValue("LastLoginUser", UserInfo.UserName); } } }