public void InitUsers() { DataSet ds = processor.Query(@"SELECT username as 'User Name',fullname as 'Full Name' ,description as 'Description' ,remark 'Remark' FROM userinfo", null); if (ds != null && ds.Tables.Count > 0) { dgvUser.DataSource = ds.Tables[0]; if (ds.Tables[0].Rows.Count > 0) { this.dgvUser.ClearSelection(); //this.dgvUser.Rows[ds.Tables[0].Rows.Count-1].Selected = true; //this.dgvUser.Rows Common.SetControlEnable(this.btnEdit, true); Common.SetControlEnable(this.btnDelete, true); } else { Common.SetControlEnable(this.btnEdit, false); Common.SetControlEnable(this.btnDelete, false); } } else { Common.SetControlEnable(this.btnEdit, false); Common.SetControlEnable(this.btnDelete, false); } }
/// <summary> /// 按键控制 /// </summary> /// <param name="state"></param> private void WizardStateControl(Step state) { switch (state) { case Step.first: Common.SetControlEnable(this.btnNext, true); Common.SetControlEnable(this.btnBack, false); this.btnSave.Visible = false; break; case Step.second: Common.SetControlEnable(this.btnNext, true); Common.SetControlEnable(this.btnBack, true); this.btnSave.Visible = false; break; case Step.third: Common.SetControlEnable(this.btnNext, true); Common.SetControlEnable(this.btnBack, true); this.btnSave.Visible = false; break; case Step.fourth: Common.SetControlEnable(this.btnNext, false); Common.SetControlEnable(this.btnBack, true); this.btnSave.Visible = true; break; } }
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); } }
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); } }
/// <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); } }
private void SetNextEnableOnThird(object sender, EventArgs args) { ListBox lb = sender as ListBox; if (lb.Items.Contains(RightsText.SignRecords)) { Common.SetControlEnable(this.btnNext, true); Common.SetControlEnable(this.btnBack, true); this.btnSave.Enabled = false; this.form.AcceptButton = this.btnNext; } else { Common.SetControlEnable(this.btnNext, false); Common.SetControlEnable(this.btnBack, true); this.btnSave.Enabled = true; this.btnSave.TabIndex = 0; this.form.AcceptButton = this.btnSave; } UserRight r = dic[WizardName.CreateRight] as UserRight; r.SetValue(); }
/// <summary> /// 按键控制 /// </summary> /// <param name="state"></param> private void WizardStateControl(Step state) { switch (state) { case Step.first: Common.SetControlEnable(this.btnNext, true); Common.SetControlEnable(this.btnBack, false); this.btnSave.Enabled = false; this.btnBack.Focus(); this.form.AcceptButton = this.btnNext; if (this.dic != null && this.dic[WizardName.CreateUser] != null) { var control = this.dic[WizardName.CreateUser] as UserCreate; if (control != null) { if (control.Group == 1) { this.FormTitleText = InputBoxTitle.WizardCreateAdmin; } else { this.FormTitleText = InputBoxTitle.WizardCreateUser; } } } break; case Step.second: Common.SetControlEnable(this.btnNext, true); Common.SetControlEnable(this.btnBack, true); this.btnSave.Enabled = false; this.form.AcceptButton = this.btnNext; this.btnBack.Focus(); //this.FormTitleText = InputBoxTitle.WizarPolicy; break; case Step.third: if ((dic[WizardName.CreateRight] as UserRight).Right.Contains(RightsText.SignRecords)) { Common.SetControlEnable(this.btnNext, true); Common.SetControlEnable(this.btnBack, true); this.btnSave.Enabled = false; this.form.AcceptButton = this.btnNext; this.btnBack.Focus(); } else { Common.SetControlEnable(this.btnNext, false); Common.SetControlEnable(this.btnBack, true); this.btnSave.Enabled = true; this.btnSave.TabIndex = 0; this.form.AcceptButton = this.btnSave; this.btnSave.Focus(); } //this.FormTitleText = InputBoxTitle.WizardRight; break; case Step.fourth: Common.SetControlEnable(this.btnNext, false); Common.SetControlEnable(this.btnBack, true); this.btnSave.Enabled = true; this.btnSave.TabIndex = 0; this.form.AcceptButton = this.btnSave; this.btnSave.Focus(); //this.FormTitleText = InputBoxTitle.WizardMeaning; break; } }