private void BindGrid2() { bool isGroup = PrjPub.CurrentStudent.IsGroupLearder; int tech = PrjPub.CurrentStudent.TechnicianTypeID; CoursewareBLL coursewareBLL = new CoursewareBLL(); IList <RailExam.Model.Courseware> coursewareList = coursewareBLL.GetEmployeeStudyCoursewareInfo(Convert.ToInt32(ViewState["TrainTypeID"].ToString()), PrjPub.CurrentStudent.OrgID, PrjPub.CurrentStudent.PostID, isGroup, tech, 5); if (coursewareList.Count > 0) { foreach (RailExam.Model.Courseware courseware in coursewareList) { courseware.ToolTip = courseware.CoursewareName; if (courseware.CoursewareName.Length <= 13) { courseware.CoursewareName = courseware.CoursewareName; } else { courseware.CoursewareName = courseware.CoursewareName.Substring(0, 13) + "..."; } } } gvCourse.DataSource = coursewareList; gvCourse.DataBind(); }
private void BindGrid2() { CoursewareBLL coursewareBLL = new CoursewareBLL(); IList <RailExam.Model.Courseware> coursewareList = new List <RailExam.Model.Courseware>(); if (!string.IsNullOrEmpty(Request.QueryString.Get("id"))) { TrainTypeBLL trainTypeBLL = new TrainTypeBLL(); TrainType trainType = trainTypeBLL.GetTrainTypeInfo(Convert.ToInt32(ViewState["TrainAimID"].ToString())); coursewareList = coursewareBLL.GetCoursewaresByTrainTypeIDPath(trainType.IDPath, 1); } else { coursewareList = coursewareBLL.GetCoursewaresByCoursewareTypeOnline(PrjPub.CurrentLoginUser.StationOrgID, Convert.ToInt32(ViewState["TrainAimID"].ToString()), "%", true, 5); } if (coursewareList.Count > 0) { foreach (RailExam.Model.Courseware courseware in coursewareList) { if (courseware.CoursewareName.Length <= 15) { courseware.CoursewareName = "<a onclick=EditCourseware(" + courseware.CoursewareID + ") href=# title=" + courseware.CoursewareName + " > " + courseware.CoursewareName + " </a>"; } else { courseware.CoursewareName = "<a onclick=EditCourseware(" + courseware.CoursewareID + ") href=# title=" + courseware.CoursewareName + " > " + courseware.CoursewareName.Substring(0, 15) + "..." + " </a>"; } } gvCourse.DataSource = coursewareList; gvCourse.DataBind(); } }
private void BindGridByCoursewareTypeID() { int typeID = Convert.ToInt32(ViewState["CoursewareTypeID"].ToString()); int postID = Convert.ToInt32(ViewState["PostID"].ToString()); int orgID = Convert.ToInt32(ViewState["OrgID"].ToString()); int techID = Convert.ToInt32(ViewState["Tech"].ToString()); int leader = Convert.ToInt32(ViewState["Leader"].ToString()); CoursewareBLL coursewareBLL = new CoursewareBLL(); IList <RailExam.Model.Courseware> coursewareList = coursewareBLL.GetStudyCoursewareInfoByTypeID(typeID, orgID, postID, leader, techID, 0); if (coursewareList.Count > 0) { foreach (RailExam.Model.Courseware courseware in coursewareList) { //if (courseware.CoursewareName.Length <= 15) //{ courseware.CoursewareName = "<a onclick=OpenIndex('" + courseware.CoursewareID + "') href=# title=" + courseware.CoursewareName + ">" + courseware.CoursewareName + "</a>"; //} //else //{ // courseware.CoursewareName = "<a onclick=OpenIndex('" + courseware.Url + "') href=# title=" + courseware.CoursewareName + ">" + courseware.CoursewareName.Substring(0, 15) + "...</a>"; //} } gvCourse.DataSource = coursewareList; gvCourse.DataBind(); } }
private void BindGrid() { string strIDPath = Request.QueryString["id"]; CoursewareBLL coursewareBLL = new CoursewareBLL(); IList <RailExam.Model.Courseware> coursewares = new List <RailExam.Model.Courseware>(); if (Request.QueryString.Get("type") == "Courseware") { coursewares = coursewareBLL.GetCoursewaresByCoursewareTypeID(Convert.ToInt32(strIDPath), 1); } else { coursewares = coursewareBLL.GetCoursewaresByTrainTypeID(Convert.ToInt32(strIDPath), 1); } foreach (RailExam.Model.Courseware courseware in coursewares) { //if (courseware.CoursewareName.Length <= 15) //{ courseware.CoursewareName = "<a onclick=OpenIndex('" + courseware.CoursewareID + "') href=# title=" + courseware.CoursewareName + ">" + courseware.CoursewareName + "</a>"; //} //else //{ // courseware.CoursewareName = "<a onclick=OpenIndex('" + courseware.Url + "') href=# title=" + courseware.CoursewareName + ">" + courseware.CoursewareName.Substring(0, 15) + "...</a>"; //} } Grid1.DataSource = coursewares; Grid1.DataBind(); }
private void BindGridCourseByCoursewareTypeID() { int postID; if (!Int32.TryParse(ViewState["PostID"].ToString(), out postID)) { return; } int typeID = Convert.ToInt32(ViewState["KnowledgeID"]); int orgID = PrjPub.CurrentStudent.OrgID; int techID = PrjPub.CurrentStudent.TechnicianTypeID; int leader = PrjPub.CurrentStudent.IsGroupLearder ? 1 : 0; CoursewareBLL coursewareBLL = new CoursewareBLL(); IList <RailExam.Model.Courseware> coursewareList = coursewareBLL.GetStudyCoursewareInfoByTypeID(typeID, orgID, postID, leader, techID, 0); if (coursewareList.Count > 0) { foreach (RailExam.Model.Courseware courseware in coursewareList) { courseware.CoursewareName = "<a onclick=OpenCourse('" + courseware.CoursewareID + "') href=# title=" + courseware.CoursewareName + ">" + courseware.CoursewareName + "</a>"; } Grid2.DataSource = coursewareList; Grid2.DataBind(); } }
private void BindCoursewareGrid() { CoursewareBLL coursewareBLL = new CoursewareBLL(); IList <RailExam.Model.Courseware> coursewares = new List <RailExam.Model.Courseware>(); string strKnowledgeID = Request.QueryString.Get("id"); IList <RailExam.Model.Book> bookList = new List <RailExam.Model.Book>(); if (strKnowledgeID != null & strKnowledgeID != "" & strKnowledgeID != "0") { coursewares = coursewareBLL.GetCoursewaresByCoursewareTypeID(Convert.ToInt32(strKnowledgeID), 1); } string strtypeID = Request.QueryString.Get("id1"); if (strtypeID != null & strtypeID != "" && strtypeID != "0") { coursewares = coursewareBLL.GetCoursewaresByTrainTypeID(Convert.ToInt32(strtypeID), 1); } foreach (RailExam.Model.Courseware courseware in coursewares) { courseware.CoursewareName = "<a onclick=OpenCourse('" + courseware.CoursewareID + "') href=# title=" + courseware.CoursewareName + ">" + courseware.CoursewareName + "</a>"; } Grid2.DataSource = coursewares; Grid2.DataBind(); }
private void BindCourse() { bool isGroup = PrjPub.CurrentStudent.IsGroupLearder; int tech = PrjPub.CurrentStudent.TechnicianTypeID; int orgID = PrjPub.CurrentStudent.OrgID; int postID = PrjPub.CurrentStudent.PostID; string strIDPath = Request.QueryString.Get("Courseware"); CoursewareBLL objBll = new CoursewareBLL(); IList <RailExam.Model.Courseware> objCourseware = objBll.GetCoursewaresByCoursewareTypeOnline(orgID, postID, strIDPath, isGroup, tech); if (objCourseware.Count > 0) { foreach (RailExam.Model.Courseware courseware in objCourseware) { if (courseware.CoursewareName.Length <= 15) { courseware.CoursewareName = courseware.CoursewareName; } else { courseware.CoursewareName = courseware.CoursewareName.Substring(0, 15) + "..."; } } } gvCourse.DataSource = objCourseware; gvCourse.DataBind(); gvBook.Visible = false; gvCourse.Visible = true; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string strCoursewareID = Request.QueryString.Get("id"); CoursewareBLL objBll = new CoursewareBLL(); RailExam.Model.Courseware obj = objBll.GetCourseware(Convert.ToInt32(strCoursewareID)); hfUrl.Value = obj.Url; } }
private void BindGrid2() { CoursewareBLL coursewareBLL = new CoursewareBLL(); IList <RailExam.Model.Courseware> coursewareList = coursewareBLL.GetCoursewareInfoByDate(6); if (coursewareList.Count > 0) { foreach (RailExam.Model.Courseware courseware in coursewareList) { courseware.CoursewareName = courseware.CoursewareName + "(" + courseware.ProvideOrgName + "," + courseware.Authors + "," + courseware.PublishDate.ToString("yyyy-MM-dd") + ")"; } } gvCourse.DataSource = coursewareList; gvCourse.DataBind(); }
protected void btnQuery_Click(object sender, EventArgs e) { // int nID = int.Parse(Request.QueryString["id"]); string strKnowledgeID = Request.QueryString.Get("id"); string[] str1 = strKnowledgeID.Split(new char[] { '/' }); int nID = int.Parse(str1[str1.LongLength - 1].ToString()); OrganizationBLL orgBll = new OrganizationBLL(); int orgID = orgBll.GetStationOrgID(PrjPub.CurrentLoginUser.OrgID); CoursewareBLL coursewareBLL = new CoursewareBLL(); IList <RailExam.Model.Courseware> coursewares = new List <RailExam.Model.Courseware>(); if (Request.QueryString.Get("type") == "Courseware") { coursewares = coursewareBLL.GetCoursewares(nID, -1, txtCoursewareName.Text, txtKeyWords.Text, txtAuthors.Text, orgID); } else if (Request.QueryString.Get("type") == "TrainType") { coursewares = coursewareBLL.GetCoursewares(-1, nID, txtCoursewareName.Text, txtKeyWords.Text, txtAuthors.Text, orgID); } else { coursewares = coursewareBLL.GetCoursewaresByPostID(nID, txtCoursewareName.Text, txtKeyWords.Text, txtAuthors.Text, orgID); } if (coursewares != null) { foreach (RailExam.Model.Courseware obj in coursewares) { if (obj.CoursewareName.Length <= 20) { obj.CoursewareName = "<a onclick=OpenIndex('" + obj.CoursewareID + "') href=# title=" + obj.CoursewareName + " > " + obj.CoursewareName + " </a>"; } else { obj.CoursewareName = "<a onclick=OpenIndex('" + obj.CoursewareID + "') href=# title=" + obj.CoursewareName + " > " + obj.CoursewareName.Substring(0, 20) + "...</a>"; } } Grid1.DataSource = coursewares; Grid1.DataBind(); } }
private void DeleteData(int nCoursewareID) { CoursewareBLL coursewareBLL = new CoursewareBLL(); coursewareBLL.DeleteCourseware(nCoursewareID); string strPath = Server.MapPath("/RailExamBao/Online/Courseware/" + nCoursewareID + "/"); if (Directory.Exists(strPath)) { string[] filenames = Directory.GetFiles(strPath); for (int i = 0; i < filenames.Length; i++) { File.Delete(filenames[i]); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string strCoursewareID = Request.QueryString.Get("id"); CoursewareBLL objBll = new CoursewareBLL(); RailExam.Model.Courseware obj = objBll.GetCourseware(Convert.ToInt32(strCoursewareID)); string strFileName = obj.Url.Replace("/RailExamBao/Online/Courseware/" + obj.CoursewareID + "/", ""); FileInfo f = new FileInfo(strFileName); //下载文件的路径 string path = Server.MapPath(obj.Url); //下载文件的名称 string filename = f.Name; System.IO.FileInfo toDownload = new System.IO.FileInfo(path); if (toDownload.Exists == true) { const long ChunkSize = 10000; byte[] buffer = new byte[ChunkSize]; Response.Clear(); System.IO.FileStream iStream = System.IO.File.OpenRead(path); long dataLengthToRead = iStream.Length; Response.ContentType = "application/octet-stream"; Response.AddHeader("Content-Disposition", "attachment; filename=new_" + HttpUtility.UrlEncode(toDownload.Name)); while (dataLengthToRead > 0 && Response.IsClientConnected) { int lengthRead = iStream.Read(buffer, 0, Convert.ToInt32(ChunkSize)); Response.OutputStream.Write(buffer, 0, lengthRead); Response.Flush(); dataLengthToRead = dataLengthToRead - lengthRead; } iStream.Close(); Response.Close(); } } }
private void BindGrid() { string strIDPath = Request.QueryString["id"]; CoursewareBLL coursewareBLL = new CoursewareBLL(); IList <RailExam.Model.Courseware> coursewares = new List <RailExam.Model.Courseware>(); OrganizationBLL orgBll = new OrganizationBLL(); int orgID = orgBll.GetStationOrgID(PrjPub.CurrentLoginUser.OrgID); if (Request.QueryString.Get("type") == "Courseware") { coursewares = coursewareBLL.GetCoursewaresByCoursewareTypeID(Convert.ToInt32(strIDPath), orgID); } else if (Request.QueryString.Get("type") == "TrainType") { coursewares = coursewareBLL.GetCoursewaresByTrainTypeID(Convert.ToInt32(strIDPath), orgID); } else { coursewares = coursewareBLL.GetCoursewaresByPostID(Convert.ToInt32(strIDPath), orgID); } if (coursewares != null) { foreach (RailExam.Model.Courseware obj in coursewares) { if (obj.CoursewareName.Length <= 20) { obj.CoursewareName = "<a onclick=OpenIndex('" + obj.CoursewareID + "') href=# title=" + obj.CoursewareName + " > " + obj.CoursewareName + " </a>"; } else { obj.CoursewareName = "<a onclick=OpenIndex('" + obj.CoursewareID + "') href=# title=" + obj.CoursewareName + " > " + obj.CoursewareName.Substring(0, 20) + "...</a>"; } } Grid1.DataSource = coursewares; Grid1.DataBind(); } }
private void BindGridCourseByCoursewareTypeID() { int typeID = Convert.ToInt32(ViewState["KnowledgeID"].ToString()); int postID = Convert.ToInt32(ViewState["PostID"].ToString()); int orgID = Convert.ToInt32(ViewState["OrgID"].ToString()); int techID = Convert.ToInt32(ViewState["Tech"].ToString()); int leader = Convert.ToInt32(ViewState["Leader"].ToString()); CoursewareBLL coursewareBLL = new CoursewareBLL(); IList <RailExam.Model.Courseware> coursewareList = coursewareBLL.GetStudyCoursewareInfoByTypeID(typeID, orgID, postID, leader, techID, 0); if (coursewareList.Count > 0) { foreach (RailExam.Model.Courseware courseware in coursewareList) { courseware.CoursewareName = "<a onclick=OpenCourse('" + courseware.CoursewareID + "') href=# title=" + courseware.CoursewareName + ">" + courseware.CoursewareName + "</a>"; } Grid2.DataSource = coursewareList; Grid2.DataBind(); } }
protected void btnOK_Click(object sender, EventArgs e) { if (Request.QueryString.Get("TrainTypeID") != null) { int bookID = Convert.ToInt32(Request.QueryString.Get("CoursewareID")); int trainTypeID = Convert.ToInt32(Request.QueryString.Get("TrainTypeID")); CoursewareTrainTypeBLL objBll = new CoursewareTrainTypeBLL(); CoursewareTrainType obj = objBll.GetCoursewareTrainType(bookID, trainTypeID); int order = Convert.ToInt32(txtOrderIndex.Text); int max = Convert.ToInt32(Request.QueryString.Get("MaxOrder")); if (order > max) { obj.OrderIndex = max; } else { obj.OrderIndex = order; } objBll.UpdateCoursewareTrainType(obj); } else { CoursewareBLL objBll = new CoursewareBLL(); RailExam.Model.Courseware obj = objBll.GetCourseware(Convert.ToInt32(Request.QueryString.Get("CoursewareID"))); int order = Convert.ToInt32(txtOrderIndex.Text); int max = Convert.ToInt32(Request.QueryString.Get("MaxOrder")); if (order > max) { obj.OrderIndex = max; } else { obj.OrderIndex = order; } objBll.UpdateCourseware(obj); } Response.Write("<script>top.returnValue='true';window.close();</script>"); }
private void BindGridCourseByCoursewareTypeID() { int typeID = Convert.ToInt32(ViewState["KnowledgeID"]); CoursewareBLL coursewareBLL = new CoursewareBLL(); IList <RailExam.Model.Courseware> coursewareList = coursewareBLL.GetCoursewaresByCoursewareTypeID(typeID, 200); if (ViewState["PostID"] != null && ViewState["PostID"].ToString() != "undefined") { int postID = Int32.Parse(ViewState["PostID"].ToString()); coursewareList = coursewareBLL.GetStudyCoursewareInfoByTypeID(typeID, 200, postID, 0, 1, 0); } if (coursewareList.Count > 0) { foreach (RailExam.Model.Courseware courseware in coursewareList) { courseware.CoursewareName = "<a onclick=OpenCourse('" + courseware.CoursewareID + "') href=# title=" + courseware.CoursewareName + ">" + courseware.CoursewareName + "</a>"; } Grid2.DataSource = coursewareList; Grid2.DataBind(); } }
private void DeleteData(int nCoursewareID) { CoursewareBLL coursewareBLL = new CoursewareBLL(); coursewareBLL.DeleteCourseware(nCoursewareID); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (PrjPub.CurrentLoginUser == null) { Response.Redirect("/RailExamBao/Common/Error.aspx?error=Session过期请重新登录本系统!"); return; } if (PrjPub.HasEditRight("课件管理") && PrjPub.IsServerCenter) //&& PrjPub.CurrentLoginUser.SuitRange == 1 { HfUpdateRight.Value = "True"; } else { HfUpdateRight.Value = "False"; } if (PrjPub.HasDeleteRight("课件管理") && PrjPub.IsServerCenter) //&& PrjPub.CurrentLoginUser.SuitRange == 1 { HfDeleteRight.Value = "True"; } else { HfDeleteRight.Value = "False"; } OrganizationBLL orgBll = new OrganizationBLL(); int orgID = orgBll.GetStationOrgID(PrjPub.CurrentLoginUser.OrgID); HfOrgId.Value = orgID.ToString(); BindGrid(); } else { string strDeleteID = Request.Form.Get("DeleteID"); if (!string.IsNullOrEmpty(strDeleteID)) { DeleteData(int.Parse(strDeleteID)); BindGrid(); } if (Request.Form.Get("Refresh") == "true") { BindGrid(); } } string strUpID = Request.Form.Get("UpID"); if (strUpID != null && strUpID != "") { if (Request.QueryString.Get("type") == "Courseware") { CoursewareBLL objBll = new CoursewareBLL(); RailExam.Model.Courseware obj = objBll.GetCourseware(Convert.ToInt32(strUpID)); obj.OrderIndex = obj.OrderIndex - 1; objBll.UpdateCourseware(obj); } if (Request.QueryString.Get("type") == "TrainType") { int trainTypeID = Convert.ToInt32(Request.QueryString.Get("id")); CoursewareTrainTypeBLL objTrainTypeBll = new CoursewareTrainTypeBLL(); CoursewareTrainType objTrainType = objTrainTypeBll.GetCoursewareTrainType(Convert.ToInt32(strUpID), trainTypeID); objTrainType.OrderIndex = objTrainType.OrderIndex - 1; objTrainTypeBll.UpdateCoursewareTrainType(objTrainType); } BindGrid(); } string strDownID = Request.Form.Get("DownID"); if (strDownID != null && strDownID != "") { if (Request.QueryString.Get("type") == "Courseware") { CoursewareBLL objBll = new CoursewareBLL(); RailExam.Model.Courseware obj = objBll.GetCourseware(Convert.ToInt32(strDownID)); obj.OrderIndex = obj.OrderIndex + 1; objBll.UpdateCourseware(obj); } if (Request.QueryString.Get("type") == "TrainType") { int trainTypeID = Convert.ToInt32(Request.QueryString.Get("id")); CoursewareTrainTypeBLL objTrainTypeBll = new CoursewareTrainTypeBLL(); CoursewareTrainType objTrainType = objTrainTypeBll.GetCoursewareTrainType(Convert.ToInt32(strDownID), trainTypeID); objTrainType.OrderIndex = objTrainType.OrderIndex + 1; objTrainTypeBll.UpdateCoursewareTrainType(objTrainType); } BindGrid(); } }
private void BindGrid() { string strIDPath = Request.QueryString["id"]; CoursewareBLL coursewareBLL = new CoursewareBLL(); IList <RailExam.Model.Courseware> coursewares = new List <RailExam.Model.Courseware>(); OrganizationBLL orgBll = new OrganizationBLL(); int orgID = orgBll.GetStationOrgID(PrjPub.CurrentLoginUser.OrgID); if (Request.QueryString.Get("type") == "Courseware") { coursewares = coursewareBLL.GetCoursewaresByCoursewareTypeID(Convert.ToInt32(strIDPath), orgID); } else { coursewares = coursewareBLL.GetCoursewaresByTrainTypeID(Convert.ToInt32(strIDPath), orgID); } OracleAccess oa = new OracleAccess(); int railSystemid = PrjPub.RailSystemId(); if (railSystemid != 0) { IList <RailExam.Model.Courseware> coursewaresVia = new List <RailExam.Model.Courseware>(); string sql = String.Format( @"select courseware_id from courseware_RANGE_ORG t where org_Id in (select org_id from org where rail_System_Id={0} and level_num=2) ", railSystemid ); DataSet dscoursewareIDs = oa.RunSqlDataSet(sql); if (dscoursewareIDs != null && dscoursewareIDs.Tables.Count > 0) { foreach (RailExam.Model.Courseware courseware in coursewares) { DataRow[] drs = dscoursewareIDs.Tables[0].Select("courseware_id=" + courseware.CoursewareID); if (drs.Length > 0) { coursewaresVia.Add(courseware); } } coursewares.Clear(); coursewares = coursewaresVia; } } if (coursewares != null) { foreach (RailExam.Model.Courseware obj in coursewares) { if (obj.CoursewareName.Length <= 20) { obj.CoursewareName = "<a onclick=OpenIndex('" + obj.CoursewareID + "') href=# title=" + obj.CoursewareName + " > " + obj.CoursewareName + " </a>"; } else { obj.CoursewareName = "<a onclick=OpenIndex('" + obj.CoursewareID + "') href=# title=" + obj.CoursewareName + " > " + obj.CoursewareName.Substring(0, 20) + "...</a>"; } } Grid1.DataSource = coursewares; Grid1.DataBind(); } }
private void BindWareTree() { tvWare.Nodes.Clear(); CoursewareTypeBLL coursewareTypeBll = new CoursewareTypeBLL(); IList <CoursewareType> coursewareTypeList = coursewareTypeBll.GetCoursewareTypes(0, 0, "", 0, 0, "", "", "", 0, 40, "LevelNum,OrderIndex Asc"); ArrayList objList = GetCourseWareList(); if (coursewareTypeList.Count > 0) { TreeViewNode tvn = null; foreach (CoursewareType coursewareType in coursewareTypeList) { tvn = new TreeViewNode(); tvn.ID = coursewareType.CoursewareTypeId.ToString(); tvn.Value = coursewareType.CoursewareTypeId.ToString(); tvn.Text = coursewareType.CoursewareTypeName; tvn.ToolTip = coursewareType.CoursewareTypeName; if (coursewareType.ParentId == 0) { tvWare.Nodes.Add(tvn); } else { try { tvWare.FindNodeById(coursewareType.ParentId.ToString()).Nodes.Add(tvn); } catch { tvWare.Nodes.Clear(); Response.Write("数据错误!"); return; } } } } tvWare.DataBind(); foreach (TreeViewNode node1 in tvWare.Nodes) { if (node1.Nodes.Count > 0) { foreach (TreeViewNode node in node1.Nodes) { CoursewareBLL coursewareBll = new CoursewareBLL(); IList <RailExam.Model.Courseware> coursewareList = null; //coursewareBll.GetCoursewares(Convert.ToString(node.Value), -1); if (coursewareList.Count > 0) { foreach (RailExam.Model.Courseware courseware in coursewareList) { TreeViewNode tvn = new TreeViewNode(); tvn.ID = courseware.CoursewareTypeID.ToString(); tvn.Value = courseware.CoursewareID.ToString(); tvn.Text = courseware.CoursewareName; tvn.ToolTip = courseware.CoursewareName; tvn.ShowCheckBox = true; if (objList.Count > 0) { if (objList.IndexOf(courseware.CoursewareID.ToString()) != -1) { tvn.Checked = true; } } tvWare.FindNodeById(node.ID.ToString()).Nodes.Add(tvn); } } } } } tvWare.DataBind(); tvWare.ExpandAll(); }
private void FillPage(int nCoursewareID) { CoursewareBLL coursewareBLL = new CoursewareBLL(); ArrayList trainTypeIDAL = new ArrayList(); ArrayList orgIDAL = new ArrayList(); ArrayList postIDAL = new ArrayList(); RailExam.Model.Courseware courseware = coursewareBLL.GetCourseware(nCoursewareID); if (courseware != null) { txtCoursewareName.Text = courseware.CoursewareName; txtCoursewareTypeName.Text = courseware.CoursewareTypeNames; hfCoursewareTypeID.Value = courseware.CoursewareTypeID.ToString(); txtTrainTypeName.Text = courseware.TrainTypeNames; txtProvideOrgName.Text = courseware.ProvideOrgName; hfProvideOrgID.Value = courseware.ProvideOrg.ToString(); datePublishDate.DateValue = courseware.PublishDate.ToString("yyyy-MM-dd"); txtAuthors.Text = courseware.Authors; txtRevisers.Text = courseware.Revisers; txtKeyWord.Text = courseware.KeyWord; txtDescription.Text = courseware.Description; string strUrl = string.Empty; strUrl = "ViewCourseware.aspx?id=" + courseware.CoursewareID; hlUrl.Text = strUrl; hlUrl.NavigateUrl = strUrl; ddlIsGroup.SelectedValue = courseware.IsGroupLearder.ToString(); ddlTech.SelectedValue = courseware.TechnicianTypeID.ToString(); hfOrderIndex.Value = courseware.OrderIndex.ToString(); txtMemo.Text = courseware.Memo; trainTypeIDAL = courseware.TrainTypeIDAL; orgIDAL = courseware.OrgIDAL; postIDAL = courseware.PostIDAL; } //tvOrg.Nodes.Clear(); //tvPost.Nodes.Clear(); BindOrganizationTree(orgIDAL); BindPostTree(postIDAL); string strUpdate = PrjPub.HasEditRight("课件管理").ToString(); string strOrgID = PrjPub.CurrentLoginUser.OrgID.ToString(); if (courseware != null) { //if (strUpdate == "True" && strOrgID == courseware.ProvideOrg.ToString()) if (strUpdate == "True" && PrjPub.CurrentLoginUser.SuitRange == 1) { SaveButton.Visible = true; CancelButton.Visible = false; } else { SaveButton.Visible = false; CancelButton.Visible = true; } } string strMode = Request.QueryString.Get("mode"); if (strMode == "ReadOnly") { SaveButton.Visible = false; CancelButton.Visible = true; //隐藏图片 txtCoursewareName.ReadOnly = true; txtAuthors.ReadOnly = true; txtRevisers.ReadOnly = true; txtKeyWord.ReadOnly = true; txtDescription.ReadOnly = true; txtMemo.ReadOnly = true; } else { SaveButton.Visible = true; CancelButton.Visible = false; for (int i = 0; i < trainTypeIDAL.Count; i++) { if (i == 0) { hfTrainTypeID.Value = trainTypeIDAL[0].ToString(); } else { hfTrainTypeID.Value += "," + trainTypeIDAL[i].ToString(); } } } ViewState["AddFlag"] = 0; }
protected void SaveButton_Click(object sender, EventArgs e) { string strFullName = string.Empty; //, strUrl, strContentType, strSize CoursewareBLL coursewareBLL = new CoursewareBLL(); if (ViewState["AddFlag"].ToString() == "1") //新增 { strFullName = File1.FileName; //直接取得文件名 if (!string.IsNullOrEmpty(strFullName)) { FileInfo fi = new FileInfo(File1.FileName); //判断只能上传.flv与.swf格式 //if (fi.Extension.ToLower() != ".flv" && fi.Extension.ToLower() != ".swf") //{ // SessionSet.PageMessage = "文件格式应为FLV或SWF视频! 现在格式为:" + fi.Extension.ToLower(); // return; //} if (fi.Name.Replace(fi.Extension, "") != txtCoursewareName.Text) { SessionSet.PageMessage = "上传文件名与课件名不一致,请确认上传文件名!"; return; } } RailExam.Model.Courseware courseware = new RailExam.Model.Courseware(); courseware.CoursewareName = txtCoursewareName.Text; courseware.CoursewareTypeID = int.Parse(hfCoursewareTypeID.Value); courseware.ProvideOrg = SessionSet.OrganizationID; courseware.PublishDate = DateTime.Parse(datePublishDate.DateValue.ToString()); courseware.Authors = txtAuthors.Text; courseware.Revisers = txtRevisers.Text; courseware.KeyWord = txtKeyWord.Text; courseware.Description = txtDescription.Text; courseware.Memo = txtMemo.Text; courseware.IsGroupLearder = Convert.ToInt32(ddlIsGroup.SelectedValue); courseware.TechnicianTypeID = Convert.ToInt32(ddlTech.SelectedValue); ArrayList al = new ArrayList(); courseware.OrgIDAL = GetOrg(tvOrg.Nodes, al); ArrayList al1 = new ArrayList(); foreach (TreeViewNode tn in tvPost.Nodes) { if (tn.Checked) { al1.Add(tn.ID); } if (tn.Nodes.Count > 0) { foreach (TreeViewNode tns in tn.Nodes) { if (tns.Checked) { al1.Add(tns.ID); } if (tns.Nodes.Count > 0) { foreach (TreeViewNode tnss in tns.Nodes) { if (tnss.Checked) { al1.Add(tnss.ID); } } } } } } courseware.PostIDAL = al1; ArrayList trainTypeIDList = new ArrayList(); string[] strType = hfTrainTypeID.Value.Split(','); for (int i = 0; i < strType.Length; i++) { if (!string.IsNullOrEmpty(strType[i])) { trainTypeIDList.Add(strType[i]); } } courseware.TrainTypeIDAL = trainTypeIDList; int nCoursewareID = coursewareBLL.AddCourseware(courseware); if (!string.IsNullOrEmpty(strFullName)) { //strUrl = File1.PostedFile.FileName;//先取得全部的上传文件路径个名字,然后再利用SubString方法来得到用户名,现在看来是没有必要了 //strContentType = File1.PostedFile.ContentType;//获取文件MIME内容类型 //strFileType = strFullName.Substring(strFullName.LastIndexOf(".") + 1);//获取文件名字 . 后面的字符作为文件类型 //strSize = File1.PostedFile.ContentLength.ToString(); Directory.CreateDirectory(Server.MapPath("../Online/Courseware/" + nCoursewareID)); File1.SaveAs(Server.MapPath("../Online/Courseware/" + nCoursewareID + "/") + strFullName); //将文件保存在跟目录的UP文件夹下 courseware.CoursewareID = nCoursewareID; courseware.Url = "/RailExamBao/Online/Courseware/" + nCoursewareID + "/" + strFullName; coursewareBLL.UpdateCourseware(courseware); } Response.Write("<script>window.opener.form1.Refresh.value='true';window.opener.form1.submit();window.close();</script>"); } else //修改 { string strCoursewareID = Request.QueryString.Get("id"); RailExam.Model.Courseware courseware = coursewareBLL.GetCourseware(Convert.ToInt32(strCoursewareID)); courseware.CoursewareID = int.Parse(strCoursewareID); courseware.CoursewareName = txtCoursewareName.Text; courseware.CoursewareTypeID = int.Parse(hfCoursewareTypeID.Value); courseware.ProvideOrg = int.Parse(hfProvideOrgID.Value); courseware.PublishDate = DateTime.Parse(datePublishDate.DateValue.ToString()); courseware.Authors = txtAuthors.Text; courseware.Revisers = txtRevisers.Text; courseware.KeyWord = txtKeyWord.Text; courseware.Description = txtDescription.Text; courseware.IsGroupLearder = Convert.ToInt32(ddlIsGroup.SelectedValue); courseware.TechnicianTypeID = Convert.ToInt32(ddlTech.SelectedValue); courseware.OrderIndex = Convert.ToInt32(hfOrderIndex.Value); strFullName = File1.FileName; //直接取得文件名 //strUrl = File1.PostedFile.FileName;//先取得全部的上传文件路径个名字,然后再利用SubString方法来得到用户名,现在看来是没有必要了 //strContentType = File1.PostedFile.ContentType;//获取文件MIME内容类型 //strFileType = strFullName.Substring(strFullName.LastIndexOf(".") + 1);//获取文件名字 . 后面的字符作为文件类型 //strSize = File1.PostedFile.ContentLength.ToString(); if (!string.IsNullOrEmpty(strFullName)) { FileInfo fi = new FileInfo(File1.FileName); //如果是武汉,就判断只能上传.flv与.swf格式 //if (fi.Extension.ToLower() != ".flv" && fi.Extension.ToLower() != ".swf") //{ // SessionSet.PageMessage = "文件格式应为FLV或SWF视频! 现在格式为:" + fi.Extension.ToLower(); // return; //} if (fi.Name.Replace(fi.Extension, "") != txtCoursewareName.Text) { SessionSet.PageMessage = "上传文件名与课件名不一致,请确认上传文件名!"; return; } if (File.Exists(Server.MapPath(courseware.Url))) { //string[] filelist = Directory.GetFileSystemEntries(Server.MapPath("../Online/Courseware/" + courseware.CoursewareID + "/")); //foreach (string file in filelist) //{ // if(!Directory.Exists(file)) // { // File.Delete(file); // } //} File.Delete(Server.MapPath(courseware.Url)); } if (!Directory.Exists(Server.MapPath("../Online/Courseware/" + strCoursewareID))) { Directory.CreateDirectory(Server.MapPath("../Online/Courseware/" + strCoursewareID)); } File1.SaveAs(Server.MapPath("../Online/Courseware/" + strCoursewareID + "/") + strFullName); //将文件保存在跟目录的UP文件夹下 courseware.Url = "/RailExamBao/Online/Courseware/" + strCoursewareID + "/" + strFullName; } courseware.Memo = txtMemo.Text; ArrayList al = new ArrayList(); courseware.OrgIDAL = GetOrg(tvOrg.Nodes, al); ArrayList al1 = new ArrayList(); foreach (TreeViewNode tn in tvPost.Nodes) { if (tn.Checked) { al1.Add(tn.ID); } if (tn.Nodes.Count > 0) { foreach (TreeViewNode tns in tn.Nodes) { if (tns.Checked) { al1.Add(tns.ID); } if (tns.Nodes.Count > 0) { foreach (TreeViewNode tnss in tns.Nodes) { if (tnss.Checked) { al1.Add(tnss.ID); } } } } } } courseware.PostIDAL = al1; ArrayList trainTypeIDList = new ArrayList(); string[] strType = hfTrainTypeID.Value.Split(','); for (int i = 0; i < strType.Length; i++) { if (!string.IsNullOrEmpty(strType[i])) { trainTypeIDList.Add(strType[i]); } } courseware.TrainTypeIDAL = trainTypeIDList; coursewareBLL.UpdateCourseware(courseware); Response.Write("<script>window.opener.form1.Refresh.value='true';window.opener.form1.submit();window.close();</script>"); } }