using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using Bowin.Web.Controls.Mvc; using EMIS.Entities; using EMIS.Utility; using EMIS.ViewModel; namespace EMIS.Web.Controls.Score { public static class ScoreEditGridExtensions { public static MvcHtmlString ScoreEditGrid(this HtmlHelper htmlHelper, string id, bool isEditable, bool hasCheckbox, Guid finalExaminationID, IDictionary htmlAttributes = null) { string formulaColumns = string.Empty; var gridOptions = new DataGridOptions { Columns = new List() { new BoundFieldColumn { FieldName="UserID", HeaderText="学生ID", Align=AlignStyle.Center, IsHidden = true }, new BoundFieldColumn { FieldName="No", HeaderText="序号", Align=AlignStyle.Center, Width=0.03 ,CustomFormatFun = "LoginIDColor" }, new BoundFieldColumn { FieldName="LoginID", HeaderText="学号", Align=AlignStyle.Center, Width=0.1 ,CustomFormatFun = "LoginIDColor" }, new BoundFieldColumn { FieldName="UserName", HeaderText="姓名", Align=AlignStyle.Center, Width=0.04 ,CustomFormatFun = "UserNameColor" }, new BoundFieldColumn { FieldName="ExamsCategoryName", HeaderText="考试性质", Align=AlignStyle.Center, Width=0.05 ,CustomFormatFun = "ExamsCategoryNameColor" }, }, DataSourceUrl = UrlHelper.GenerateContentUrl("~/Score/GetStudentScoreInputView?finalExaminationID=" + finalExaminationID, htmlHelper.ViewContext.HttpContext), ID = id, IsPagination = false, IsPostBack = true }; if (hasCheckbox) { gridOptions.Columns.Insert(0, new CheckBoxFieldColumn { HeaderText = "", FieldName = "UserID" }); } var scoreDynamicTypes = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ScoreType); foreach (var item in scoreDynamicTypes) { if (isEditable) { gridOptions.Columns.Add(new TextBoxColumn { FieldName = "ScoreDetail[" + item.Value.ToString() + "].Score", HeaderText = item.Name, Align = AlignStyle.Center, Width = 0.04, EnableFieldName = "ScoreDetail[" + item.Value.ToString() + "].IsCanEdit", Validator = new OnlyMoneyValidator() { Required = false } }); } else { gridOptions.Columns.Add(new BoundFieldColumn { FieldName = "ScoreDetail[" + item.Value.ToString() + "].Score", HeaderText = item.Name, Align = AlignStyle.Center, Width = 0.04 }); } } gridOptions.Columns.Add(new BoundFieldColumn { FieldName = "TotalScore", HeaderText = "总成绩", Align = AlignStyle.Center, Width = 0.04, CustomFormatFun = "TotalScoreColor" }); gridOptions.Columns.Add(new BoundFieldColumn { FieldName = "Credit", HeaderText = "学分", Align = AlignStyle.Center, Width = 0.03, CustomFormatFun = "CreditColor", Formatter = Formatter.OnlyYearMonthDay }); gridOptions.Columns.Add(new BoundFieldColumn { FieldName = "GradePoint", HeaderText = "绩点", Align = AlignStyle.Center, Width = 0.03, CustomFormatFun = "GradePointColor" }); if (isEditable) { gridOptions.Columns.Add(new DictionaryDropdownListColumn { EnableFieldName = isEditable ? "IsCanEdit" : "NotEnable", FieldName = "ExamsStateID", HeaderText = "考试状态", Align = AlignStyle.Center, DictionaryType = EMIS.ViewModel.DictionaryItem.CF_ExamsState, Width = 0.07 }); gridOptions.Columns.Add(new TextBoxColumn { FieldName = "Remarks", HeaderText = "备注", Align = AlignStyle.Center, Width = 0.1 }); } else { gridOptions.Columns.Add(new BoundFieldColumn { FieldName = "ExamsStateName", HeaderText = "考试状态", Align = AlignStyle.Center, Width = 0.07 }); gridOptions.Columns.Add(new BoundFieldColumn { FieldName = "Remarks", HeaderText = "备注", Align = AlignStyle.Center, Width = 0.1 }); } return htmlHelper.DataGrid(gridOptions, htmlAttributes); } } }