void GetJCQuizList() { string strSiteID = string.Empty; string strTitle = string.Empty; string strTheme = string.Empty; string strSiteCode = string.Empty; List <JC_Quiz> jcmodel = new List <JC_Quiz>(); JC_QuizDAL dal = new JC_QuizDAL(); DataSet jclistds = dal.GetJCQuizDataList(""); foreach (DataRow row in jclistds.Tables[0].Rows) { JC_Quiz model = DataConvert.DataRowToModel <JC_Quiz>(row); jcmodel.Add(model); } //读取模板内容 // string text = System.IO.File.ReadAllText(Server.MapPath("Themes/" + strTheme + "/NewHome.html")); string text = System.IO.File.ReadAllText(Server.MapPath("Themes/Quiz/QuizList.html")); JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext(); context.TempData["title"] = "2014巴西世界杯比赛日程表一览"; context.TempData["siteid"] = Session["siteid"]; context.TempData["jcmodel"] = jcmodel; context.TempData["footer"] = "奥琦微商易"; JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text); t.Render(Response.Output); }
protected void Page_Load(object sender, EventArgs e) { if (null != Common.Common.NoHtml(Request.QueryString["action"])) { strAction = Common.Common.NoHtml(Request.QueryString["action"]); } if (null != Common.Common.NoHtml(Request.QueryString["id"])) { strID = Common.Common.NoHtml(Request.QueryString["id"]); } JC_QuizDAL dal = new JC_QuizDAL(); switch (strAction) { case "del": if (dal.UpdateJCState(strID)) { strMessage = "操作成功!"; } else { strMessage = "操作失败!"; } break; default: break; } Response.Write(strMessage); Response.End(); }
public void ShowActivityInfo(string strID) { JC_QuizDAL dal = new JC_QuizDAL(); DataSet ds = dal.GetJCQuizDetail(strID); JC_Quiz model = DataConvert.DataRowToModel <JC_Quiz>(ds.Tables[0].Rows[0]); this.txtName.Text = model.Name; this.hd_content.Value = model.MatchDesc; starttime.Text = model.StartTime.ToString(); img0.Src = "../../" + model.HomeTeamImg; img1.Src = "../../" + model.VisitingTeamImg; hometeam.Text = model.HomeTeam; VisitingTeam.Text = model.VisitingTeam; RightScore.Text = model.RightScore; if (strAction == "show") { this.btnReset.Visible = false; this.btnSave.Visible = false; starttime.ReadOnly = true; txtName.ReadOnly = true; } else { starttime.Attributes.Add("onclick", "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"); } }
/// <summary> /// 加载数据 /// </summary> /// <param name="strWhere">条件</param> void LoadData(string strWhere) { txtName.Text = ""; JC_QuizDAL dal = new JC_QuizDAL(); DataSet ds = dal.GetJCQuizDataList(strWhere); DataView dv = ds.Tables[0].DefaultView; AspNetPager1.RecordCount = dv.Count; PagedDataSource pds = new PagedDataSource(); pds.DataSource = dv; pds.AllowPaging = true; pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1; pds.PageSize = AspNetPager1.PageSize; Repeater1.DataSource = pds; Repeater1.DataBind(); }
string GetLoseWin(string quizID) { JC_QuizDAL dal = new JC_QuizDAL(); string Score = string.Empty; try { Score = dal.GetQuizValueById("RightScore", quizID).ToString(); } catch (Exception) { return("0"); } int HomeNum = 0; int VisitNum = 0; string[] sArray = Score.Split(':'); string[] sArray1 = Score.Split(':'); try { HomeNum = Convert.ToInt32(sArray[0].ToString()); VisitNum = Convert.ToInt32(sArray[1].ToString()); } catch (Exception) { HomeNum = Convert.ToInt32(sArray1[0].ToString()); VisitNum = Convert.ToInt32(sArray1[1].ToString()); } if (HomeNum > VisitNum) { return(">"); } else if (HomeNum == VisitNum) { return("="); } else { return("<"); } }
const string vsKey = "searchCriteria"; //ViewState key /// <summary> /// 页面加载事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { AspNetPager1.CurrentPageIndex = 1; string s = ""; if (Session["strRoleCode"].ToString() != "ADMIN") { s = " a.SiteCode = '" + Session["strSiteCode"].ToString() + "' "; } ViewState[vsKey] = s; ddlselectName.Items.Clear(); JC_QuizDAL jcquizdal = new JC_QuizDAL(); DataSet ds = new DataSet(); if (Session["strRoleCode"].ToString() == "ADMIN") { ds = jcquizdal.GetJCQuizDataList(""); } else { ds = jcquizdal.GetJCQuizDataList(" SiteCode ='" + Session["strSiteCode"].ToString() + "' "); } DataTable dt = ds.Tables[0]; DataRow dr = ds.Tables[0].NewRow(); dr["ID"] = "0"; dr["Name"] = "--全部--"; dt.Rows.InsertAt(dr, 0); ddlselectName.DataSource = ds.Tables[0].DefaultView; ddlselectName.DataTextField = "Name"; ddlselectName.DataValueField = "ID"; ddlselectName.DataBind(); LoadData(s); } }
protected void btnSave_Click(object sender, EventArgs e) { if (null == Session["strSiteName"] || null == Session["strSiteCode"] || null == Session["strLoginName"]) { Response.Write("<script language=JavaScript>;parent.location.href='../Index.aspx';</script>"); Response.End(); } //上传主队图像 string strIconFileName0 = string.Empty; //图像路径 string strIconSaveFileName0 = string.Empty; //网址路径 try { if (this.file0.PostedFile.FileName == "") { strIconSaveFileName0 = ""; } else { if (!System.IO.Directory.Exists(Server.MapPath("~") + @"/Images")) { System.IO.Directory.CreateDirectory(Server.MapPath("~") + @"/Images"); } if (!System.IO.Directory.Exists(String.Format(@"{0}/Images/{1}", Server.MapPath("~"), Session["strSiteCode"].ToString()))) { System.IO.Directory.CreateDirectory(String.Format(@"{0}/Images/{1}", Server.MapPath("~"), Session["strSiteCode"].ToString())); } string orignalName = this.file0.PostedFile.FileName; //获取客户机上传文件的文件名 string extendName = orignalName.Substring(orignalName.LastIndexOf(".")); //获取扩展名 if (extendName != ".gif" && extendName != ".jpg" && extendName != ".jpeg" && extendName != ".png") { MessageBox.Show(this, "文件格式有误!"); return; }//检查文件格式 string newName = String.Format("{0}_{1}{2}", DateTime.Now.Millisecond, file0.PostedFile.ContentLength, extendName);//对文件进行重命名 strIconFileName0 = String.Format(@"{0}Images/{1}/{2}", Server.MapPath("~"), Session["strSiteCode"].ToString(), newName); strIconSaveFileName0 = String.Format(@"Images/{0}/{1}", Session["strSiteCode"].ToString(), newName); file0.PostedFile.SaveAs(strIconFileName0); } } catch (Exception ex) { MessageBox.Show(this, "上传发生错误!原因是:" + ex.ToString()); } //上传客队图像 string strIconFileName1 = string.Empty; //图像路径 string strIconSaveFileName1 = string.Empty; //网址路径 try { if (this.file1.PostedFile.FileName == "") { strIconSaveFileName1 = ""; } else { if (!System.IO.Directory.Exists(Server.MapPath("~") + @"/Images")) { System.IO.Directory.CreateDirectory(Server.MapPath("~") + @"/Images"); } if (!System.IO.Directory.Exists(String.Format(@"{0}/Images/{1}", Server.MapPath("~"), Session["strSiteCode"].ToString()))) { System.IO.Directory.CreateDirectory(String.Format(@"{0}/Images/{1}", Server.MapPath("~"), Session["strSiteCode"].ToString())); } string orignalName = this.file1.PostedFile.FileName; //获取客户机上传文件的文件名 string extendName = orignalName.Substring(orignalName.LastIndexOf(".")); //获取扩展名 if (extendName != ".gif" && extendName != ".jpg" && extendName != ".jpeg" && extendName != ".png") { MessageBox.Show(this, "文件格式有误!"); return; }//检查文件格式 string newName = String.Format("{0}_{1}{2}", DateTime.Now.Millisecond, file1.PostedFile.ContentLength, extendName);//对文件进行重命名 strIconFileName1 = String.Format(@"{0}Images/{1}/{2}", Server.MapPath("~"), Session["strSiteCode"].ToString(), newName); strIconSaveFileName1 = String.Format(@"Images/{0}/{1}", Session["strSiteCode"].ToString(), newName); file1.PostedFile.SaveAs(strIconFileName1); } } catch (Exception ex) { MessageBox.Show(this, "上传发生错误!原因是:" + ex.ToString()); } if (txtName.Text.Trim() != null && txtName.Text.Trim() != "") { JC_Quiz model = new JC_Quiz(); JC_QuizDAL dal = new JC_QuizDAL(); model.SiteCode = Session["strSiteCode"].ToString(); model.Name = txtName.Text; model.HomeTeam = hometeam.Text; model.HomeTeamImg = strIconSaveFileName0; model.VisitingTeam = VisitingTeam.Text; model.VisitingTeamImg = strIconSaveFileName1; model.StartTime = Convert.ToDateTime(starttime.Text); model.MatchDesc = hd_content.Value; model.ID = Guid.NewGuid().ToString("N").ToUpper(); model.State = 0; model.QuizType = "0"; if (dal.AddJCQuiz(model)) { MessageBox.Show(this, "操作成功!"); } else { MessageBox.Show(this, "操作失败!"); } } else { MessageBox.Show(this, "请输入信息名称后再操作!"); } }