private void btnOk_Click(object sender, EventArgs e) { All.Window.MessageWindow mw; if (cbbName.SelectedIndex < 0) { cbbName.Focus(); mw = new MessageWindow("请选择要修改的用户", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); mw.ShowDialog(); return; } if (txtOldPassword.Text.ToUpper() != alluser.AllUser[cbbName.SelectedIndex].PassWord.ToUpper()) { txtPassword.Focus(); mw = new MessageWindow("对不起,输入的用户名和原始密码不匹配", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); mw.ShowDialog(); return; } if (txtPassword.Text != txtPasswordAgain.Text) { txtPassword.Focus(); mw = new All.Window.MessageWindow("两次输入的密码不一致,请重新输入密码!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); mw.ShowDialog(); return; } alluser.AllUser[cbbName.SelectedIndex].PassWord = txtPassword.Text; alluser.AllUser[cbbName.SelectedIndex].Save(); mw = new All.Window.MessageWindow(string.Format("[{0}] 用户已修改成功!", cbbName.Text.Trim()), "成功", MessageBoxButtons.OK, MessageBoxIcon.Information); mw.ShowDialog(); }
private void com_CommunicateErrorRaise(Exception e) { using (All.Window.MessageWindow mw = new All.Window.MessageWindow(e.Message, "错误", All.Window.MessageWindow.EButton.OK, All.Window.MessageWindow.EIcon.Error)) { mw.ShowDialog(); } }
private void OpenCom() { try { if (!cbbBaud.Items.Contains(cbbBaud.Text)) { cbbBaud.Items.Add(cbbBaud.Text); } cbbBaud.DropDownStyle = ComboBoxStyle.DropDownList; com = new All.Communicate.Com(); com.CommunicateErrorRaise += com_CommunicateErrorRaise; Dictionary <string, string> buff = new Dictionary <string, string>(); com.Init(buff); com.Open(); if (com.IsOpen) { ucCommunite1.SetCommunicate(com); btnOpen.Text = "关闭"; btnOpen.BackgroundImage = AllTools.Properties.Resources.Close; } else { CloseCom(); } } catch (Exception e) { using (All.Window.MessageWindow mw = new All.Window.MessageWindow(e.Message, "错误", All.Window.MessageWindow.EButton.OK, All.Window.MessageWindow.EIcon.Error)) { mw.ShowDialog(); } } }
private void btnOk_Click(object sender, EventArgs e) { MessageWindow mw; if (User.AllUser.FindIndex(user => user.UserName == txtName.Text) >= 0) { txtName.Focus(); mw = new MessageWindow("当前要添加的用户已存在,不能添加", "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error); mw.ShowDialog(); return; } if (txtPassword.Text != txtPasswordAgain.Text) { txtPassword.Focus(); mw = new All.Window.MessageWindow("两次输入的密码不一致,请重新输入密码!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); mw.ShowDialog(); return; } All.Class.cUser.UserSet us = new Class.cUser.UserSet(); us.UserName = txtName.Text; us.PassWord = txtPassword.Text; us.Level = cbbLevel.Text; us.Save(); User.AllUser.Add(us); mw = new MessageWindow("当前用户已成功添加", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information); mw.ShowDialog(); }