/// <summary> /// 获得当前系统中管理员的个数 /// </summary> /// <returns> /// </returns> public int GetAdminCount() { int result = 0; DataSet adminCount = processor.Query("SELECT COUNT(*) AS AdminCount FROM UserInfo WHERE (RoleId = 1)", null); int.TryParse(adminCount.Tables[0].Columns[0].ToString(), out result); return(result); }
public List <UserRight> GetRightByUserName(string username) { if (!string.IsNullOrEmpty(username)) { Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("Username", username); return(processor.Query <UserRight>("select * from UserRight where Username=@Username COLLATE NOCASE", dic)); } else { return(null); } }
public List <UserMeanRelation> GetMeaningByUser(string username) { if (!string.IsNullOrEmpty(username)) { Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("username", username); return(processor.Query <UserMeanRelation>("SELECT * FROM UserMeanRelation WHERE username=@username COLLATE NOCASE", dic)); } else { return(null); } }
//根据条件读取所有日志 public List <OperationLog> GetLog(Dictionary <string, object> dic) { // string cmdtext = @"select Action,UserName as 'User Name',fullname as 'Full Name',operatetime as 'Date',Detail // from OperationLog where 1=1"; string cmdtext = @"select * from OperationLog where 1=1"; if (dic != null) { foreach (string s in dic.Keys) { if (s == "OperateTime1") { cmdtext = string.Concat(cmdtext, " and strftime('%Y%m%d',date(operatetime)) >=@", s); } else if (s == "OperateTime2") { cmdtext = string.Concat(cmdtext, " and strftime('%Y%m%d',date(operatetime)) <=@", s); } else { cmdtext = string.Concat(cmdtext, " and ", s, "=@", s); } } } return(processor.Query <OperationLog>(cmdtext, dic)); //DataSet ds = processor.Query(cmdtext, dic); //if (ds != null && ds.Tables.Count > 0) // return ds.Tables[0]; //else // return new DataTable(); }
public List <AlarmConfig> GetAlarmConfigBySnTn(string sn, string tn) { Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("sn", sn); dic.Add("tn", tn); return(processor.Query <AlarmConfig>("select * from AlarmConfig where SN=@sn and TN=@tn", dic)); }
public void Init() { List <RoleInfo> role = processor.Query <RoleInfo>("SELECT * FROM RoleInfo", null); if (role == null || role.Count == 0) { role.Add(new RoleInfo() { ID = 1, Rolename = "Admin", Remark = DateTime.Now.ToString() }); role.Add(new RoleInfo() { ID = 2, Rolename = "User", Remark = DateTime.Now.ToString() }); processor.Insert <RoleInfo>(role); } this.cbxRole.DataSource = role; this.cbxRole.DisplayMember = "Rolename"; this.cbxRole.ValueMember = "ID"; userid = this.GetCurrentUserId(); if (username != null && username != string.Empty) { user = processor.QueryOne <UserInfo>("SELECT * FROM USERINFO WHERE username=@username COLLATE NOCASE", delegate() { Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("username", username.Trim().ToLower()); return(dic); }); this.tbUserName.Text = user.UserName; this.tbFullName.Text = user.FullName; this.tbPwd.Text = user.Pwd; this.tbDescription.Text = user.Description; this.tbConfirm.Text = user.Pwd; switch (user.RoleId) { case 1: this.cbxRole.SelectedValue = 1; break; case 2: this.cbxRole.SelectedValue = 2; break; default: break; } // 如果为普通用户,则隐藏锁定、Diable、Group修改选项 if (Common.User.RoleId != 1 || Common.User.Userid == user.Userid) { this.cbxRole.Enabled = false; } Common.SetControlEnable(this.tbUserName, false); } else { Common.SetControlEnable(this.tbUserName, true); } }
/// <summary> /// init meanings 列表 /// </summary> public void InitMeaning() { // DataSet list = processor.Query("SELECT * FROM Meanings", null); List <Meanings> list = processor.Query <Meanings>("SELECT * FROM Meanings", null); if (list != null && list.Count > 0) { this.clbMeaning.DataSource = list; this.clbMeaning.ValueMember = "ID"; this.clbMeaning.DisplayMember = "Desc"; Common.SetControlEnable(this.btnEditMean, true); Common.SetControlEnable(this.btnDelMean, true); } else { Common.SetControlEnable(this.btnEditMean, false); Common.SetControlEnable(this.btnDelMean, false); } }
public DataTable GetUserInfoByInit() { DataSet ds = processor.Query(@"SELECT username as 'User Name',fullname as 'Full Name',description as 'Role' ,CASE RoleID WHEN 1 THEN 'Admin' else 'User' end as 'Group' FROM userinfo", null); if (ds != null && ds.Tables.Count > 0) { return(ds.Tables[0]); } else { return(null); } }
public void Init() { List <RoleInfo> role = processor.Query <RoleInfo>("SELECT * FROM RoleInfo", null); if (role == null || role.Count == 0) { role.Add(new RoleInfo() { ID = 1, Rolename = "Administrators", Remark = DateTime.Now.ToString() }); role.Add(new RoleInfo() { ID = 2, Rolename = "Users", Remark = DateTime.Now.ToString() }); processor.Insert <RoleInfo>(role); } this.cbxRole.DataSource = role; this.cbxRole.DisplayMember = "Rolename"; this.cbxRole.ValueMember = "ID"; userid = this.GetCurrentUserId(); if (username != null && username != string.Empty) { user = processor.QueryOne <UserInfo>("SELECT * FROM USERINFO WHERE username=@username", delegate() { Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("username", username); return(dic); }); this.tbUserName.Text = user.UserName; this.tbFullName.Text = user.FullName; this.tbPwd.Text = user.Pwd; this.tbDescription.Text = user.Description; this.tbConfirm.Text = user.Pwd; this.cbChangePwd.Checked = Convert.ToBoolean(user.ChangePwd); this.cbLocked.Checked = Convert.ToBoolean(user.Locked); Common.SetControlEnable(this.cbLocked, true); Common.SetControlEnable(this.tbUserName, false); } else { Common.SetControlEnable(this.cbLocked, false); Common.SetControlEnable(this.tbUserName, true); } }
//根据条件读取所有日志 public List <OperationLog> GetLog(Dictionary <string, object> dic) { string cmdtext = "select * from OperationLog where 1=1"; if (dic != null) { foreach (string s in dic.Keys) { if (s == "OperateTime1") { cmdtext = string.Concat(cmdtext, " and strftime('%Y%m%d',date(operatetime)) >=@", s); } else if (s == "OperateTime2") { cmdtext = string.Concat(cmdtext, " and strftime('%Y%m%d',date(operatetime)) <=@", s); } else { cmdtext = string.Concat(cmdtext, " and ", s, "=@", s); } } } return(processor.Query <OperationLog>(cmdtext, dic)); }
public List <UserProfile> GetGlobalSetting() { //Dictionary<string, object> dic = new Dictionary<string, object>(); //dic.Add("@IsGlobal", true); return(processor.Query <UserProfile>("select * from userprofile where IsGlobal=1", null)); }
public List <DigitalSignature> GetDigitalSignatureList() { return(processor.Query <DigitalSignature>("select * from DigitalSignature", null)); }
public List <PointInfo> GetPointsList() { return(processor.Query <PointInfo>("select * from pointinfo", null)); }
public List <Device> GetDeviceList() { return(processor.Query <Device>("select * from device", null)); }