//对话框载入 private void EmployeeForm_Load(object sender, EventArgs e) { if (!newDepartment) { TextName.Text = m_Department.name; TextNote.Text = m_Department.note; TextName.SelectAll(); TextName.Focus(); } }
private void AddButton(object sender, RoutedEventArgs e) { ProgramPersons.Add(new Person()); PeopleList.SelectedIndex = ProgramPersons.Count - 1; TextName.Text = "Name"; TextSalary.Text = "0"; TextAge.Text = "0"; TextName.SelectAll(); TextSalary.SelectAll(); TextAge.SelectAll(); TextName.Focus(); }
private void btnJoin_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(TextName.Text) || string.IsNullOrEmpty(TextEmail.Text) || string.IsNullOrEmpty(TextPassword.Text)) { MetroFramework.MetroMessageBox.Show(this, "All field should be filled up.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); TextName.Focus(); return; } else { if (UserServices.DuplicateMail(TextEmail.Text)) { MetroFramework.MetroMessageBox.Show(this, "Mail Already Existed.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } User u = new User(); if (TextName.Text.Length <= 50 && TextEmail.Text.Length <= 50 && TextPassword.Text.Length <= 50) { u.name = TextName.Text; if (IsValidEmail(TextEmail.Text)) { u.email = TextEmail.Text; } else { MetroFramework.MetroMessageBox.Show(this, "Invalid mail.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } u.password = TextPassword.Text; } else { MetroFramework.MetroMessageBox.Show(this, "Name, Password or Email is Too Big.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (pictureBox.Image != null) { u.picture = imageToByteArray(pictureBox.Image); } else { u.picture = null; } UserServices.Insert(u); MetroFramework.MetroMessageBox.Show(this, "Joined successfully.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Hide(); } }
private void New() { if (string.IsNullOrEmpty(TextName.Text)) { MessageBox.Show("请输入温度类型名称"); TextName.Focus(); return; } Temperature = new Sys_Temperature() { IsSystem = (Yqun.Common.ContextCache.ApplicationContext.Current.IsAdministrator && CheckIsSystem.Checked) ? 1 : 0, Name = TextName.Text, CreateBy = Yqun.Common.ContextCache.ApplicationContext.Current.UserName, CreateTime = DateTime.Now.ToString("yyyy-MM-dd hh:MM:ss"), }; if (Yqun.Common.ContextCache.ApplicationContext.Current.IsAdministrator) { if (string.IsNullOrEmpty(TestRoomCode)) { Temperature.TestRoomCode = "0000000000000000"; } else { Temperature.TestRoomCode = TestRoomCode; } } else { Temperature.TestRoomCode = Yqun.Common.ContextCache.ApplicationContext.Current.InTestRoom.Code; } var result = TemperatureHelperClient.NewTemperature(Temperature); if (string.IsNullOrEmpty(result)) { MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; } else { MessageBox.Show(result, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private async void ButtonEdit_Clicked(object sender, EventArgs e) { FieldsAreReadOnly = false; OnPropertyChanged("FieldsAreReadOnly"); TextName.Focus(); ButtonEdit.IsVisible = false; ButtonSave.IsVisible = true; ButtonCancel.IsVisible = true; Status.IsEnabled = true; Createdby.IsVisible = false; Createdon.IsVisible = false; Modifiedby.IsVisible = false; Modifiedon.IsVisible = false; LCreatedby.IsVisible = false; LCreatedon.IsVisible = false; LModifiedby.IsVisible = false; LModifiedon.IsVisible = false; }
//确定 private void okBtn_Click(object sender, EventArgs e) { if (TextName.Text.Trim() == "") { BathClass.printErrorMsg("需要输入部门名称"); TextName.SelectAll(); TextName.Focus(); return; } m_Department.name = TextName.Text.Trim(); if (TextNote.Text.Trim() != "") { m_Department.note = TextNote.Text.Trim(); } if (newDepartment) { if (db.Department.FirstOrDefault(x => x.name == TextName.Text) != null) { BathClass.printErrorMsg("已经存在此名称的部门"); TextName.SelectAll(); TextName.Focus(); return; } db.Department.InsertOnSubmit(m_Department); db.SubmitChanges(); m_form.createTree(); m_Department = new Department(); TextName.Text = ""; TextNote.Text = ""; TextName.Focus(); } else { db.SubmitChanges(); this.DialogResult = DialogResult.OK; } }
private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar > 95 && e.KeyChar < 124) { //only display lowercase letters of the alphabet } else//entered a number or character that isnt in the alphabet { MessageBox.Show("Please enter letters only", "Error"); e.Handled = true; TextName.Focus();//Focus on name textbox } if (e.KeyChar > 12 && e.KeyChar < 14)//Enter key pressed { MessageBox.Show("Please enter your lives now between 1 and 5"); TextName.Enabled = false; //deny access to name textbox LblLives.Focus(); //Focus on lives textbox } }
private void Modify() { if (string.IsNullOrEmpty(TextName.Text)) { MessageBox.Show("请输入温度类型名称"); TextName.Focus(); return; } Temperature.Name = TextName.Text; var result = TemperatureHelperClient.RenameTemperature(Convert.ToString(Temperature.ID), Temperature.Name); if (string.IsNullOrEmpty(result)) { MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; } else { MessageBox.Show(result, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void Form1_Load(object sender, EventArgs e) { MessageBox.Show("Use the arrow keys to move your vehicle. \n Don't get hit by the tyres! \n Every oil can you collect scores a point! \n If a tyre hits your vehicle a life is lost!", "Game Instructions"); TextName.Focus(); }
private void ButtonLogin_Click(object sender, EventArgs e) { if (TextName.Text.Trim() == "" && TextPassword.Text.Trim() == "") { labelNameNull.Text = "账号不能为空"; labelPasswordNull.Text = "密码不能为空"; TextName.Focus(); } else if (TextName.Text.Trim() == "") { labelNameNull.Text = "账号不能为空"; labelPasswordNull.Text = " "; TextName.Focus(); } else if (TextPassword.Text.Trim() == "") { labelNameNull.Text = " "; labelPasswordNull.Text = "密码不能为空"; TextPassword.Focus(); } else { labelNameNull.Text = " "; labelPasswordNull.Text = " "; string identify = ComboBox.SelectedItem.ToString(); switch (identify) { case "总管理员": { if (TextName.Text.Trim() != "admin" && TextPassword.Text.Trim() != PublicValue.ADMINPASWRD) { labelNameNull.Text = "账号输入错误"; labelPasswordNull.Text = "密码输入错误"; TextName.Focus(); } else if (TextName.Text.Trim() != "admin") { labelNameNull.Text = "账号输入错误"; labelPasswordNull.Text = " "; TextName.Focus(); } else if (TextPassword.Text.Trim() != PublicValue.ADMINPASWRD) { labelNameNull.Text = " "; labelPasswordNull.Text = "密码输入错误"; TextName.Focus(); } else { MessageBox.Show("登录成功!", "提示"); this.Hide(); Admin admin = new Admin(); admin.Show(); } break; } case "公寓管理员": { int flag = 0; MySQLConnection SQLconnection = new MySQLConnection(new MySQLConnectionString ("localhost", "DormitoryManage", "root", "123456").AsString); string SQLstr = "SELECT managerNumber, managerPassword FROM manager_info"; SQLconnection.Open(); MySQLCommand SQLcommand = new MySQLCommand(SQLstr, SQLconnection); MySQLDataReader SQLreader = (MySQLDataReader)SQLcommand.ExecuteReader(); while (SQLreader.Read()) { string tempa = SQLreader["managerNumber"].ToString(); string tempb = SQLreader["managerPassword"].ToString(); if (TextName.Text.Trim() != tempa && TextPassword.Text.Trim() != tempb) { flag = 0; } else if (TextName.Text.Trim() != tempa) { flag = 1; } else if (TextPassword.Text.Trim() != tempb) { flag = 2; } else { flag = 3; break; } } SQLconnection.Close(); if (flag == 0) { labelNameNull.Text = "账号输入错误"; labelPasswordNull.Text = "密码输入错误"; TextName.Focus(); } else if (flag == 1) { labelNameNull.Text = "账号输入错误"; labelPasswordNull.Text = " "; TextName.Focus(); } else if (flag == 2) { labelNameNull.Text = " "; labelPasswordNull.Text = "密码输入错误"; TextName.Focus(); } else if (flag == 3) { MessageBox.Show("登录成功!", "提示"); PublicValue.MAGNUM = TextName.Text; this.Hide(); ManagerHost managerhost = new ManagerHost(); managerhost.Show(); } break; } case "学生": { int flag = 0; MySQLConnection SQLconnection = new MySQLConnection(new MySQLConnectionString ("localhost", "DormitoryManage", "root", "123456").AsString); string SQLstr = "SELECT studentNumber, studentPassword FROM student_info"; SQLconnection.Open(); MySQLCommand SQLcommand1 = new MySQLCommand("SET NAMES GB2312", SQLconnection); SQLcommand1.ExecuteNonQuery(); MySQLCommand SQLcommand2 = new MySQLCommand(SQLstr, SQLconnection); MySQLDataReader SQLreader = (MySQLDataReader)SQLcommand2.ExecuteReader(); while (SQLreader.Read()) { string tempa = SQLreader["studentNumber"].ToString(); string tempb = SQLreader["studentPassword"].ToString(); if (TextName.Text.Trim() != tempa && TextPassword.Text.Trim() != tempb) { flag = 0; } else if (TextName.Text.Trim() != tempa) { flag = 1; } else if (TextPassword.Text.Trim() != tempb) { flag = 2; } else { flag = 3; break; } } SQLconnection.Close(); if (flag == 0) { labelNameNull.Text = "账号输入错误"; labelPasswordNull.Text = "密码输入错误"; TextName.Focus(); } else if (flag == 1) { labelNameNull.Text = "账号输入错误"; labelPasswordNull.Text = " "; TextName.Focus(); } else if (flag == 2) { labelNameNull.Text = " "; labelPasswordNull.Text = "密码输入错误"; TextName.Focus(); } else if (flag == 3) { MessageBox.Show("登录成功!", "提示"); PublicValue.STUNUM = TextName.Text; this.Hide(); StudentHost studenthost = new StudentHost(); studenthost.Show(); } break; } } } }
private void ButtonCancel_Click(object sender, EventArgs e) { TextName.Clear(); TextPassword.Clear(); TextName.Focus(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { TextName.Focus(); }
private void btnSave_Click(object sender, EventArgs e) { Book b = new Book(); if (string.IsNullOrEmpty(TextDescription.Text) || string.IsNullOrEmpty(TextAuthor.Text) || string.IsNullOrEmpty(TextName.Text) || string.IsNullOrEmpty(ComboCategory.Text)) { MetroFramework.MetroMessageBox.Show(this, "All field should be filled up.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); TextName.Focus(); return; } else { if (TextName.Text.Length <= 50) { b.name = TextName.Text; } else { MetroFramework.MetroMessageBox.Show(this, "Book Name Too Big.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (TextAuthor.Text.Length <= 50) { b.author = TextAuthor.Text; } else { MetroFramework.MetroMessageBox.Show(this, "Author Name Too Big.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (TextDescription.Text.Length <= 500) { b.description = TextDescription.Text; } else { MetroFramework.MetroMessageBox.Show(this, "Description Too Big.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (pictureBox.Image != null) { b.picture = imageToByteArray(pictureBox.Image); //return; } if (!string.IsNullOrEmpty(TextLink.Text)) { b.link = TextLink.Text; } b.category = ComboCategory.Text; b.rating = 0; BookServices.Insert(b); MetroFramework.MetroMessageBox.Show(this, "Added successfully.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Refresh(); TextDescription.Clear(); TextAuthor.Clear(); TextName.Clear(); ComboCategory.SelectedIndex = 0; TextLink.Clear(); pictureBox.Image = null; } }