private void Indigency_Button(object sender, RoutedEventArgs e) { var rowSelected = v_data_grid.SelectedCells[0].Item as Resident; Indigent indgcy = new Indigent(); indgcy.v_name1.Text = $"{rowSelected.FirstName} {rowSelected.MiddleName} {rowSelected.LastName}"; indgcy.v_name2.Text = $"{rowSelected.FirstName} {rowSelected.MiddleName} {rowSelected.LastName}"; indgcy.v_name3.Text = $"{rowSelected.FirstName} {rowSelected.MiddleName} {rowSelected.LastName}"; indgcy.v_civilstat.Text = rowSelected.CivilStatus; indgcy.v_day.Text = DateTime.Now.Day.ToString(); indgcy.v_month.Text = $"{DateTime.Now.Month} {DateTime.Now.Year}"; indgcy.v_age.Text = ComputeAge((DateTime)rowSelected.BirthDate).ToString(); indgcy.Show(); }
private void FillList() { DBConnection.cmd.CommandType = CommandType.StoredProcedure; if (Properties.Settings.Default.nameBranch == Properties.Settings.Default.nameOffice) { DBConnection.cmd.CommandText = "sp_displayIndigentBranch"; DBConnection.cmd.Parameters.Add(new SqlParameter("@Branch", SqlDbType.Int)); DBConnection.cmd.Parameters["@Branch"].Value = Properties.Settings.Default.Branch; } else { DBConnection.cmd.CommandText = "sp_displayIndigentOffice"; DBConnection.cmd.Parameters.Add(new SqlParameter("@Office", SqlDbType.Int)); DBConnection.cmd.Parameters["@Office"].Value = Properties.Settings.Default.Office; } DBConnection.cmd.Parameters.Add(new SqlParameter("@Success", SqlDbType.Int)); DBConnection.cmd.Parameters["@Success"].Direction = ParameterDirection.Output; Indigent TI; try { list.Clear(); DBConnection.OpenConnection(); DBConnection.reader = DBConnection.cmd.ExecuteReader(); while (DBConnection.reader.Read()) { TI = new Indigent(); TI.Ssn = DBConnection.reader.GetInt64(0).ToString(); TI.SDate = DBConnection.reader.GetDateTime(1); TI.RequestStatus2 = DBConnection.reader.GetString(2); TI.FName = DBConnection.reader.GetString(3); TI.MName = DBConnection.reader.GetString(4); TI.GName = DBConnection.reader.GetString(5); TI.LName = DBConnection.reader.GetString(6); TI.MotherName = DBConnection.reader.GetString(7); TI.DialCode = DBConnection.reader.GetString(8); TI.Number = DBConnection.reader.GetString(9); TI.TypeAssistance = DBConnection.reader.GetString(10); TI.SocialStatus2 = DBConnection.reader.GetString(11); TI.Nationality = DBConnection.reader.GetString(12); TI.PersonalCardNO = DBConnection.reader.GetString(13); TI.PassportNO = DBConnection.reader.GetString(14); TI.Email = DBConnection.reader.GetString(15); TI.Gender2 = DBConnection.reader.GetString(16); TI.Scribe_ssn2 = DBConnection.reader.GetString(17); TI.Office_no2 = DBConnection.reader.GetString(18); TI.IND_ID = DBConnection.reader.GetInt32(19); list.Add(TI); } _list2.Clear(); _list2.AddRange(list.ToList <Indigent>()); } catch (Exception ex) { MessageBox.Show("خطا في عرض البيانات" + Environment.NewLine + ex.Message.ToString(), "", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading); } finally { DBConnection.CloseConnection(); } }