private void Button_Add_Engineer_Click(object sender, RoutedEventArgs e) { if (Button_Add_Engineer.Content == "Add Engineer") { Engineer_Personality EP = new Engineer_Personality(); EP.Engineer_ID1 = Convert.ToInt32(textBox_EngineerID.Text); EP.First_Name1 = textBox_First_Name.Text; EP.Last_Name1 = textBox_Last_Name.Text; EP.Father_Name1 = textBox_Father_Name.Text; EP.Mather_Name1 = textBox_Mother_Name.Text; EP.Place_of_Birth1 = textBox_Place_of_Birth.Text; EP.Date_of_Birth1 = Convert.ToDateTime(DatePicker_Death_Date.Text);; EP.National_Number1 = Convert.ToDouble(textBox_Nation_Number.Text); EP.Sex1 = comboBox_Sex.Text; EP.Nationality1 = textBox_Nationality.Text; EP.Mobile_Number1 = Convert.ToInt32(textBox_Mobile_Number.Text); EP.E_Mail1 = textBox_E_Mail.Text; EP.University1 = comboBox_University.Text; EP.Year_of_Study1 = Convert.ToInt32(textBox_Year_of_Study.Text); EP.Semester1 = comboBox_Semester.Text; EP.Section1 = textBox_Section.Text; try { EP.Date_of_Eretirement1 = Convert.ToDateTime(DatePicker_Retirement_Date.Text); } catch { EP.Date_of_Eretirement1 = null; } try { EP.Date_of_Death1 = Convert.ToDateTime(DatePicker_Death_Date); } catch { EP.Date_of_Death1 = null; } if (checkBox_Idintity_Card.IsChecked == true) { EP.Receiving_Identity_Card1 = true; } else { EP.Receiving_Identity_Card1 = false; } if (checkBox_Oath.IsChecked == true) { EP.Oath_Interpretation1 = true; } else { EP.Oath_Interpretation1 = false; } EP.Moved_From1 = textBox_Moved_From.Text; EP.License1 = comboBox_License.Text; EP.Specialization1 = comboBox_Specialization.Text; EP.AddEngineer(); for (int i = 1; i <= 3; i++) { Engineer_Address EA = new Engineer_Address(); EA.Address_ID1 = i; if (i == 2) { EA.The_Ward1 = textBox_Area_Work.Text; EA.The_Street1 = textBox_Street_Work.Text; EA.Phone1 = Convert.ToInt32(textBox_Phone_Work.Text); EA.Extra_nformation1 = textBox_Extra_Info_Work.Text; EA.Engineer_ID1 = Convert.ToInt32(textBox_EngineerID.Text); EA.The_City1 = "Aleppo"; } else if (i == 1) { EA.The_Ward1 = textBox_Area_Temporary_Living.Text; EA.The_Street1 = textBox_Street_Temporary_Living.Text; EA.Phone1 = Convert.ToInt32(textBox_Phone_Temporary_Living.Text); EA.Extra_nformation1 = textBox_Extra_Info_Temporary_Living.Text; EA.Engineer_ID1 = Convert.ToInt32(textBox_EngineerID.Text); EA.The_City1 = "Aleppo"; } else if (i == 3) { EA.The_Ward1 = textBox__Area_Permanent_Living.Text; EA.The_Street1 = textBox_Permanent_Living.Text; EA.Phone1 = Convert.ToInt32(textBox_Phone_Permanent_Living.Text); EA.Extra_nformation1 = textBox_Extra_Info_Permanent_Living.Text; EA.Engineer_ID1 = Convert.ToInt32(textBox_EngineerID.Text); EA.The_City1 = "Aleppo"; } } } else if (Button_Add_Engineer.Content == "Update Engineer") { Engineer_Personality EP = new Engineer_Personality(); EP.Engineer_ID1 = Convert.ToInt32(textBox_EngineerID.Text); EP.First_Name1 = textBox_First_Name.Text; EP.Last_Name1 = textBox_Last_Name.Text; EP.Father_Name1 = textBox_Father_Name.Text; EP.Mather_Name1 = textBox_Mother_Name.Text; EP.Place_of_Birth1 = textBox_Place_of_Birth.Text; EP.Date_of_Birth1 = Convert.ToDateTime(DatePicker_Date_of_Birth.Text); EP.National_Number1 = Convert.ToDouble(textBox_Nation_Number.Text); EP.Sex1 = comboBox_Sex.Text; EP.Nationality1 = textBox_Nationality.Text; EP.Mobile_Number1 = Convert.ToInt32(textBox_Mobile_Number.Text); EP.E_Mail1 = textBox_E_Mail.Text; EP.University1 = comboBox_University.Text; EP.Year_of_Study1 = Convert.ToInt32(textBox_Year_of_Study.Text); EP.Semester1 = comboBox_Semester.Text; EP.Section1 = textBox_Section.Text; try { EP.Date_of_Eretirement1 = Convert.ToDateTime(DatePicker_Retirement_Date.Text); } catch { EP.Date_of_Eretirement1 = null; } try { EP.Date_of_Death1 = Convert.ToDateTime(DatePicker_Death_Date); } catch { EP.Date_of_Death1 = null; } if (checkBox_Idintity_Card.IsChecked == true) { EP.Receiving_Identity_Card1 = true; } else { EP.Receiving_Identity_Card1 = false; } if (checkBox_Oath.IsChecked == true) { EP.Oath_Interpretation1 = true; } else { EP.Oath_Interpretation1 = false; } EP.Moved_From1 = textBox_Moved_From.Text; EP.License1 = comboBox_License.Text; EP.Specialization1 = comboBox_Specialization.Text; string s = EP.UpEngineer(); for (int i = 1; i <= 3; i++) { Engineer_Address EA = new Engineer_Address(); EA.Address_ID1 = i; if (i == 2) { EA.The_Ward1 = textBox_Area_Work.Text; EA.The_Street1 = textBox_Street_Work.Text; EA.Phone1 = Convert.ToInt32(textBox_Phone_Work.Text); EA.Extra_nformation1 = textBox_Extra_Info_Work.Text; EA.Engineer_ID1 = Convert.ToInt32(textBox_EngineerID.Text); EA.The_City1 = "Aleppo"; } else if (i == 1) { EA.The_Ward1 = textBox_Area_Temporary_Living.Text; EA.The_Street1 = textBox_Street_Temporary_Living.Text; EA.Phone1 = Convert.ToInt32(textBox_Phone_Temporary_Living.Text); EA.Extra_nformation1 = textBox_Extra_Info_Temporary_Living.Text; EA.Engineer_ID1 = Convert.ToInt32(textBox_EngineerID.Text); EA.The_City1 = "Aleppo"; } else if (i == 3) { EA.The_Ward1 = textBox__Area_Permanent_Living.Text; EA.The_Street1 = textBox_Permanent_Living.Text; EA.Phone1 = Convert.ToInt32(textBox_Phone_Permanent_Living.Text); EA.Extra_nformation1 = textBox_Extra_Info_Permanent_Living.Text; EA.Engineer_ID1 = Convert.ToInt32(textBox_EngineerID.Text); EA.The_City1 = "Aleppo"; } } } }
private void Button_View_Click(object sender, RoutedEventArgs e) { try { DataRowView row = (DataRowView)dataGrid.SelectedItems[0]; DataLoad DataLoad_Form = new DataLoad(); EP.Engineer_ID1 = Convert.ToInt32(row[0].ToString()); DataTable DT = EP.FindEngineer(); DataRow DR; for (int i = 0; i < DT.Rows.Count; i++) { DR = DT.Rows[i]; DataLoad_Form.textBox_EngineerID.Text = DR.ItemArray[0].ToString(); DataLoad_Form.textBox_First_Name.Text = DR.ItemArray[1].ToString(); DataLoad_Form.textBox_Last_Name.Text = DR.ItemArray[2].ToString(); DataLoad_Form.textBox_Father_Name.Text = DR.ItemArray[3].ToString(); DataLoad_Form.textBox_Mother_Name.Text = DR.ItemArray[4].ToString(); DataLoad_Form.textBox_Place_of_Birth.Text = DR.ItemArray[5].ToString(); DataLoad_Form.DatePicker_Date_of_Birth.Text = (Convert.ToDateTime(DR.ItemArray[6]).ToShortDateString()); DataLoad_Form.textBox_Nation_Number.Text = DR.ItemArray[7].ToString(); DataLoad_Form.comboBox_Sex.Text = DR.ItemArray[8].ToString(); DataLoad_Form.textBox_Nationality.Text = DR.ItemArray[9].ToString(); DataLoad_Form.textBox_Mobile_Number.Text = "0" + DR.ItemArray[10].ToString(); DataLoad_Form.textBox_E_Mail.Text = DR.ItemArray[11].ToString(); DataLoad_Form.comboBox_University.Text = DR.ItemArray[12].ToString(); DataLoad_Form.comboBox_University.Text = DR.ItemArray[12].ToString(); DataLoad_Form.textBox_Year_of_Study.Text = DR.ItemArray[13].ToString(); List <string> items1 = new List <string>(); items1.Add(DR.ItemArray[14].ToString()); DataLoad_Form.comboBox_Semester.ItemsSource = items1; DataLoad_Form.comboBox_Semester.Text = DR.ItemArray[14].ToString(); DataLoad_Form.comboBox_License.Text = DR.ItemArray[15].ToString(); DataLoad_Form.DatePicker_Retirement_Date.Text = DR.ItemArray[16].ToString(); DataLoad_Form.DatePicker_Death_Date.Text = DR.ItemArray[17].ToString(); DataLoad_Form.checkBox_Idintity_Card.IsChecked = Convert.ToBoolean(DR.ItemArray[18].ToString()); DataLoad_Form.checkBox_Oath.IsChecked = Convert.ToBoolean(DR.ItemArray[19].ToString()); DataLoad_Form.textBox_Moved_From.Text = DR.ItemArray[20].ToString(); List <string> items2 = new List <string>(); items2.Add(DR.ItemArray[21].ToString()); //DataLoad_Form.comboBox_Section.ItemsSource = items2; //DataLoad_Form.comboBox_Section.Text = DR.ItemArray[21].ToString(); List <string> items3 = new List <string>(); items3.Add(DR.ItemArray[22].ToString()); DataLoad_Form.comboBox_Specialization.ItemsSource = items3; DataLoad_Form.comboBox_Specialization.Text = DR.ItemArray[22].ToString(); } for (int i = 1; i <= 3; i++) { Engineer_Address EA = new Engineer_Address(); EA.Engineer_ID1 = Convert.ToInt32(row[0].ToString()); EA.Address_ID1 = i; DataTable dt = EA.Find_Engineer_Address(); DataRow DR1; for (int j = 0; j < dt.Rows.Count; j++) { DR1 = dt.Rows[j]; if (i == 2) { DataLoad_Form.textBox_Area_Work.Text = DR1.ItemArray[2].ToString(); DataLoad_Form.textBox_Street_Work.Text = DR1.ItemArray[3].ToString(); DataLoad_Form.textBox_Phone_Work.Text = DR1.ItemArray[4].ToString(); DataLoad_Form.textBox_Extra_Info_Work.Text = DR1.ItemArray[5].ToString(); } else if (i == 1) { DataLoad_Form.textBox_Area_Temporary_Living.Text = DR1.ItemArray[2].ToString(); DataLoad_Form.textBox_Street_Temporary_Living.Text = DR1.ItemArray[3].ToString(); DataLoad_Form.textBox_Phone_Temporary_Living.Text = DR1.ItemArray[4].ToString(); DataLoad_Form.textBox_Extra_Info_Temporary_Living.Text = DR1.ItemArray[5].ToString(); } else if (i == 3) { DataLoad_Form.textBox__Area_Permanent_Living.Text = DR1.ItemArray[2].ToString(); DataLoad_Form.textBox_Permanent_Living.Text = DR1.ItemArray[3].ToString(); DataLoad_Form.textBox_Phone_Permanent_Living.Text = DR1.ItemArray[4].ToString(); DataLoad_Form.textBox_Extra_Info_Permanent_Living.Text = DR1.ItemArray[5].ToString(); } } } DataLoad_Form.Button_Add_Engineer.Content = "Update Engineer"; DataLoad_Form.Show(); } catch (Exception) { } }