/// <summary> /// 窗体数据初始化 /// </summary> private void formInit() { string online = "0"; if (ServerHandle.TcpSvr.SessionTable != null) { //foreach (Session Client in ServerHandle.TcpSvr.SessionTable.Values) //{ // if (Client != null && Client.UserID != null) // { // online += "," + Client.UserID.ToString(); // } //} List <object> clients = new List <object>(ServerHandle.TcpSvr.dic.Values); foreach (object client in clients) { Session Client = (Session)client; if (Client != null && Client.UserID != null) { online += "," + Client.UserID.ToString(); } } } dataGridView1.AutoGenerateColumns = false; GSSBLL.Users bll = new GSSBLL.Users(); DataSet ds = bll.GetList("F_UserID in (" + online + ")"); dataGridView1.DataSource = ds.Tables[0]; groupBox2.Text = "在线用户(" + dataGridView1.Rows.Count + ")"; }
/// <summary> /// 初始化窗体 /// </summary> private void InitForm() { ServerUtil.BindDropDLTDept(this.f_DepartIDComboBox); ServerUtil.BindDropDLTRoles(this.f_RoleIDComboBox); if (_id != 0) { this.Text = "用户修改"; label1.Visible = true; label2.Visible = true; f_RegTimeLabel1.Visible = true; f_LastInTimeLabel1.Visible = true; GSSBLL.Users bll = new GSSBLL.Users(); GSSModel.Users model = bll.GetModel(_id); f_UserIDTextBox.Text = model.F_UserID.ToString(); f_UserNameTextBox.Text = model.F_UserName; //f_PassWordTextBox.Text=model.F_PassWord ; textBoxPSWH.Text = model.F_PassWord; f_DepartIDComboBox.SelectedValue = model.F_DepartID; f_RoleIDComboBox.SelectedValue = model.F_RoleID; f_RealNameTextBox.Text = model.F_RealName; SexradioButton1.Checked = model.F_Sex == false ? false : true; SexradioButton2.Checked = !SexradioButton1.Checked; f_BirthdayDateTimePicker.Text = model.F_Birthday.ToString(); f_EmailTextBox.Text = model.F_Email; f_MobilePhoneTextBox.Text = model.F_MobilePhone; f_TelphoneTextBox.Text = model.F_Telphone; f_NoteTextBox.Text = model.F_Note; f_IsUsedCheckBox.Checked = model.F_IsUsed; f_RegTimeLabel1.Text = model.F_RegTime.ToString(); f_LastInTimeLabel1.Text = model.F_LastInTime.ToString(); } }
/// <summary> /// 窗体数据初始化 /// </summary> private void formInit() { dataGridView1.AutoGenerateColumns = false; GSSBLL.Users bll = new GSSBLL.Users(); DataSet ds = bll.GetAllList(); dataGridView1.DataSource = ds.Tables[0]; }
private void toolStripButtonDelete_Click(object sender, EventArgs e) { if (MessageBox.Show("确定要删除选中的数据吗?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No) { return; } int iSelectRowCount = dataGridView1.SelectedRows.Count; //判断是否选择了行 if (iSelectRowCount > 0) { //循环删除行 foreach (DataGridViewRow dgvRow in dataGridView1.SelectedRows) { GSSBLL.Users bll = new GSSBLL.Users(); if (bll.Delete(Convert.ToInt32(dgvRow.Cells[0].Value))) { dataGridView1.Rows.Remove(dgvRow); } } } }
/// <summary> /// 保存数据 /// </summary> private void SaveData() { //验证数据项 string msg = CheckData(); if (msg.Length > 0) { MessageBox.Show(msg, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (textBoxPSWH.Text.Trim().Length == 0 && f_PassWordTextBox.Text.Trim().Length == 0) { MessageBox.Show("请输入密码!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { textBoxPSWH.Text = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(f_PassWordTextBox.Text.Trim(), "MD5").ToLower(); } //数据准备 GSSModel.Users model = new GSSModel.Users(); model.F_UserName = f_UserNameTextBox.Text; model.F_PassWord = textBoxPSWH.Text; model.F_DepartID = Convert.ToInt32(f_DepartIDComboBox.SelectedValue); model.F_RoleID = Convert.ToInt32(f_RoleIDComboBox.SelectedValue); model.F_RealName = f_RealNameTextBox.Text; model.F_Sex = SexradioButton1.Checked; model.F_Birthday = Convert.ToDateTime(f_BirthdayDateTimePicker.Text); model.F_Email = f_EmailTextBox.Text; model.F_MobilePhone = f_MobilePhoneTextBox.Text; model.F_Telphone = f_TelphoneTextBox.Text; model.F_Note = f_NoteTextBox.Text; model.F_IsUsed = f_IsUsedCheckBox.Checked; //数据提交 GSSBLL.Users bll = new GSSBLL.Users(); bool isok = false; if (_id != 0) { model.F_UserID = int.Parse(f_UserIDTextBox.Text); model.F_LastInTime = DateTime.Now; isok = bll.Update(model); } else { model.F_RegTime = DateTime.Now; int num = bll.Add(model); if (num > 0) { isok = true; } } if (isok) { MessageBox.Show("数据保存成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("数据保存失败!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error); } }