using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Telerik.Web.UI; namespace VRS.Management { public partial class Course_Edit : BasePage { DataService.BLL.pro_course bll = new DataService.BLL.pro_course(); DataService.BLL.admin_log log = new DataService.BLL.admin_log(); protected override void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //VerifyPermissions("10016"); //BindSystemRoles(dpRole); BindMajors(dp_major, ""); BindSoft(dp_soft, ""); DataLoad(); } } /// /// 绑定科目 /// /// /// protected void dp_major_SelectedIndexChanged(object sender, DropDownListEventArgs e) { var value = dp_major.SelectedValue; BindMajorSubject(value, dp_subject, ""); } protected void DataLoad() { string Id = Request.Params["Id"]; if (!string.IsNullOrWhiteSpace(Id)) { var model = bll.GetModel(Id); course_name.Text = model.course_name; dp_soft.SelectedValue = model.soft_id; dp_major.SelectedValue = model.major_id; BindMajorSubject(model.major_id, dp_subject, ""); dp_subject.SelectedValue = model.subject_id; video.Src = model.video_url; is_hot.SelectedValue = model.is_hot; //`soft_dsc` longtext '软件介绍', //`yw_dsc` longtext '业务介绍', //`func_dsc` longtext '功能介绍', } else { OnError(null); } } protected void btnSure_Click(object sender, EventArgs e) { string Id = Request.Params["Id"]; /* if (string.IsNullOrEmpty(real_name.Text)) { RadAjaxManager1.Alert("姓名不能为空!"); return; } */ if (string.IsNullOrEmpty(course_name.Text) || string.IsNullOrEmpty(dp_major.SelectedValue) || string.IsNullOrEmpty(dp_subject.SelectedValue) || string.IsNullOrEmpty(dp_soft.SelectedValue)) { RadAjaxManager1.Alert("课程名称、业务场景、专业分类、终端类型不能为空!"); return; } DataService.Model.pro_course model = bll.GetModel(Id); model.course_name = course_name.Text.Trim(); model.soft_id = dp_soft.SelectedValue; model.major_id = dp_major.SelectedValue; model.subject_id = dp_subject.SelectedValue; //`video_url` varchar(50) '视频介绍', model.video_url = video.Src; //`soft_dsc` longtext '软件介绍', //`yw_dsc` longtext '业务介绍', //`func_dsc` longtext '功能介绍', model.is_hot = is_hot.SelectedValue; if (bll.Update(model)) { log.write_log("修改课程成功。" + "名称:" + course_name.Text.Trim() + ",ID:" + model.id); RadAjaxManager1.ResponseScripts.Add("alert('修改成功!');CloseAndRebind();"); } else RadAjaxManager1.Alert("修改失败!"); } protected void btnUpload_Click(object sender, EventArgs e) { if (RadAsyncUpload1.UploadedFiles.Count < 1) { RadAjaxManager1.Alert("未选择视频!"); return; } var uploadFile = RadAsyncUpload1.UploadedFiles[0]; var upload_type = "1";// type.SelectedValue; if (upload_type == "0") //图片 { var arrray = Util.ConfigInfo.list_pic_type; var extension = uploadFile.GetExtension(); if (!arrray.Contains(extension)) { RadAjaxManager1.Alert("请上传图片!"); return; } } else if (upload_type == "1") //视频,.mp4,.avi,.dat,.3gp,.mov,.rmvb { var arrray = Util.ConfigInfo.list_video_type; var extension = uploadFile.GetExtension(); if (!arrray.Contains(extension)) { RadAjaxManager1.Alert("请上传视频!"); return; } } if (BasePage.SaveFile(uploadFile, Context, out string filePath)) { //imgTopic.ImageUrl = "~" + filePath; if (upload_type == "0") { td_pic.Visible = true; td_video.Visible = false; imgTopic.ImageUrl = "~" + filePath; } else { td_pic.Visible = false; td_video.Visible = true; video.Src = "~" + filePath; } } else { RadAjaxManager1.Alert("上传失败!"); } } protected void btnRemove_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(imgTopic.ImageUrl)) { string path = Server.MapPath(imgTopic.ImageUrl); if (File.Exists(path)) { File.SetAttributes(path, FileAttributes.Normal); File.Delete(path); } imgTopic.ImageUrl = ""; } if (!string.IsNullOrEmpty(video.Src)) { string path = Server.MapPath(video.Src); if (File.Exists(path)) { File.SetAttributes(path, FileAttributes.Normal); File.Delete(path); } video.Src = ""; } } } }