private void modifyEmployeeToolStripMenuItem_Click(object sender, EventArgs e) { EmployeeInfo employeeInfo = this.TheSqlData.ReaderEmployeeInfo(this.iEmployeeID); if (employeeInfo != null) { int num = this.iEmployeeID; string text = employeeInfo.strFirstName; string text2 = employeeInfo.strLastName; bool flag = employeeInfo.bMenOrWomen; DateTime dateTime = employeeInfo.dtBirthDate; string text3 = employeeInfo.strTitle; 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 = employeeInfo.iDepartmentID; string strDepartmentName = employeeInfo.strDepartmentName; int num3 = employeeInfo.iDepartmentID; string strJobName = employeeInfo.strJobName; DateTime dateTime2 = employeeInfo.dtHireDate; string text4 = employeeInfo.strAddress; string text5 = employeeInfo.strCity; string text6 = employeeInfo.strPhone; string text7 = employeeInfo.strNote; Form9 form = new Form9(); form.bModify = true; 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 = flag; form.The_dtBirthDate = dateTime; form.The_strTitle = text3; form.The_iDepartmentID = num2; form.The_strDepartmentName = strDepartmentName; form.The_iJobID = num3; form.The_strJobName = strJobName; form.The_dtHireDate = dateTime2; form.The_strAddress = text4; form.The_strCity = text5; form.The_strPhone = text6; form.The_strNote = text7; if (form.ShowDialog(this) == DialogResult.OK) { text = form.The_strFirstName; text2 = form.The_strLastName; flag = form.The_bMenOrWomen; dateTime = form.The_dtBirthDate; text3 = form.The_strTitle; num2 = form.The_iDepartmentID; num3 = form.The_iJobID; dateTime2 = form.The_dtHireDate; text4 = form.The_strAddress; text5 = form.The_strCity; text6 = form.The_strPhone; text7 = form.The_strNote; if (this.TheSqlData.UpdateEmployeeInfo(num, text, text2, flag, dateTime, text3, num2, num3, dateTime2, text4, text5, text6, text7)) { this.Employees = this.TheSqlData.ReaderEmployees(); this.ShowEmployeesForListView(this.listView1, this.Employees); this.SetListViewItemSelectFocus(this.listView1, this.iItem); } else { MessageBox.Show(string.Concat(new string[] { Properties.Resources.Update, " ", Properties.Resources.EmployeeInfo, " ", Properties.Resources.Failure, "!" })); } } } } } }
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; } } } } } }