using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace VRS.Management.VSAT { public partial class TechSpecManage_Add : BasePage { DataService.BLL.pro_know bll = new DataService.BLL.pro_know(); DataService.BLL.admin_log log = new DataService.BLL.admin_log(); DataService.BLL.pro_type_manage bll_type_manage = new DataService.BLL.pro_type_manage(); protected override void Page_Load(object sender, EventArgs e) { base.Page_Load(sender, e); if (!IsPostBack) { } } protected void btnSure_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(title.Text.Trim())) { RadAjaxManager1.Alert("标题不能为空!"); return; } if (bll.GetRecordCount(string.Format(" title = '{0}' ", title.Text.Trim())) > 0) { RadAjaxManager1.Alert("标题禁止重复!"); return; } if (string.IsNullOrEmpty(keyword.Text.Trim())) { RadAjaxManager1.Alert("关键字不能为空!"); return; } if (string.IsNullOrEmpty(file_link.HRef) || file_link.HRef == "#") { RadAjaxManager1.Alert("维修技术规范文档不能为空!"); return; } //设备名称唯一 DataService.Model.pro_know model = new DataService.Model.pro_know(); model.know_id = BasePage.GetNewId("tech"); model.title = title.Text.Trim(); //model.content = content.Text.Trim(); model.content = RadEditor1.Content; model.keyword = keyword.Text.Trim(); model.r1 = file_link.Title; model.pic_url = file_link.HRef; string type_id = ""; var type = bll_type_manage.GetModelList(" type_name='技术规范' ").FirstOrDefault(); if (null != type) { type_id = type.type_id; } model.type_id = type_id; if (bll.Add(model)) { log.write_log("添加技术规范成功。" + "名称:" + model.title + ",ID:" + model.know_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 array = new string[] { ".doc", ".docx", ".pdf", ".xls", ".xlsx", ".rar", ".swf" }; /* var extension = uploadFile.GetExtension(); if (!array.Contains(extension)) { RadAjaxManager1.Alert("文件格式错误!"); return; } */ if (BasePage.SaveFile(uploadFile, Context, out string filePath, out string originalName)) { file_link.HRef = "~" + filePath; file_link.InnerHtml = originalName; file_link.Title = originalName; } else { RadAjaxManager1.Alert("上传失败!"); } } protected void btnRemove_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(file_link.HRef)) { string path = Server.MapPath(file_link.HRef); if (File.Exists(path)) { File.Delete(path); } file_link.HRef = ""; file_link.InnerHtml = ""; file_link.Title = ""; } } } }