private void OpenOrCloseSerialPort() { this.Cursor = Cursors.WaitCursor; string portName = "COM6"; if (this.comport.IsOpen) { this.comport.Close(); } else { try { this.strPortName = Settings.Default.PortName; this.strStopBits = Settings.Default.StopBits.ToString(); this.strDataBits = Settings.Default.DataBits.ToString(); this.strParity = Settings.Default.Parity.ToString(); this.strBaudRate = Settings.Default.BaudRate.ToString(); this.comport.BaudRate = int.Parse(this.strBaudRate); this.comport.DataBits = int.Parse(this.strDataBits); this.comport.StopBits = (StopBits)Enum.Parse(typeof(StopBits), this.strStopBits); this.comport.Parity = (Parity)Enum.Parse(typeof(Parity), this.strParity); this.comport.PortName = portName; this.comport.DataReceived += new SerialDataReceivedEventHandler(this.port_DataReceived); this.comport.Open(); } catch (Exception ex) { MyMsgBox.MsgError(ex.Message); } } this.Cursor = Cursors.Default; }
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; }
private SoundTempArray LoadSoundTemplate(string sSound_template_code) { SoundTempArray soundTempArray = new SoundTempArray(); SoundTempArray result; try { DataProvider dataProvider = new DataProvider(); string sqlString = "SELECT [sound_template_id],[sound_template_code],[sound_type_id],[sound_id], [nreads] FROM [dbo].[SOUND_TEMPLATES]WHERE sound_template_code = '" + sSound_template_code + "' Order By [orderby]"; SqlDataReader sqlDataReader = dataProvider.excuteQuery(sqlString); while (sqlDataReader.Read()) { int isound_template_id = int.Parse(sqlDataReader[0].ToString()); string ssound_template_code = sqlDataReader[1].ToString(); int isound_type_id = int.Parse(sqlDataReader[2].ToString()); int isound_id = sqlDataReader.IsDBNull(3) ? 0 : int.Parse(sqlDataReader[3].ToString()); int inread = sqlDataReader.IsDBNull(4) ? 0 : int.Parse(sqlDataReader[4].ToString()); SoundTempInfo si = new SoundTempInfo(isound_template_id, ssound_template_code, isound_type_id, isound_id, inread); soundTempArray.Add(si); } sqlDataReader.Close(); } catch (SqlException ex) { MyMsgBox.MsgError(ex.Message); result = new SoundTempArray(); return(result); } result = soundTempArray; 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 SoundExArray LoadSound() { SoundExArray soundExArray = new SoundExArray(); SoundExArray result; try { DataProvider dataProvider = new DataProvider(); string sqlString = "SELECT [sound_id],[sound_code] ,[sound_type] ,[sound_path] FROM [dbo].[SOUNDS]Order by sound_id;"; SqlDataReader sqlDataReader = dataProvider.excuteQuery(sqlString); while (sqlDataReader.Read()) { int i_sound_id = int.Parse(sqlDataReader[0].ToString()); string s_sound_code = sqlDataReader[1].ToString(); int i_sound_type; if (sqlDataReader[2].ToString() != "") { i_sound_type = int.Parse(sqlDataReader[2].ToString()); } else { i_sound_type = 0; } string s_sound_path = sqlDataReader[3].ToString(); SoundExInfo si = new SoundExInfo(i_sound_id, s_sound_code, i_sound_type, s_sound_path); soundExArray.Add(si); } sqlDataReader.Close(); } catch (SqlException ex) { MyMsgBox.MsgError(ex.Message); result = new SoundExArray(); return(result); } result = soundExArray; return(result); }
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; } } } } } } } } } } } }
private void newDepartmentToolStripMenuItem_Click(object sender, EventArgs e) { bool flag = false; bool flag2 = true; int maxValueDepartmentID = this.TheSqlData.GetMaxValueDepartmentID(); if (maxValueDepartmentID != -1) { int num = maxValueDepartmentID + 1; string text = ""; string text2 = ""; while (!flag && flag2) { Form12 form = new Form12(); form.bModify = false; form.The_iDepartmentID = num; form.The_strDepartmentName = text; form.The_strNote = text2; if (form.ShowDialog(this) == DialogResult.OK) { num = form.The_iDepartmentID; text = form.The_strDepartmentName; text2 = form.The_strNote; if (!this.TheSqlData.IsExistDepartmentID(num)) { if (this.TheSqlData.InsertDepartmentInfo(num, text, text2)) { this.Departments = this.TheSqlData.ReaderDepartments(); this.ShowDepartmentsForListView(this.listView1, this.Departments); this.SetListViewItemSelectFocus(this.listView1, this.listView1.Items.Count - 1); flag = true; } else { MessageBox.Show(string.Concat(new string[] { Properties.Resources.Insert, Properties.Resources.DepartmentInfo, " ", Properties.Resources.Failure, "!" })); } } else { MyMsgBox.MsgError(string.Concat(new string[] { Properties.Resources.InfoOfDepartment, ": ", num.ToString(), ". ", text, " ", Properties.Resources.IsExisted, "!" })); } } else { flag2 = false; } } } }
private void newEmployeeToolStripMenuItem_Click(object sender, EventArgs e) { bool flag = false; bool flag2 = true; int maxValueEmployeeID = this.TheSqlData.GetMaxValueEmployeeID(); if (maxValueEmployeeID != -1) { int num = maxValueEmployeeID + 1; string text = ""; string text2 = ""; bool flag3 = false; DateTime the_dtBirthDate = new DateTime(1900, 1, 1); string text3 = ""; DepartmentArray departmentArray = this.TheSqlData.ReaderDepartments(); if (departmentArray.Count != 0) { string[] array = new string[departmentArray.Count]; for (int i = 0; i < departmentArray.Count; i++) { array[i] = departmentArray[i].strDepartmentName; } int[] array2 = new int[departmentArray.Count]; for (int i = 0; i < departmentArray.Count; i++) { array2[i] = departmentArray[i].iDepartmentID; } JobArray jobArray = this.TheSqlData.ReaderJobs(); if (jobArray.Count != 0) { string[] array3 = new string[jobArray.Count]; for (int i = 0; i < jobArray.Count; i++) { array3[i] = jobArray[i].strJobName; } int[] array4 = new int[jobArray.Count]; for (int i = 0; i < jobArray.Count; i++) { array4[i] = jobArray[i].iJobID; } int num2 = 0; string the_strDepartmentName = ""; int num3 = 0; string the_strJobName = ""; DateTime the_dtHireDate = new DateTime(1900, 1, 1); string text4 = ""; string text5 = ""; string text6 = ""; string text7 = ""; while (!flag && flag2) { Form9 form = new Form9(); form.bModify = false; form.The_DepartmentNames = array; form.The_DepartmentIDs = array2; form.The_JobNames = array3; form.The_JobIDs = array4; form.The_iEmployeeID = num; form.The_strFirstName = text; form.The_strLastName = text2; form.The_bMenOrWomen = flag3; form.The_dtBirthDate = the_dtBirthDate; form.The_strTitle = text3; form.The_iDepartmentID = num2; form.The_strDepartmentName = the_strDepartmentName; form.The_iJobID = num3; form.The_strJobName = the_strJobName; form.The_dtHireDate = the_dtHireDate; form.The_strAddress = text4; form.The_strCity = text5; form.The_strPhone = text6; form.The_strNote = text7; if (form.ShowDialog(this) == DialogResult.OK) { num = form.The_iEmployeeID; text = form.The_strFirstName; text2 = form.The_strLastName; flag3 = form.The_bMenOrWomen; the_dtBirthDate = form.The_dtBirthDate; text3 = form.The_strTitle; num2 = form.The_iDepartmentID; the_strDepartmentName = form.The_strDepartmentName; the_strJobName = form.The_strJobName; num3 = form.The_iJobID; the_dtHireDate = form.The_dtHireDate; text4 = form.The_strAddress; text5 = form.The_strCity; text6 = form.The_strPhone; text7 = form.The_strNote; if (!this.TheSqlData.IsExistEmployeeID(num)) { if (this.TheSqlData.InsertEmployeeInfo(num, text, text2, flag3, the_dtBirthDate, text3, num2, num3, the_dtHireDate, text4, text5, text6, text7)) { this.Employees = this.TheSqlData.ReaderEmployees(); this.ShowEmployeesForListView(this.listView1, this.Employees); this.SetListViewItemSelectFocus(this.listView1, this.listView1.Items.Count - 1); flag = true; } else { MessageBox.Show(string.Concat(new string[] { Properties.Resources.Insert, Properties.Resources.EmployeeInfo, " ", Properties.Resources.Failure, "!" })); } } else { MyMsgBox.MsgError(string.Concat(new string[] { Properties.Resources.InfoOfEmployee, ": ", num.ToString(), ". ", text, " ", text2, " ", Properties.Resources.IsExisted, "!" })); } } else { flag2 = false; } } } } } }