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; } } }
public ActionResult CreateChildren([FromBody] ChildrenDTO child) { object obj = schoolService.CreateChildren(child); return(new JsonResult { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = obj }); }
protected void butSave_Click(object sender, EventArgs e) { try { var repo = new DataRepo(); var child = new ChildrenDTO() { CenterId = int.Parse(this.ddlCenter.SelectedValue), GroupId = int.Parse(this.ddlGroup.SelectedValue), FirstName = this.FirstName.Text, LastName = this.LastName.Text, DOB = DateTime.Parse(this.DOB.Text), ExcludedDays = this.getExcludedScheduleDayNumbers(), EnrollmentDate = DateTime.Parse(this.EnrollmentDate.Text), DismisalDate = (string.IsNullOrEmpty(this.DismisalDate.Text)) ? (DateTime?)null : DateTime.Parse(this.DismisalDate.Text), isActive = this.chkIsActive.Checked, ParentFirstName = this.ParentFirstName.Text, ParentLastName = this.ParentLastName.Text, Address = this.Address.Text, City = this.City.Text, State = (this.State.SelectedIndex == 0) ? null : this.State.SelectedValue, Zip = this.Zip.Text, Phone = this.Phone.Text, Email = this.Email.Text, Notify = this.chkNotify.Checked }; int childId = 0; int.TryParse(this.hidChildId.Value, out childId); if (childId == 0) { repo.postChild(child); this.writeMessage("The child and their supporting contact was created successfully."); } else { repo.putChild(childId, child); this.writeMessage("The child and their supporting contact was updated successfully."); } this.butSave.Text = "Add"; this.hidChildId.Value = string.Empty; this.populateChildrenGrid(ViewState["SortExpression"].ToString(), this.gridViewSortDirection); } catch (CBSException ex) { this.writeMessage(ex); } catch (Exception ex) { this.writeMessage(ex); } }
public void Edit(int id, ChildrenDTO children) { using (var uow = new UnitOfWork(new DataContext())) { var obj = uow.Childrens.Get(id); obj.Name = children.FullName; obj.Age = children.Age; obj.Occupation = children.Occupation; uow.Childrens.Edit(obj); uow.Complete(); } }
public ChildrenDTO Get(int id) { using (var uow = new UnitOfWork(new DataContext())) { var obj = uow.Childrens.Get(id); var children = new ChildrenDTO(); children.Age = obj.Age; children.FullName = obj.Name; children.Occupation = obj.Occupation; return(children); } }
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(); } }
public async Task <ActualResult> UpdateAsync(ChildrenDTO item) { try { _context.Entry(_mapper.Map <DAL.Entities.Children>(item)).State = EntityState.Modified; await _context.SaveChangesAsync(); return(new ActualResult()); } catch (Exception exception) { return(new ActualResult(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public void Add(ChildrenDTO children) { using (var uow = new UnitOfWork(new DataContext())) { var obj = new Children(); obj.Name = children.FullName; obj.Age = children.Age; obj.Occupation = children.Occupation; obj.PersonalInfoID = children.PersonalInfoID; uow.Childrens.Add(obj); uow.Complete(); children.ID = obj.ChildrenID; } }
public async Task <ActualResult> CreateAsync(ChildrenDTO item) { try { await _context.Children.AddAsync(_mapperService.Mapper.Map <DAL.Entities.Children>(item)); await _context.SaveChangesAsync(); return(new ActualResult()); } catch (Exception exception) { return(new ActualResult(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult <string> > CreateAsync(ChildrenDTO item) { try { var children = _mapper.Map <DAL.Entities.Children>(item); await _context.Children.AddAsync(children); await _context.SaveChangesAsync(); var hashId = HashHelper.EncryptLong(children.Id); return(new ActualResult <string> { Result = hashId }); } catch (Exception exception) { return(new ActualResult <string>(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public object UpdateChildren(ChildrenDTO childDto) { Child child = UOW.ChildrenRepository.Where(p => p.id.Equals(childDto.id)).First(); child.fullName = childDto.fullName; child.dateOut = childDto.dateOut; child.dateIn = childDto.dateIn; child.address = childDto.address; child.areaId = childDto.Area.id; child.birthDate = childDto.birthDate; child.classId = childDto.Class.id; child.fatherName = childDto.fatherName; child.fatherPhone = childDto.fatherPhone; child.motherName = childDto.motherName; child.motherPhone = childDto.motherPhone; child.sex = childDto.sex; UOW.ChildrenRepository.Update(child); UOW.Commit(); return(childDto); }
public object CreateChildren(ChildrenDTO childDto) { Child child = new Child(); child.id = Guid.NewGuid(); child.fullName = childDto.fullName; child.dateOut = childDto.dateOut; child.dateIn = childDto.dateIn; child.address = childDto.address; child.areaId = childDto.Area.id; child.birthDate = childDto.birthDate; child.classId = childDto.Class.id; child.fatherName = childDto.fatherName; child.fatherPhone = childDto.fatherPhone; child.motherName = childDto.motherName; child.motherPhone = childDto.motherPhone; child.sex = childDto.sex; child = UOW.ChildrenRepository.Insert(child); UOW.Commit(); childDto.id = child.id; return(childDto); }
protected void rptGroupActivities_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { ChildrenDTO child = (ChildrenDTO)e.Item.DataItem; int childId = child.Id; HiddenField hid = (HiddenField)e.Item.FindControl("hidChildId"); hid.Value = childId.ToString(); int DOW = (int)_dailyGroupActivities.DailyGroup.ClassDate.DayOfWeek; string childState = string.Empty; PlaceHolder ph = (PlaceHolder)e.Item.FindControl("phCell"); LinkedList <Control> llControls = new LinkedList <Control>(); cWebHelper.FindControlRecursive(ph, "ddl", ref llControls, false, false); foreach (var ctl in llControls) { DropDownList ddl = (DropDownList)ctl; int activityId = int.Parse(ddl.ID.Split("_".ToCharArray())[1]); var selectedActivity = (from ca in _dailyGroupActivities.ChildDailyGroupActivities where ca.ActivityId == activityId && ca.ChildId == childId select ca.ActivityValueId.ToString()).FirstOrDefault(); if (string.IsNullOrEmpty(selectedActivity)) //No value selected, so use default { //Attendance In/Out? if ((activityId == 8) && ((from gc in _dailyGroupActivities.GroupChildren where gc.Id == childId && (gc.ExcludedDays.Contains(DOW.ToString())) select gc.Id).Any())) { childState = "NotInClass"; ddl.SelectedValue = "26"; //Set Attendance value to out } else { ddl.SelectedValue = (from cav in _dailyGroupActivities.ChildActivityValues where cav.ActivityId == activityId && cav.IsDefault orderby cav.ActivityValue ascending select cav.ActivityValueId.ToString()).FirstOrDefault(); } } else { ddl.SelectedValue = selectedActivity; if ((from cga in _dailyGroupActivities.ChildDailyGroupActivities where cga.ChildId == childId && cga.ActivityId == 8 && cga.ActivityValueId == 26 select cga.ChildId).Any()) { childState = "NotInClass"; } } ddl.CssClass = childState; } Label lbl = (Label)e.Item.FindControl("lblName"); lbl.Text = child.FirstName + " " + child.LastName.Substring(0, 1) + "."; lbl.CssClass = childState; } }