private bool HasYearPrefix(DateTimeLayoutVM dateTimeLayout) { if (dateTimeLayout.CalendarEra == DateTimeLayoutCalendarEra.Japanese || dateTimeLayout.CalendarEra == DateTimeLayoutCalendarEra.Western) { return(true); } return(false); }
private void WriteDateTimeResponse(Body body, QuestionVM question) { ResponseVM response = question.Response; DateTimeLayoutVM dateTimeLayout = (DateTimeLayoutVM)response.Layout; Table table = CreateFilledTable(); string prefix = null; if (HasRange(response)) { prefix = Resources.FromTo; } if (config.IsLanguageEn) { TableRow row1 = CreateDateTimeResponseRowEn(question, prefix); table.Append(row1); if (HasRange(response)) { TableRow row2 = CreateDateTimeResponseRowEn(question, " "); table.Append(row2); } } else { TableRow row1 = CreateDateTimeResponseRowJa(question, prefix); table.Append(row1); if (HasRange(response)) { TableRow row2 = CreateDateTimeResponseRowJa(question, " "); table.Append(row2); } } body.Append(table); }
private TableRow CreateDateTimeResponseRowEn(QuestionVM question, string prefix) { ResponseVM response = question.Response; DateTimeLayoutVM dateTimeLayout = (DateTimeLayoutVM)response.Layout; TableRow tableRow = new TableRow(); TableCell cell = null; List <TableCell> cells = null; //input field of month if (HasMonth(response)) { cell = CreateNoBorderCell(Resources.WordMonth); tableRow.Append(cell); cells = CreateNumberInputCells(dateTimeLayout.Style, 2); tableRow.Append(cells); } //Input field of Day if (HasDay(response)) { cell = CreateNoBorderCell(Resources.WordDay); tableRow.Append(cell); cells = CreateNumberInputCells(dateTimeLayout.Style, 2); tableRow.Append(cells); } //Input field of Year string yearLabel = Resources.WordYear; if (dateTimeLayout.CalendarEra == DateTimeLayoutCalendarEra.Japanese) { yearLabel += "[" + Resources.JapaneseEraTSH + "]"; } cell = CreateNoBorderCell(yearLabel); tableRow.Append(cell); cells = CreateNumberInputCells(dateTimeLayout.Style, 4); tableRow.Append(cells); //input field of time if (HasTime(response)) { cells = CreateNumberInputCells(dateTimeLayout.Style, 2); tableRow.Append(cells); CreateNoBorderCell(":"); cells = CreateNumberInputCells(dateTimeLayout.Style, 2); tableRow.Append(cells); } if (!string.IsNullOrEmpty(prefix)) { tableRow.Append(CreateNoBorderCell(prefix)); } TableCell lastCell = CreateLastNoBorderCell(); tableRow.Append(lastCell); return(tableRow); }
private TableRow CreateDateTimeResponseRowJa(QuestionVM question, string prefix) { ResponseVM response = question.Response; DateTimeLayoutVM dateTimeLayout = (DateTimeLayoutVM)response.Layout; TableRow tableRow = new TableRow(); //Prefix of Input field of Year if (HasYearPrefix(dateTimeLayout)) { string text = dateTimeLayout.CalendarEra == DateTimeLayoutCalendarEra.Japanese ? Resources.JapaneseEraTSH : Resources.WesternEra; //Create a cell with no right and left border TableCell calendarEraCell = CreateNoBorderCell(text); tableRow.Append(calendarEraCell); } //Input field of Year List <TableCell> cells = CreateNumberInputCells(dateTimeLayout.Style, 4); tableRow.Append(cells); //Postfix of Input field of Year TableCell yearLabelCell = CreateNoBorderCell(Resources.WordYear); tableRow.Append(yearLabelCell); //input field of month if (HasMonth(response)) { cells = CreateNumberInputCells(dateTimeLayout.Style, 2); tableRow.Append(cells); TableCell monthLabelCell = CreateNoBorderCell(Resources.WordMonth); tableRow.Append(monthLabelCell); } //Input field of Day if (HasDay(response)) { cells = CreateNumberInputCells(dateTimeLayout.Style, 2); tableRow.Append(cells); TableCell dayLabelCell = CreateNoBorderCell(Resources.WordDay); tableRow.Append(dayLabelCell); } //input field of time if (HasTime(response)) { cells = CreateNumberInputCells(dateTimeLayout.Style, 2); tableRow.Append(cells); TableCell hourLabelCell = CreateNoBorderCell(Resources.WordHour); tableRow.Append(hourLabelCell); cells = CreateNumberInputCells(dateTimeLayout.Style, 2); tableRow.Append(cells); TableCell minLabelCell = CreateNoBorderCell(Resources.WordMinute); tableRow.Append(minLabelCell); } if (!string.IsNullOrEmpty(prefix)) { tableRow.Append(CreateNoBorderCell(prefix)); } TableCell lastCell = CreateLastNoBorderCell(); tableRow.Append(lastCell); return(tableRow); }