171 lines
5.2 KiB
C#
171 lines
5.2 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;
|
||
using Telerik.Web.UI;
|
||
|
||
namespace VRS.Management.VSAT
|
||
{
|
||
public partial class FaultExam_Edit : BasePage
|
||
{
|
||
DataService.BLL.pro_fault_exam bll = new DataService.BLL.pro_fault_exam();
|
||
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);
|
||
exam_title.Text = model.exam_title;
|
||
yyfx.Text = model.yyfx;
|
||
gzdw.Text = model.gzdw;
|
||
pcff.Text = model.pcff;
|
||
imgTopic.ImageUrl = model.pic1;
|
||
imgTopic2.ImageUrl = model.pic2;
|
||
imgTopic3.ImageUrl = model.pic3;
|
||
imgTopic4.ImageUrl = model.pic4;
|
||
imgTopic5.ImageUrl = model.pic5;
|
||
}
|
||
else
|
||
{
|
||
OnError(null);
|
||
}
|
||
}
|
||
|
||
protected void btnSure_Click(object sender, EventArgs e)
|
||
{
|
||
var id = Request.Params["Id"];
|
||
if (string.IsNullOrEmpty(exam_title.Text))
|
||
{
|
||
RadAjaxManager1.Alert("故障标题不能为空!");
|
||
return;
|
||
}
|
||
|
||
/*
|
||
if (bll.GetRecordCount(string.Format(" exam_title = '{0}' ", exam_title.Text.Trim())) > 0)
|
||
{
|
||
RadAjaxManager1.Alert("故障标题禁止重复!");
|
||
return;
|
||
}*/
|
||
|
||
DataService.Model.pro_fault_exam model = bll.GetModel(Request.Params["Id"]);
|
||
model.exam_title = exam_title.Text.Trim();
|
||
model.yyfx = yyfx.Text.Trim();
|
||
model.gzdw = gzdw.Text.Trim();
|
||
model.pcff = pcff.Text.Trim();
|
||
model.pic1 = imgTopic.ImageUrl;
|
||
model.pic2 = imgTopic2.ImageUrl;
|
||
model.pic3 = imgTopic3.ImageUrl;
|
||
model.pic4 = imgTopic4.ImageUrl;
|
||
model.pic5 = imgTopic5.ImageUrl;
|
||
|
||
if (bll.Update(model))
|
||
{
|
||
log.write_log("修改故障题目成功。" + "故障标题:" + model.exam_title + ",id:" + model.exam_id);
|
||
RadAjaxManager1.ResponseScripts.Add("alert('修改成功!');CloseAndRebind();");
|
||
}
|
||
else
|
||
RadAjaxManager1.Alert("修改失败!");
|
||
}
|
||
|
||
public void upload_click(RadAsyncUpload Upload1, Image img)
|
||
{
|
||
if (Upload1.UploadedFiles.Count < 1)
|
||
{
|
||
RadAjaxManager1.Alert("未选择图片!");
|
||
return;
|
||
}
|
||
|
||
var uploadFile = Upload1.UploadedFiles[0];
|
||
var extension = uploadFile.GetExtension();
|
||
var extension_list = new string[] { ".jpg", ".png", ".jpeg", ".bmp", ".gif" };
|
||
if (!extension_list.Contains(extension))
|
||
{
|
||
RadAjaxManager1.Alert("文件格式错误!");
|
||
return;
|
||
}
|
||
|
||
if (BasePage.SaveFile(uploadFile, Context, out string filePath))
|
||
{
|
||
img.ImageUrl = "~" + filePath;
|
||
}
|
||
else
|
||
{
|
||
RadAjaxManager1.Alert("上传失败!");
|
||
}
|
||
}
|
||
|
||
protected void btnUpload_Click(object sender, EventArgs e)
|
||
{
|
||
upload_click(RadAsyncUpload1, imgTopic);
|
||
|
||
}
|
||
protected void btnUpload_Click2(object sender, EventArgs e)
|
||
{
|
||
upload_click(RadAsyncUpload2, imgTopic2);
|
||
}
|
||
protected void btnUpload_Click3(object sender, EventArgs e)
|
||
{
|
||
upload_click(RadAsyncUpload3, imgTopic3);
|
||
}
|
||
|
||
protected void btnUpload_Click4(object sender, EventArgs e)
|
||
{
|
||
upload_click(RadAsyncUpload4, imgTopic4);
|
||
}
|
||
protected void btnUpload_Click5(object sender, EventArgs e)
|
||
{
|
||
upload_click(RadAsyncUpload5, imgTopic5);
|
||
}
|
||
|
||
public void Remove_Click(Image img)
|
||
{
|
||
if (!string.IsNullOrEmpty(img.ImageUrl))
|
||
{
|
||
string path = Server.MapPath(img.ImageUrl);
|
||
if (File.Exists(path))
|
||
{
|
||
File.Delete(path);
|
||
}
|
||
img.ImageUrl = "";
|
||
}
|
||
}
|
||
|
||
protected void btnRemove_Click(object sender, EventArgs e)
|
||
{
|
||
Remove_Click(imgTopic);
|
||
|
||
}
|
||
protected void btnRemove_Click2(object sender, EventArgs e)
|
||
{
|
||
Remove_Click(imgTopic2);
|
||
}
|
||
|
||
protected void btnRemove_Click3(object sender, EventArgs e)
|
||
{
|
||
Remove_Click(imgTopic3);
|
||
}
|
||
|
||
protected void btnRemove_Click4(object sender, EventArgs e)
|
||
{
|
||
Remove_Click(imgTopic4);
|
||
}
|
||
|
||
protected void btnRemove_Click5(object sender, EventArgs e)
|
||
{
|
||
Remove_Click(imgTopic5);
|
||
}
|
||
}
|
||
} |