private void Ok() { try { nhanVien n = new nhanVien(); if (nv.timkiem("UserName", UserName.Text).Rows.Count > 0) { UserName.SelectAll(); PassWord.Text = ""; Retype.Text = ""; UserName.Focus(); MessageBox.Show("User already exists"); } else { if (PassWord.Text == Retype.Text) { n.maNV = UserName.Text; n.hoTen = fullName.Text; n.ngaySinh = BirthDay.Value.ToShortDateString(); n.sdt = PhoneNumber.Text; n.passWord = PassWord.Text; if (n.isNull()) { toolTip1.ToolTipTitle = "Warning"; toolTip1.Show("Enter full infomation", Retype, Retype.Location, 5000); } else if (nv.them(n)) { if (nv.themUser(n)) { MessageBox.Show("Done"); this.Close(); } } } else { toolTip1.ToolTipTitle = "Warning"; toolTip1.Show("Retype password again!", Retype, new Point(400, 250), 5000); Retype.SelectAll(); Retype.Focus(); } } } catch { MessageBox.Show("Failed", "Oops", MessageBoxButtons.OK); } }
private void Edit() { if (Fullname.Enabled == false) { foreach (Control control in layoutControl1.Controls) { if ((control is TextEdit || control is DateTimePicker) && control != Username) { control.Enabled = true; } } } else { nv.maNV = Username.Text; nv.hoTen = Fullname.Text; nv.ngaySinh = Birthday.Value.ToString(); nv.sdt = PhoneNumber.Text; nv.passWord = Password.Text; if (nv.isNull()) { toolTip1.ToolTipTitle = "Warning"; toolTip1.Show("Please enter full information", windowsUIButtonPanel1, windowsUIButtonPanel1.Location, 5000); } else { if (nhanVien.sua(nv)) { MessageBox.Show("Update successful", "Infomation"); Profile_Load(this, new EventArgs()); } else { MessageBox.Show("Update unsuccesful", "Warning"); return; } } } }