122 lines
4.1 KiB
C#
122 lines
4.1 KiB
C#
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_Edit : BasePage
|
||
{
|
||
DataService.BLL.pro_know bll = new DataService.BLL.pro_know();
|
||
DataService.BLL.admin_log log = new DataService.BLL.admin_log();
|
||
protected override void Page_Load(object sender, EventArgs e)
|
||
{
|
||
base.Page_Load(sender, e);
|
||
if (!IsPostBack)
|
||
{
|
||
|
||
DataLoad();
|
||
}
|
||
}
|
||
|
||
protected void DataLoad()
|
||
{
|
||
string Id = Request.Params["Id"];
|
||
if (!string.IsNullOrWhiteSpace(Id))
|
||
{
|
||
var model = bll.GetModel(Id);
|
||
title.Text = model.title;
|
||
keyword.Text = model.keyword;
|
||
//content.Text = model.content;
|
||
RadEditor1.Content = model.content;
|
||
file_link.HRef = model.pic_url;
|
||
file_link.InnerHtml = model.r1;
|
||
}
|
||
else
|
||
{
|
||
OnError(null);
|
||
}
|
||
}
|
||
|
||
protected void btnSure_Click(object sender, EventArgs e)
|
||
{
|
||
var id = Request.Params["Id"];
|
||
if (string.IsNullOrEmpty(title.Text.Trim()))
|
||
{
|
||
RadAjaxManager1.Alert("技术规范名称不能为空!");
|
||
return;
|
||
}
|
||
if (bll.GetRecordCount(string.Format(" title = '{0}' and know_id !='{1}'", title.Text.Trim(), id)) > 0)
|
||
{
|
||
RadAjaxManager1.Alert("技术规范名称禁止重复!");
|
||
return;
|
||
}
|
||
if (string.IsNullOrEmpty(keyword.Text.Trim()))
|
||
{
|
||
RadAjaxManager1.Alert("关键字不能为空!");
|
||
return;
|
||
}
|
||
DataService.Model.pro_know model = bll.GetModel(id);
|
||
model.title = title.Text.Trim();
|
||
model.keyword = keyword.Text.Trim();
|
||
//model.content = content.Text.Trim();
|
||
model.content = RadEditor1.Content;
|
||
model.pic_url = file_link.HRef;
|
||
model.r1 = file_link.Title;
|
||
if (bll.Update(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 = "";
|
||
}
|
||
}
|
||
}
|
||
} |