Exemple #1
0
        protected void gvChildren_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                ChildrenDTO dataItem = e.Row.DataItem as ChildrenDTO;

                e.Row.Cells[7].Text  = string.Format("{0:MM/dd/yyyy}", dataItem.DOB);
                e.Row.Cells[10].Text = string.Format("{0:MM/dd/yyyy}", dataItem.EnrollmentDate);
                e.Row.Cells[11].Text = string.Format("{0:MM/dd/yyyy}", dataItem.DismisalDate);

                Label lbl;

                lbl = e.Row.FindControl("lblScheduledDays") as Label;

                if (lbl != null)
                {
                    lbl.Text = VIPHelpers.formatScheduledDates(dataItem.ExcludedDays);
                }

                lbl = e.Row.FindControl("lblParentName") as Label;

                if (lbl != null)
                {
                    lbl.Text = dataItem.ParentFirstName + " " + dataItem.ParentLastName;
                }
            }
        }
Exemple #2
0
        protected void gvChildren_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Edit")
            {
                // Convert the row index stored in the CommandArgument
                // property to an Integer.
                int index = int.Parse(e.CommandArgument.ToString());

                // Retrieve the row that contains the button clicked
                // by the user from the Rows collection.
                GridViewRow row = this.gvChildren.Rows[index];

                this.hidChildId.Value = this.gvChildren.DataKeys[index].Values["Id"].ToString();

                var repo = new DataRepo();

                ChildrenDTO dataItem = repo.getChild(int.Parse(this.hidChildId.Value));

                this.chkIsActive.Checked = dataItem.isActive;

                this.ddlCenter.SelectedValue = dataItem.CenterId.ToString();
                ddlCenter_SelectedIndexChanged(null, new EventArgs());

                this.ddlGroup.SelectedValue = dataItem.GroupId.ToString();

                this.FirstName.Text = dataItem.FirstName;
                this.LastName.Text  = dataItem.LastName;
                this.lblDOB.Text    = string.Format("DOB (Age: {0:0#})", VIPHelpers.calculateAge(dataItem.DOB));
                this.DOB.Text       = dataItem.DOB.ToString("MM/dd/yyyy");

                this.setExcludedScheduleDays(dataItem.ExcludedDays);

                this.EnrollmentDate.Text = dataItem.EnrollmentDate.ToString("MM/dd/yyyy");
                this.DismisalDate.Text   = (dataItem.DismisalDate.HasValue) ? ((DateTime)dataItem.DismisalDate).ToString("MM/dd/yyyy") : string.Empty;

                this.ParentFirstName.Text = (string.IsNullOrEmpty(dataItem.ParentFirstName)) ? string.Empty : dataItem.ParentFirstName;
                this.ParentLastName.Text  = (string.IsNullOrEmpty(dataItem.ParentLastName)) ? string.Empty : dataItem.ParentLastName;
                this.Address.Text         = (string.IsNullOrEmpty(dataItem.Address)) ? string.Empty : dataItem.Address;
                this.City.Text            = (string.IsNullOrEmpty(dataItem.City)) ? string.Empty : dataItem.City;
                this.State.SelectedValue  = dataItem.State;
                this.Zip.Text             = (string.IsNullOrEmpty(dataItem.Zip)) ? string.Empty : dataItem.Zip;
                this.Phone.Text           = dataItem.Phone;
                this.Email.Text           = dataItem.Email;
                this.chkNotify.Checked    = dataItem.Notify;

                this.butSave.Text = "Save";

                e.Handled = true;

                this.FirstName.Focus();
            }
        }