/// <summary> 加载记忆账户 /// </summary> private void LoadMemery() { this.dsUser = ConfigManager.User; if (this.dsUser == null) { this.dsUser = new DataSet(); } if (this.dsUser.Tables.Count == 0) { DataTable dt = new DataTable("User"); dt.Columns.Add("ID"); dt.Columns.Add("PWD"); this.dsUser.Tables.Add(dt); } this.dtUser = this.dsUser.Tables[0].Copy(); if (this.dtUser.Rows.Count > 0) { if (this.dtUser.Columns.Contains("ID")) { this.tbUser.Caption = this.dtUser.Rows[0]["ID"].ToString(); } if (this.dtUser.Columns.Contains("PWD")) { this.tbPwd.Caption = this.dtUser.Rows[0]["PWD"].ToString(); } if (this.tbPwd.Caption.Trim().Length > 0) { pbChecked_Click(null, null); } this.formCmb = new FormCmb(); this.formCmb.DisplayName = "ID"; this.formCmb.ValueName = "ID"; this.formCmb.ItemHeight = 35; this.formCmb.BackColor = Color.White; this.formCmb.SelectedColor = Color.FromArgb(97, 167, 208); this.formCmb.ItemSelected += new FormCmb.ItemSelectedHandler(this.SeletecdUser); this.formCmb.ItemDeleted += new FormCmb.ItemDeletedHandler(this.DeletedUser); this.formCmb.BindCmb(this.tbUser.InnerTextBox, this.dtUser, this.tbUser.Location.X, this.panelUser.Height - this.tbUser.Location.Y - this.tbUser.Height, true); } if (this.tbUser.Caption.Length > 0) { this.tbPwd.InnerTextBox.Focus(); } else { this.tbUser.InnerTextBox.Focus(); } }
/// <summary> 删除用户 /// </summary> /// <param name="value"></param> private void DeletedUser(string value) { if (this.dtUser == null) { return; } DataRow dr = this.dtUser.Select("ID='" + value + "'")[0]; this.dtUser.Rows.Remove(dr); if (this.tbUser.Tag.ToString() == value) { this.tbUser.Caption = string.Empty; this.tbUser.Tag = string.Empty; this.tbPwd.Caption = string.Empty; } this.formCmb.RefreshItems(this.dtUser); if (this.dtUser.Rows.Count == 0) { this.formCmb = null; } }
/// <summary> 删除用户 /// </summary> /// <param name="value"></param> private void DeletedUser(string value) { if (this.dtUser == null) { return; } DataRow dr = this.dtUser.Select("ID='" + value + "'")[0]; this.dtUser.Rows.Remove(dr); if (this.tbUser.Tag.ToString() == value) { this.tbUser.Caption = string.Empty; this.tbUser.Tag = string.Empty; this.tbPwd.Caption = string.Empty; } this.formCmb.RefreshItems(this.dtUser); if (this.dtUser.Rows.Count == 0) { this.formCmb = null; } }
/// <summary> 加载记忆账户 /// </summary> private void LoadMemery() { this.dsUser = ConfigManager.User; if (this.dsUser == null) { this.dsUser = new DataSet(); } if (this.dsUser.Tables.Count == 0) { DataTable dt = new DataTable("User"); dt.Columns.Add("ID"); dt.Columns.Add("PWD"); this.dsUser.Tables.Add(dt); } this.dtUser = this.dsUser.Tables[0].Copy(); if (this.dtUser.Rows.Count > 0) { if (this.dtUser.Columns.Contains("ID")) { this.tbUser.Caption = this.dtUser.Rows[0]["ID"].ToString(); } if (this.dtUser.Columns.Contains("PWD")) { this.tbPwd.Caption = this.dtUser.Rows[0]["PWD"].ToString(); } if (this.tbPwd.Caption.Trim().Length > 0) { pbChecked_Click(null, null); } this.formCmb = new FormCmb(); this.formCmb.DisplayName = "ID"; this.formCmb.ValueName = "ID"; this.formCmb.ItemHeight = 35; this.formCmb.BackColor = Color.White; this.formCmb.SelectedColor = Color.FromArgb(97, 167, 208); this.formCmb.ItemSelected += new FormCmb.ItemSelectedHandler(this.SeletecdUser); this.formCmb.ItemDeleted += new FormCmb.ItemDeletedHandler(this.DeletedUser); this.formCmb.BindCmb(this.tbUser.InnerTextBox, this.dtUser, this.tbUser.Location.X, this.panelUser.Height - this.tbUser.Location.Y - this.tbUser.Height, true); } if (this.tbUser.Caption.Length > 0) { this.tbPwd.InnerTextBox.Focus(); } else { this.tbUser.InnerTextBox.Focus(); } }