private void okButton_Click(object sender, EventArgs e) { if (!this.bModify) { string text = this.roomIdTextBox.Text.Trim(); if (text == string.Empty) { MyMsgBox.MsgError(Properties.Resources.RoomID + " " + Properties.Resources.IsNotEmpty + "!"); this.roomIdTextBox.Focus(); return; } if (!StringEx.IsStrNumber(text)) { MyMsgBox.MsgError(Properties.Resources.RoomID + " " + Properties.Resources.IsNumber + "!"); this.roomIdTextBox.Focus(); return; } int num = int.Parse(text); if (num < 1) { MyMsgBox.MsgError(Properties.Resources.RoomID + " > 0 !"); this.roomIdTextBox.Focus(); return; } } if (this.roomNameTextBox.Text.Trim() == string.Empty) { MyMsgBox.MsgError(Properties.Resources.RoomName + " " + Properties.Resources.IsNotEmpty + "!"); this.roomNameTextBox.Focus(); } else { base.DialogResult = DialogResult.OK; } }
private void okButton_Click(object sender, EventArgs e) { if (!this.bModify) { string strBedID_ = this.bedIdTextBox.Text.Trim(); if (strBedID_ == string.Empty) { MyMsgBox.MsgError(Properties.Resources.BedID + " " + Properties.Resources.IsNotEmpty + "!"); this.bedIdTextBox.Focus(); return; } if (!StringEx.IsStrNumber(strBedID_)) { MyMsgBox.MsgError(Properties.Resources.BedID + " " + Properties.Resources.IsNumber + "!"); this.bedIdTextBox.Focus(); return; } int iBedID_ = Int32.Parse(strBedID_); if (iBedID_ < 1) { MyMsgBox.MsgError(Properties.Resources.BedID + " > 0 !"); this.bedIdTextBox.Focus(); return; } } if (this.bedNameTextBox.Text.Trim() == string.Empty) { MyMsgBox.MsgError(Properties.Resources.BedName + " " + Properties.Resources.IsNotEmpty + "!"); this.bedNameTextBox.Focus(); return; } this.DialogResult = DialogResult.OK; }
public static bool IsStrDate(string strText) { bool result; if (strText.Length != 10) { result = false; } else { string text = strText.Substring(0, 2).Trim(); if (!StringEx.IsStrNumber(text)) { result = false; } else { int num = int.Parse(text); if (num == 0) { result = false; } else { string text2 = strText.Substring(3, 2).Trim(); if (!StringEx.IsStrNumber(text2)) { result = false; } else { int num2 = int.Parse(text2); if (num2 == 0) { result = false; } else { string text3 = strText.Substring(6, 4).Trim(); if (!StringEx.IsStrNumber(text3)) { result = false; } else { int num3 = int.Parse(text3); result = (num3 != 0 && StringEx.IsDate(num, num2, num3)); } } } } } } return(result); }
public static DateTime GetDate(string strText) { DateTime now = DateTime.Now; int length = strText.Length; DateTime result; if (length != 10) { result = now; } else { string text = strText.Substring(0, 2).Trim(); if (!StringEx.IsStrNumber(text)) { result = now; } else { int num = int.Parse(text); string text2 = strText.Substring(3, 2).Trim(); if (!StringEx.IsStrNumber(text2)) { result = now; } else { int num2 = int.Parse(text2); string text3 = strText.Substring(6, 4).Trim(); if (!StringEx.IsStrNumber(text3)) { result = now; } else { int num3 = int.Parse(text3); if (!StringEx.IsDate(num, num2, num3)) { result = now; } else { result = new DateTime(num3, num2, num); } } } } } return(result); }
private void okButton_Click(object sender, EventArgs e) { if (!this.bModify) { int selectedIndex = this.typeNameComboBox.SelectedIndex; if (selectedIndex == -1) { MyMsgBox.MsgError(Properties.Resources.LocationType + " " + Properties.Resources.IsNotSelected + "!"); this.typeNameComboBox.Focus(); return; } string text = this.locationIdTextBox.Text.Trim(); if (text == string.Empty) { MyMsgBox.MsgError(Properties.Resources.LocationID + " " + Properties.Resources.IsNotEmpty + "!"); this.locationIdTextBox.Focus(); return; } if (!StringEx.IsStrNumber(text)) { MyMsgBox.MsgError(Properties.Resources.LocationID + " " + Properties.Resources.IsNumber + "!"); this.locationIdTextBox.Focus(); return; } int num = int.Parse(text); if (num < 1) { MyMsgBox.MsgError(Properties.Resources.LocationID + " > 0 !"); this.locationIdTextBox.Focus(); return; } } if (this.locationNameTextBox.Text.Trim() == string.Empty) { MyMsgBox.MsgError(Properties.Resources.LocationName + " " + Properties.Resources.IsNotEmpty + "!"); this.locationNameTextBox.Focus(); } else { base.DialogResult = DialogResult.OK; } }
private void okButton_Click(object sender, EventArgs e) { if (!this.bModify) { string text = this.employeeIdTextBox.Text.Trim(); if (text == string.Empty) { MyMsgBox.MsgError(Properties.Resources.EmployeeID + " " + Properties.Resources.IsNotEmpty + "!"); this.employeeIdTextBox.Focus(); return; } if (!StringEx.IsStrNumber(text)) { MyMsgBox.MsgError(Properties.Resources.EmployeeID + " " + Properties.Resources.IsNumber + "!"); this.employeeIdTextBox.Focus(); return; } int num = int.Parse(text); if (num < 1) { MyMsgBox.MsgError(Properties.Resources.EmployeeID + " > 0 !"); this.employeeIdTextBox.Focus(); return; } } if (this.firstNameTextBox.Text.Trim() == string.Empty) { MyMsgBox.MsgError(Properties.Resources.FirstName + " " + Properties.Resources.IsNotEmpty + "!"); this.firstNameTextBox.Focus(); } else { if (this.lastNameTextBox.Text.Trim() == string.Empty) { MyMsgBox.MsgError(Properties.Resources.LastName + " " + Properties.Resources.IsNotEmpty + "!"); this.lastNameTextBox.Focus(); } else { if (this.titleTextBox.Text.Trim() == string.Empty) { MyMsgBox.MsgError(Properties.Resources.Title + " " + Properties.Resources.IsNotEmpty + "!"); this.titleTextBox.Focus(); } else { int selectedIndex = this.departmentNameComboBox.SelectedIndex; if (selectedIndex == -1) { MyMsgBox.MsgError(Properties.Resources.Department + " " + Properties.Resources.IsNotSelected + "!"); this.departmentNameComboBox.Focus(); } else { int selectedIndex2 = this.jobNameComboBox.SelectedIndex; if (selectedIndex2 == -1) { MyMsgBox.MsgError(Properties.Resources.Job + " " + Properties.Resources.IsNotSelected + "!"); this.jobNameComboBox.Focus(); } else { int num2 = DateTime.Now.Year - this.birthDateDateTimePicker.Value.Year; if (num2 < 18) { MyMsgBox.MsgError(Properties.Resources.Employee + " >= 18 " + Properties.Resources.Years + "!"); this.birthDateDateTimePicker.Focus(); } else { if (num2 > 60) { MyMsgBox.MsgError(Properties.Resources.Employee + " <= 60 " + Properties.Resources.Years + "!"); this.birthDateDateTimePicker.Focus(); } else { if (this.hireDateDateTimePicker.Value > DateTime.Now) { MyMsgBox.MsgError(Properties.Resources.HireDate + " " + Properties.Resources.Invalid + "!"); this.hireDateDateTimePicker.Focus(); } else { if (this.hireDateDateTimePicker.Value.Year - 18 < this.birthDateDateTimePicker.Value.Year) { MyMsgBox.MsgError(Properties.Resources.HireDate + " " + Properties.Resources.Invalid + "!"); this.hireDateDateTimePicker.Focus(); } else { if (this.addressTextBox.Text.Trim() == string.Empty) { MyMsgBox.MsgError(Properties.Resources.Address + " " + Properties.Resources.IsNotEmpty + "!"); this.addressTextBox.Focus(); } else { if (this.cityTextBox.Text.Trim() == string.Empty) { MyMsgBox.MsgError(Properties.Resources.City + " " + Properties.Resources.IsNotEmpty + "!"); this.cityTextBox.Focus(); } else { base.DialogResult = DialogResult.OK; } } } } } } } } } } } }