/// <summary> /// Gets the control data. /// </summary> /// <returns></returns> private AssociationForMatter GetControlData() { try { AssociationForMatter association = new AssociationForMatter(); association.ApplicationId = 1;//PMS association.ProjectId = (Guid)Session[SessionName.ProjectId]; association.RoleId = Convert.ToInt32(_ddlRole.SelectedValue); association.MemberId = new Guid(_hdnMemberId.Value); association.OrganisationId = new Guid(_hdnOrganisationId.Value); association.Description = _txtDescription.Text.Trim(); if (_ccDateFrom.DateText.Length > 0) { association.DateFrom = Convert.ToDateTime(_ccDateFrom.DateText); } else { association.DateFrom = DataConstants.BlankDate; } if (_ccDateTo.DateText.Length > 0) { association.DateTo = Convert.ToDateTime(_ccDateTo.DateText); } else { association.DateTo = DataConstants.BlankDate; } association.Reference = _txtReference.Text.Trim(); association.LetterHead = _txtLetterHeading.Text.Trim(); association.Comment = _txtCommenting.Text.Trim(); association.LinkedProjectId = new Guid(_hdnLinkedProjectId.Value); //Get extended info from the grid List<RoleExtendedInfo> extendedInfo = new List<RoleExtendedInfo>(); foreach (GridViewRow row in _grdAdditionalAssociationInfo.Rows) { string text = string.Empty; decimal number = decimal.Zero; DateTime date = DataConstants.BlankDate; bool hasValue = false; string dataType = ((HiddenField)row.FindControl("_hdnDataType")).Value.ToString().Trim(); int typeId = Convert.ToInt32(((HiddenField)row.FindControl("_hdnTypeId")).Value); TextBox notes = (TextBox)row.Cells[2].FindControl("_txtNotes"); switch (dataType) { case "Date": CalendarControl calendarControl = (CalendarControl)row.Cells[1].FindControl("_cc"); string dateText = calendarControl.DateText.Trim(); if (dateText != string.Empty) { date = Convert.ToDateTime(dateText); hasValue = true; } break; case "Number": TextBox numericTextBox = (TextBox)row.FindControl("_txt"); number = Convert.ToDecimal(numericTextBox.Text); hasValue = (number != decimal.Zero); break; case "Text": TextBox textBox = (TextBox)row.FindControl("_txt"); text = textBox.Text.Trim(); hasValue = (text != string.Empty); break; case "Bool": CheckBox checkBox = (CheckBox)row.FindControl("_chk"); text = Convert.ToInt32(checkBox.Checked).ToString(); hasValue = (text != "0"); break; case "List": DropDownList dropDownList = (DropDownList)row.FindControl("_ddl"); text = dropDownList.SelectedValue.Trim(); hasValue = (text != string.Empty); break; } //Add extended info item if a value was entered if (notes.Text.Trim().Length > 0 || hasValue) { RoleExtendedInfo info = new RoleExtendedInfo(); info.TypeId = typeId; info.Text = text; info.Date = date; info.Number = number; info.Comment = notes.Text.Trim(); extendedInfo.Add(info); } } if (extendedInfo.Count > 0) { association.RoleExtendedInfoDetails = extendedInfo.ToArray(); } return association; } catch (Exception ex) { throw ex; } }
/// <summary> /// Gets the control data. /// </summary> /// <returns></returns> private AssociationForMatter GetControlData() { try { AssociationForMatter association = new AssociationForMatter(); association.ApplicationId = 1;//PMS association.ProjectId = (Guid)Session[SessionName.ProjectId]; association.RoleId = Convert.ToInt32(_ddlRole.SelectedValue); association.MemberId = new Guid(_hdnMemberId.Value); association.OrganisationId = new Guid(_hdnOrganisationId.Value); association.Description = _txtDescription.Text.Trim(); if (_ccDateFrom.DateText.Length > 0) { association.DateFrom = Convert.ToDateTime(_ccDateFrom.DateText); } else { association.DateFrom = DataConstants.BlankDate; } if (_ccDateTo.DateText.Length > 0) { association.DateTo = Convert.ToDateTime(_ccDateTo.DateText); } else { association.DateTo = DataConstants.BlankDate; } association.Reference = _txtReference.Text.Trim(); association.LetterHead = _txtLetterHeading.Text.Trim(); association.Comment = _txtCommenting.Text.Trim(); association.LinkedProjectId = new Guid(_hdnLinkedProjectId.Value); //Get extended info from the grid List <RoleExtendedInfo> extendedInfo = new List <RoleExtendedInfo>(); foreach (GridViewRow row in _grdAdditionalAssociationInfo.Rows) { string text = string.Empty; decimal number = decimal.Zero; DateTime date = DataConstants.BlankDate; bool hasValue = false; string dataType = ((HiddenField)row.FindControl("_hdnDataType")).Value.ToString().Trim(); int typeId = Convert.ToInt32(((HiddenField)row.FindControl("_hdnTypeId")).Value); TextBox notes = (TextBox)row.Cells[2].FindControl("_txtNotes"); switch (dataType) { case "Date": CalendarControl calendarControl = (CalendarControl)row.Cells[1].FindControl("_cc"); string dateText = calendarControl.DateText.Trim(); if (dateText != string.Empty) { date = Convert.ToDateTime(dateText); hasValue = true; } break; case "Number": TextBox numericTextBox = (TextBox)row.FindControl("_txt"); number = Convert.ToDecimal(numericTextBox.Text); hasValue = (number != decimal.Zero); break; case "Text": TextBox textBox = (TextBox)row.FindControl("_txt"); text = textBox.Text.Trim(); hasValue = (text != string.Empty); break; case "Bool": CheckBox checkBox = (CheckBox)row.FindControl("_chk"); text = Convert.ToInt32(checkBox.Checked).ToString(); hasValue = (text != "0"); break; case "List": DropDownList dropDownList = (DropDownList)row.FindControl("_ddl"); text = dropDownList.SelectedValue.Trim(); hasValue = (text != string.Empty); break; } //Add extended info item if a value was entered if (notes.Text.Trim().Length > 0 || hasValue) { RoleExtendedInfo info = new RoleExtendedInfo(); info.TypeId = typeId; info.Text = text; info.Date = date; info.Number = number; info.Comment = notes.Text.Trim(); extendedInfo.Add(info); } } if (extendedInfo.Count > 0) { association.RoleExtendedInfoDetails = extendedInfo.ToArray(); } return(association); } catch (Exception ex) { throw ex; } }