//评分标准 private void FillScoreStandard(CSPeriodScoreStandard dr, CSWorksTypeScoreStandard dr1, string i) { StringBuilder str = new StringBuilder(); str.AppendLine("<div class=\"comments-scores-model\">"); int standardID = dr == null ? dr1.StandardID : dr.StandardID; int score = dr == null ? (int)dr1.Score : (int)dr.Score; string subStandard = dr == null ? dr1.StandardDescription : dr.StandardDescription; string standardName = dr == null ? dr1.StandardName : dr.StandardName; //评分 Panel div = new Panel(); div.ID = "div" + standardID;// dr["StandardID"]; div.CssClass = "comments-scores-modelTitle"; div.Controls.Add(new LiteralControl(standardName + "(" + score + "分)")); TextBox txtBox = new TextBox(); txtBox.ID = "txtFen" + standardID + "_" + score; txtBox.Text = "0"; txtBox.CssClass = "txtcss"; txtBox.Attributes.Add("onfocus", "onft" + i + "(this)"); txtBox.Attributes.Add("onblur", "onbt" + i + "(this)"); txtBox.Attributes.Add("onchange", "checkInput(this)"); div.Controls.Add(txtBox); Image img = new Image(); img.Style.Add("visibility", "hidden"); img.ID = "img" + standardID; img.ImageUrl = "images/dui.png"; div.Controls.Add(img); str.Append("<div class=\"comments-scores-divHidden\" id=\"HiddenDiv" + i + "\">"); str.AppendLine("<ul>"); string[] subsValue = subStandard.Split('\n'); foreach (string strValue in subsValue) { str.AppendLine("<li>" + strValue + "</li>"); } str.AppendLine("</ul>"); str.AppendLine("</div>"); divContent.Controls.Add(div); divContent.Controls.Add(new LiteralControl(str.ToString())); divContent.Controls.Add(new LiteralControl("</div>")); }
private void InitControlDetail(int i, CSPeriodScoreStandard drStandard1, CSWorksTypeScoreStandard drStandard2, ScoreStandard drStandard3, string score, string des, ref Table tbl) { string sName; string sID; string sDes; if (drStandard1 == null) { if (drStandard2 == null) { sName = drStandard3.StandardName; sID = drStandard3.StandardID.ToString(); sDes = drStandard3.Description; } else { sName = drStandard2.StandardName; sID = drStandard2.StandardID.ToString(); sDes = drStandard2.StandardDescription; } } else { sName = drStandard1.StandardName; sID = drStandard1.StandardID.ToString(); sDes = drStandard1.StandardDescription; } TableRow tRow; TableCell tCell; Label lstStandard; TextBox txtContent; tRow = new TableRow(); tCell = new TableCell(); lstStandard = new Label(); lstStandard.Width = 100; lstStandard.ID = "lst" + i.ToString(); lstStandard.Text = sName; tCell.Controls.Add(lstStandard); tRow.Cells.Add(tCell); txtContent = new TextBox(); txtContent.ID = "txtScore" + i.ToString() + "_" + sID; txtContent.Width = 20; if (score != "") { txtContent.Text = score; } tCell = new TableCell(); tCell.Controls.Add(txtContent); tCell.Controls.Add(new LiteralControl("分(设置指标分数)")); tRow.Cells.Add(tCell); tbl.Rows.Add(tRow); lstStandard = new Label(); lstStandard.Width = 400; lstStandard.ID = "des" + i.ToString(); lstStandard.Font.Size = 8; lstStandard.ForeColor = System.Drawing.Color.Gray; lstStandard.Text = sDes; tRow = new TableRow(); tCell = new TableCell(); tCell.ColumnSpan = 2; tCell.Controls.Add(lstStandard); tRow.Cells.Add(tCell); tbl.Rows.Add(tRow); txtContent = new TextBox(); txtContent.ID = "txtDes" + i.ToString(); txtContent.TextMode = TextBoxMode.MultiLine; txtContent.Rows = 5; txtContent.Width = 400; if (des != "") { txtContent.Text = des; } else { txtContent.Text = "分条描述指标的具体评分标准"; } tRow = new TableRow(); tCell = new TableCell(); tCell.ColumnSpan = 2; tCell.Controls.Add(txtContent); tRow.Cells.Add(tCell); tbl.Rows.Add(tRow); }
/// <summary> /// 五个指标共90分 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void btnSave_Click(object sender, EventArgs e) { Table tbl = (Table)divEditContent.Controls[0]; List <CSPeriodScoreStandard> ds = GetPeriodStandarad; List <CSWorksTypeScoreStandard> ds1 = new List <CSWorksTypeScoreStandard> (); string txtScore; string lstValue; string txtDes; List <CSPeriodScoreStandard> drs; if (PeriodID == 0) { ds1 = GetScoreStandardByType; } int result = 0; int i = 0; while (i < DSAllStandard.Count * 3) { lstValue = ((TextBox)tbl.Rows[i].Cells[1].Controls[0]).ID; lstValue = lstValue.Substring(lstValue.IndexOf("_") + 1); txtScore = ((TextBox)tbl.Rows[i].Cells[1].Controls[0]).Text; txtDes = ((TextBox)tbl.Rows[i + 2].Cells[0].Controls[0]).Text; if (txtScore == "") { txtScore = "0"; } ContestEntities db = new ContestEntities(); PeriodStandard dr; if (PeriodID > 0) { int standID = int.Parse(lstValue); drs = ds.Where(p => p.StandardID == standID).ToList(); //drs = ds.Tables[0].Select("StandardID=" + lstValue); if (drs.Count > 0) { drs[0].StandardDescription = txtDes.Trim(); drs[0].Score = int.Parse(txtScore.Trim()); drs[0].Modified = DateTime.Now; drs[0].ModifiedBy = DAL.Common.LoginID; DAL.Standard.UpdatePeriodStandard(drs[0]); result += 1; } else { if (txtScore != "") { dr = new ContestDll.PeriodStandard(); dr.PeriodID = PeriodID; dr.WorkTypeID = WorksTypeID; dr.StandardID = int.Parse(lstValue); dr.StandardDescription = txtDes.Trim(); dr.Score = int.Parse(txtScore.Trim()); dr.Created = DateTime.Now; dr.CreatedBy = DAL.Common.LoginID; dr.Flag = 1; DAL.Standard.InsertPeriodStandard(dr); result += 1; } } } else { CSWorksTypeScoreStandard dr1 = ds1.SingleOrDefault(p => p.StandardID == int.Parse(lstValue)); if (dr1 != null) { dr1.Score = int.Parse(txtScore.Trim()); dr1.StandardDescription = txtDes.Trim(); DAL.WorksType.UpdateWorksTypeScoreStandard(dr1); result += 1; } else { dr1 = new CSWorksTypeScoreStandard(); dr1.WorkTypeID = WorksTypeID; dr1.StandardID = int.Parse(lstValue); dr1.StandardDescription = txtDes.Trim(); dr1.Score = int.Parse(txtScore.Trim()); dr1.Flag = 1; DAL.WorksType.InsertWorksTypeScoreStandard(dr1); result += 1; } } //保存或更新 i += 3; } if (result > 0) { //ViewState["dsStandard"] = null; DAL.Common.ShowMessage(this.Page, this.GetType(), "保存成功"); } else { DAL.Common.ShowMessage(this.Page, this.GetType(), "分数不能空"); } }