protected void DataListGroup_ItemDataBound(object sender, DataListItemEventArgs e) { int sgrade = Int32.Parse(Request.QueryString["Sg"].ToString()); int sclass = Int32.Parse(Request.QueryString["Sc"].ToString()); string sid = ((Label)e.Item.FindControl("LabelSid")).Text; Label lbgstus = (Label)e.Item.FindControl("LabelGstus"); DropDownList ddl = (DropDownList)e.Item.FindControl("DDLGscores"); LinkButton btnview = (LinkButton)e.Item.FindControl("LinkBtnView"); LearnSite.BLL.Students sbll = new LearnSite.BLL.Students(); lbgstus.Text = sbll.GroupMember(sgrade, sclass, int.Parse(sid)); string snum = ((Label)e.Item.FindControl("LabelSnum")).Text; int mid = Int32.Parse(Request.QueryString["Mi"].ToString()); LearnSite.BLL.GroupWork gbll = new LearnSite.BLL.GroupWork(); LearnSite.Model.GroupWork gmodel = new LearnSite.Model.GroupWork(); gmodel = gbll.GetModelBySnum(snum, mid); if (gmodel != null) { ddl.SelectedValue = gmodel.Gscore.ToString(); ddl.ToolTip = gmodel.Gid.ToString(); btnview.CommandArgument = gmodel.Gurl; } else { ddl.SelectedValue = "0"; ddl.Enabled = false; btnview.Enabled = false; } }
private void showGroupWork() { int groupcount = DLgroups.Items.Count; int pos = Int32.Parse(Labelpos.Text); int lastpos = Int32.Parse(Labellastpos.Text); if (groupcount > 0 && pos > -1 && pos < groupcount) { int sgrade = Int32.Parse(Request.QueryString["Sg"].ToString()); int sclass = Int32.Parse(Request.QueryString["Sc"].ToString()); int mid = Int32.Parse(Request.QueryString["Mi"].ToString()); LinkButton lb = (LinkButton)DLgroups.Items[pos].FindControl("LbSgtitle"); LabelSgtitle.Text = lb.Text; lb.BorderColor = System.Drawing.Color.FromArgb(0, 102, 255); if (pos != lastpos) { LinkButton lblast = (LinkButton)DLgroups.Items[lastpos].FindControl("LbSgtitle"); lblast.BorderColor = System.Drawing.Color.FromArgb(212, 212, 212);//还原上个边框颜色 } Labellastpos.Text = pos.ToString(); Label ln = (Label)DLgroups.Items[pos].FindControl("LabelSname"); LabelLeader.Text = ln.Text; string sid = ((Label)DLgroups.Items[pos].FindControl("LabelSid")).Text; string snum = ((Label)DLgroups.Items[pos].FindControl("LabelSnum")).Text; LearnSite.BLL.Students sbll = new LearnSite.BLL.Students(); Labelmember.Text = sbll.GroupMember(sgrade, sclass, int.Parse(sid)); LearnSite.BLL.GroupWork gbll = new LearnSite.BLL.GroupWork(); LearnSite.Model.GroupWork gmodel = new LearnSite.Model.GroupWork(); gmodel = gbll.GetModelBySnum(snum, mid); if (gmodel != null) { DDLGscores.SelectedValue = gmodel.Gscore.ToString(); DDLGscores.Enabled = true; Labelgid.Text = gmodel.Gid.ToString(); string url = gmodel.Gurl; string ext = LearnSite.Common.WordProcess.getext(url); string htmname = "index.htm"; if (string.IsNullOrEmpty(ext)) { ext = "htm"; } LiteralView.Text = LearnSite.Common.WordProcess.SelectWriteTeaNew(ext, url, true, htmname); } else { DDLGscores.SelectedValue = "0"; DDLGscores.Enabled = false; LiteralView.Text = ""; } } }
private void uploadgroupwork() { if (Request.Files["Filedata"] != null) { try { // Get the data HttpPostedFile group_upload = Request.Files["Filedata"]; string Gtype = group_upload.FileName.Substring(group_upload.FileName.LastIndexOf(".") + 1).ToLower(); string Gmid = Request.QueryString["mid"].ToString(); string Gnum = Request.QueryString["num"].ToString(); string info = HttpUtility.UrlDecode(Request.QueryString["info"].ToString()); LearnSite.BLL.Mission mbll = new LearnSite.BLL.Mission(); LearnSite.Model.Mission mmodel = new LearnSite.Model.Mission(); mmodel = mbll.GetModel(Int32.Parse(Gmid)); // string Gextention = mmodel.Mfiletype; string Gcid = mmodel.Mcid.ToString(); //Syear | Sgrade | Sclass | Sid | Sname | Wip | Sterm | LoginTime string[] infoarray = info.Split('|'); string Ggroup = infoarray[3];//取组长 string Gyear = infoarray[0]; string Ggrade = infoarray[1]; string Gclass = infoarray[2]; string Gip = infoarray[5]; string LoginTime = infoarray[7]; string Gterm = infoarray[6]; LearnSite.BLL.Signin sn = new LearnSite.BLL.Signin(); LearnSite.Model.Signin qmodel = sn.GetModelm(Gnum); if (qmodel != null) { Gyear = qmodel.Qsyear.ToString(); Ggrade = qmodel.Qgrade.ToString(); Gclass = qmodel.Qclass.ToString(); Gip = qmodel.Qip; LoginTime = qmodel.Qdate.ToString(); Gterm = qmodel.Qterm.ToString(); } int Glengh = group_upload.ContentLength; DateTime Gdate = DateTime.Now; LearnSite.BLL.GroupWork gbll = new LearnSite.BLL.GroupWork(); bool gdone = gbll.DoneGroupWork(Gnum, Int32.Parse(Gmid)); string MySavePath = LearnSite.Common.WorkUpload.GetWurl(Gyear, Ggrade, Gclass, Gcid, Gmid);//获得作品保存路径(如果不存在,自动创建) string NewFileName = "g" + Gnum + Gcid + "_" + Gmid + "." + Gtype; string Gurl = MySavePath + "/" + NewFileName; string saveFilename = Server.MapPath(Gurl); //如果作品未提交,提交作品 if (!gdone) { int Gtime = LearnSite.Common.Computer.TimePassed(); LearnSite.Model.GroupWork gmodel = new LearnSite.Model.GroupWork(); gmodel.Gcheck = false; gmodel.Gcid = Int32.Parse(Gcid); gmodel.Gclass = Int32.Parse(Gclass); gmodel.Gdate = DateTime.Now; gmodel.Gfilename = NewFileName; gmodel.Ggrade = Int32.Parse(Ggrade); gmodel.Ghit = 0; gmodel.Gip = Gip; gmodel.Glengh = Glengh; gmodel.Gmid = Int32.Parse(Gmid); gmodel.Gnote = ""; gmodel.Gnum = Gnum; gmodel.Grank = -1; gmodel.Gscore = 0; LearnSite.BLL.Students sbll = new LearnSite.BLL.Students(); gmodel.Gstudents = sbll.GroupSnum(Gnum); gmodel.Gterm = Int32.Parse(Gterm); gmodel.Gtime = Gtime; gmodel.Gtype = Gtype; gmodel.Gurl = Gurl; gmodel.Gvote = 0; gmodel.Ggroup = Int32.Parse(Ggroup); gbll.Add(gmodel);//添加小组作品提交记录 } else { //已交则不更新记录 } try { group_upload.SaveAs(saveFilename);//保存提交作品 Response.StatusCode = 200; Response.Write(NewFileName); } catch (Exception ex) { Response.StatusCode = 200; Response.Write(ex); } } catch (Exception ex) { Response.StatusCode = 200; Response.Write(ex); } finally { Response.End(); } } }
private void uploadgroupwork() { HttpPostedFile group_upload = Request.Files["imgFilegroup"]; int maxSize = 104857600;//定义上传最大值为100MB if (group_upload != null) { // Get the data string Gtype = group_upload.FileName.Substring(group_upload.FileName.LastIndexOf(".") + 1).ToLower(); string Gmid = Request.QueryString["mid"].ToString(); string Gnum = Request.QueryString["num"].ToString(); LearnSite.BLL.Mission mbll = new LearnSite.BLL.Mission(); LearnSite.Model.Mission mmodel = new LearnSite.Model.Mission(); mmodel = mbll.GetModel(Int32.Parse(Gmid)); string Gextention = mmodel.Mfiletype; string Gcid = mmodel.Mcid.ToString(); string limitext = Gextention;//初始化,随意 switch (Gextention) { case "doc": limitext = "*.doc;*.docx"; break; case "ppt": limitext = "*.ppt;*.pptx"; break; case "xls": limitext = "*.xls;*.xlsx"; break; case "office": limitext = "*.doc;*.docx;*.ppt;*.pptx;*.xls;*.xlsx"; break; case "sb": limitext = "*.sb;*.sb2"; break; default: limitext = "*." + Gextention; break; } if (Gtype == Gextention || limitext.Contains(Gtype)) { if (group_upload.InputStream != null || group_upload.InputStream.Length < maxSize) { LearnSite.BLL.Signin sn = new LearnSite.BLL.Signin(); LearnSite.Model.Signin qmodel = sn.GetModelm(Gnum); LearnSite.Model.Cook cook = new LearnSite.Model.Cook(); string Ggroup = cook.Sid.ToString();//取组长 string Gyear = cook.Syear.ToString(); string Ggrade = cook.Sgrade.ToString(); string Gclass = cook.Sclass.ToString(); string Gip = cook.LoginIp; string LoginTime = cook.LoginTime; string Gterm = cook.ThisTerm.ToString(); if (qmodel != null) { Gyear = qmodel.Qsyear.ToString(); Ggrade = qmodel.Qgrade.ToString(); Gclass = qmodel.Qclass.ToString(); Gip = qmodel.Qip; LoginTime = qmodel.Qdate.ToString(); Gterm = qmodel.Qterm.ToString(); } int Glengh = group_upload.ContentLength; DateTime Gdate = DateTime.Now; LearnSite.BLL.GroupWork gbll = new LearnSite.BLL.GroupWork(); bool gdone = gbll.DoneGroupWork(Gnum, Int32.Parse(Gmid)); string MySavePath = LearnSite.Common.WorkUpload.GetWurl(Gyear, Ggrade, Gclass, Gcid, Gmid);//获得作品保存路径(如果不存在,自动创建) string NewFileName = "g" + Gnum + Gcid + "_" + Gmid + "." + Gtype; string Gurl = MySavePath + "/" + NewFileName; string saveFilename = Server.MapPath(Gurl); //如果作品未提交,提交作品 if (!gdone) { int Gtime = LearnSite.Common.Computer.TimePassed(); LearnSite.Model.GroupWork gmodel = new LearnSite.Model.GroupWork(); gmodel.Gcheck = false; gmodel.Gcid = Int32.Parse(Gcid); gmodel.Gclass = Int32.Parse(Gclass); gmodel.Gdate = DateTime.Now; gmodel.Gfilename = NewFileName; gmodel.Ggrade = Int32.Parse(Ggrade); gmodel.Ghit = 0; gmodel.Gip = Gip; gmodel.Glengh = Glengh; gmodel.Gmid = Int32.Parse(Gmid); gmodel.Gnote = ""; gmodel.Gnum = Gnum; gmodel.Grank = -1; gmodel.Gscore = 0; LearnSite.BLL.Students sbll = new LearnSite.BLL.Students(); gmodel.Gstudents = sbll.GroupSnum(Gnum); gmodel.Gterm = Int32.Parse(Gterm); gmodel.Gtime = Gtime; gmodel.Gtype = Gtype; gmodel.Gurl = Gurl; gmodel.Gvote = 0; gmodel.Ggroup = Int32.Parse(Ggroup); gbll.Add(gmodel);//添加小组作品提交记录 } else { //已交则不更新记录 } group_upload.SaveAs(saveFilename);//保存或更新提交作品 Hashtable hash = new Hashtable(); hash["error"] = 0; Response.AddHeader("Content-Type", "text/html; charset=UTF-8"); Response.Write(JsonMapper.ToJson(hash)); Response.End(); } else { showError("选择的文件大小超过限制!(最大为10MB)"); } } else { showError("选择的文件类型错误!"); } } else { showError("请选择文件!"); } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(LearnSite.Model.GroupWork model) { dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(LearnSite.Model.GroupWork model) { return(dal.Add(model)); }
/// <summary> /// 获得数据列表 /// </summary> public List <LearnSite.Model.GroupWork> DataTableToList(DataTable dt) { List <LearnSite.Model.GroupWork> modelList = new List <LearnSite.Model.GroupWork>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { LearnSite.Model.GroupWork model; for (int n = 0; n < rowsCount; n++) { model = new LearnSite.Model.GroupWork(); if (dt.Rows[n]["Gid"].ToString() != "") { model.Gid = int.Parse(dt.Rows[n]["Gid"].ToString()); } model.Gnum = dt.Rows[n]["Gnum"].ToString(); model.Gstudents = dt.Rows[n]["Gstudents"].ToString(); if (dt.Rows[n]["Gterm"].ToString() != "") { model.Gterm = int.Parse(dt.Rows[n]["Gterm"].ToString()); } if (dt.Rows[n]["Ggrade"].ToString() != "") { model.Ggrade = int.Parse(dt.Rows[n]["Ggrade"].ToString()); } if (dt.Rows[n]["Gclass"].ToString() != "") { model.Gclass = int.Parse(dt.Rows[n]["Gclass"].ToString()); } if (dt.Rows[n]["Gcid"].ToString() != "") { model.Gcid = int.Parse(dt.Rows[n]["Gcid"].ToString()); } if (dt.Rows[n]["Gmid"].ToString() != "") { model.Gmid = int.Parse(dt.Rows[n]["Gmid"].ToString()); } model.Gfilename = dt.Rows[n]["Gfilename"].ToString(); model.Gtype = dt.Rows[n]["Gtype"].ToString(); model.Gurl = dt.Rows[n]["Gurl"].ToString(); if (dt.Rows[n]["Glengh"].ToString() != "") { model.Glengh = int.Parse(dt.Rows[n]["Glengh"].ToString()); } if (dt.Rows[n]["Gscore"].ToString() != "") { model.Gscore = int.Parse(dt.Rows[n]["Gscore"].ToString()); } if (dt.Rows[n]["Gtime"].ToString() != "") { model.Gtime = int.Parse(dt.Rows[n]["Gtime"].ToString()); } if (dt.Rows[n]["Gvote"].ToString() != "") { model.Gvote = int.Parse(dt.Rows[n]["Gvote"].ToString()); } if (dt.Rows[n]["Gcheck"].ToString() != "") { if ((dt.Rows[n]["Gcheck"].ToString() == "1") || (dt.Rows[n]["Gcheck"].ToString().ToLower() == "true")) { model.Gcheck = true; } else { model.Gcheck = false; } } model.Gnote = dt.Rows[n]["Gnote"].ToString(); if (dt.Rows[n]["Grank"].ToString() != "") { model.Grank = int.Parse(dt.Rows[n]["Grank"].ToString()); } if (dt.Rows[n]["Ghit"].ToString() != "") { model.Ghit = int.Parse(dt.Rows[n]["Ghit"].ToString()); } model.Gip = dt.Rows[n]["Gip"].ToString(); if (dt.Rows[n]["Gdate"].ToString() != "") { model.Gdate = DateTime.Parse(dt.Rows[n]["Gdate"].ToString()); } if (dt.Rows[n]["Ggroup"].ToString() != "") { model.Ggroup = int.Parse(dt.Rows[n]["Ggroup"].ToString()); } modelList.Add(model); } } return(modelList); }