async Task <DataTable> FillDataTable()
        {
            var seniors = await SeniorsRepository.GetSeniorsAsync();

            using (var dt = new DataTable())
            {
                dt.Columns.Add("Id", typeof(int));
                dt.Columns.Add("SeniorId", typeof(string));
                dt.Columns.Add("FullName", typeof(string));
                dt.Columns.Add("Dob", typeof(DateTime));
                dt.Columns.Add("MaritalStatus", typeof(string));
                dt.Columns.Add("ContactNo", typeof(string));
                dt.Columns.Add("Religion", typeof(string));
                dt.Columns.Add("Barangay", typeof(string));
                dt.Columns.Add("Municipality", typeof(string));
                dt.Columns.Add("Province", typeof(string));
                foreach (var senior in seniors)
                {
                    dt.Rows.Add(senior.Id, senior.SeniorID,
                                $"{senior.LastName}, {senior.FirstName} {senior.MiddleName}", senior.DOB, senior.MaritialStatus,
                                senior.ContactNum, senior.Religion, senior.Barangay, senior.Municipality,
                                senior.Province);
                }
                return(dt);
            }
        }
示例#2
0
        protected async void btnRegister_Onclick(object sender, EventArgs e)
        {
            try
            {
                var senior = new SeniorsModel()
                {
                    SeniorID       = txtseniorID.Text,
                    FirstName      = txtfirstname.Text,
                    MiddleName     = txtmiddlename.Text,
                    LastName       = txtlastname.Text,
                    Gender         = rblGender.SelectedItem.Value,
                    DOB            = Convert.ToDateTime(txtDob.Text, CultureInfo.InvariantCulture),
                    MaritialStatus = rblMS.SelectedItem.Value,
                    ContactNum     = txtcontactnum.Text,
                    Religion       = txtreligion.Text,
                    Occupation     = txtoccupation.Text,
                    Barangay       = txtbarangay.Text,
                    Municipality   = txtmunicipality.Text,
                    Province       = txtprovince.Text,
                    Photo          = fuPhoto.FileBytes
                };
                await SeniorsRepository.InsertSeniorAsync(senior);

                Response.Write(@"<script>alert('Record Successfully Created!');</script>");
                ResetForm();
            }
            catch (Exception exception)
            {
                Response.Write($@"<script>alert('${exception.Message}');</script>");
            }
        }
示例#3
0
        protected async void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var id = Request.QueryString["Id"];
                if (!string.IsNullOrEmpty(id))
                {
                    var senior = await SeniorsRepository.GetProfileAsync(Convert.ToInt32(id));

                    if (senior != null)
                    {
                        SeniorID.Text         = senior.SeniorID;
                        txtfirstname.Text     = senior.FirstName;
                        txtmiddlename.Text    = senior.MiddleName;
                        txtlastname.Text      = senior.LastName;
                        rblGender.Text        = senior.Gender;
                        txtDob.Text           = senior.DOB.ToShortDateString();
                        rblMaritalStatus.Text = senior.MaritialStatus;
                        contactnum.Text       = senior.ContactNum;
                        religion.Text         = senior.Religion;
                        occupation.Text       = senior.Occupation;
                        brgy.Text             = senior.Barangay;
                        municipality.Text     = senior.Municipality;
                        province.Text         = senior.Province;
                        return;
                    }
                }

                Response.Redirect("~/Pages/Home.aspx", false);
            }
        }