160 lines
5.2 KiB
C#
160 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
|
||
{
|
||
public partial class ComAbout_Edit : BasePage
|
||
{
|
||
DataService.BLL.pro_com_about bll = new DataService.BLL.pro_com_about();
|
||
DataService.BLL.admin_log log = new DataService.BLL.admin_log();
|
||
protected override void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
DataLoad();
|
||
}
|
||
}
|
||
|
||
protected void DataLoad()
|
||
{
|
||
var model = bll.GetModelList("").FirstOrDefault();
|
||
if (null != model)
|
||
{
|
||
com_title.Text = model.com_title;
|
||
com_content.Text = model.com_content;
|
||
contact_us.Text = model.contact_us;
|
||
our_position.Text = model.our_position;
|
||
our_vision.Text = model.our_vision;
|
||
our_value.Text = model.our_value;
|
||
imgTopic.ImageUrl = model.com_pic;
|
||
}
|
||
else
|
||
{
|
||
OnError(null);
|
||
}
|
||
}
|
||
|
||
protected void btnSure_Click(object sender, EventArgs e)
|
||
{
|
||
/*
|
||
if (string.IsNullOrEmpty(real_name.Text))
|
||
{
|
||
RadAjaxManager1.Alert("姓名不能为空!");
|
||
return;
|
||
}
|
||
*/
|
||
/*
|
||
if (string.IsNullOrEmpty(app_name.Text) || string.IsNullOrEmpty(dp_major.SelectedValue))
|
||
{
|
||
RadAjaxManager1.Alert("应用名称、专业分类、科目分类、软件分类不能为空!");
|
||
return;
|
||
}
|
||
*/
|
||
var model = bll.GetModelList("").FirstOrDefault();
|
||
if (null != model)
|
||
{
|
||
model.com_title = com_title.Text.Trim();
|
||
model.com_content = com_content.Text.Trim();
|
||
model.contact_us = contact_us.Text.Trim();
|
||
|
||
model.our_position = our_position.Text.Trim();
|
||
model.our_vision = our_vision.Text.Trim();
|
||
model.our_value = our_value.Text.Trim();
|
||
model.com_pic = imgTopic.ImageUrl;
|
||
|
||
if (bll.Update(model))
|
||
{
|
||
log.write_log("修改关于我们成功。" + "名称:" + com_title.Text.Trim() + ",ID:" + model.id);
|
||
RadAjaxManager1.ResponseScripts.Add("alert('修改成功!');");
|
||
}
|
||
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 = "0";// 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 = "";
|
||
}
|
||
}
|
||
}
|
||
} |