private async void dataGrid1_MouseDoubleClick(object sender, MouseButtonEventArgs e) { try { MyEmployee selectedEmpRow = dataGrid1.SelectedItem as MyEmployee; if (!File.Exists(@"c:\Images\" + selectedEmpRow.EmployeeId + ".jpg")) { byte[] arr = await client.GetArrayAsync(@"c:\temper\Images2\" + selectedEmpRow.EmployeeId + ".jpg"); File.WriteAllBytes(@"c:\Images\" + selectedEmpRow.EmployeeId + ".jpg", arr); } EmployeeCardWindow employeeCardWindow = new EmployeeCardWindow(); employeeCardWindow.IDText = selectedEmpRow.EmployeeId; employeeCardWindow.Refresh(); employeeCardWindow.Show(); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void Edit_Click(object sender, RoutedEventArgs e) { if (passportBox.Text == "" || phoneBox.Text == "" || positionBox.SelectedItem == null || departmentBox.SelectedItem == null || nameBox.Text == "" || photoBox.Text == "") { MessageBox.Show("Set Employee's data..."); } else { try { MyFullEmployee selectedEmp = new MyFullEmployee { FPassport = passportBox.Text, FDepId = departmentBox.SelectedItem.ToString(), FName = nameBox.Text, FPosId = positionBox.SelectedItem.ToString(), FPhone = phoneBox.Text, FAge = Convert.ToInt32(ageBox.SelectedItem), FPhoto = photoBox.SelectedItem.ToString(), FId = IdBox.Text, }; client?.EditEmployee(selectedEmp); this.Close(); EmployeeCardWindow employeeCardWindow = new EmployeeCardWindow(); employeeCardWindow.IDText = IDEdit; employeeCardWindow.Refresh(); employeeCardWindow.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }