dlmh_system/VRS/Management/ComCertif_Add.aspx.cs

160 lines
4.9 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using System.IO;
namespace VRS.Management
{
public partial class ComCertif_Add : BasePage
{
DataService.BLL.pro_com_certif bll = new DataService.BLL.pro_com_certif();
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)
{
}
}
protected void btnSure_Click(object sender, EventArgs e)
{
/*
if (string.IsNullOrEmpty(app_name.Text) || string.IsNullOrEmpty(dp_major.SelectedValue) || string.IsNullOrEmpty(dp_subject.SelectedValue) || string.IsNullOrEmpty(dp_soft.SelectedValue))
{
RadAjaxManager1.Alert("应用名称、专业分类、科目分类、软件分类不能为空!");
return;
}
*/
/*
if (bll.GetRecordCount(string.Format(" login_name = '{0}' ", login_name.Text.Trim())) > 0)
{
RadAjaxManager1.Alert("账号禁止重复!");
return;
}
*/
if (string.IsNullOrEmpty(imgTopic.ImageUrl))
{
RadAjaxManager1.Alert("图片不能为空!");
return;
}
if (string.IsNullOrEmpty(dsc.Text))
{
RadAjaxManager1.Alert("描述不能为空!");
return;
}
var model = new DataService.Model.pro_com_certif();
model.id = BasePage.GetId();
model.type = dp_type.SelectedValue;
model.url = imgTopic.ImageUrl;
model.dsc = dsc.Text;
model.create_time = DateTime.Now;
if (bll.Add(model))
{
//log.write_log("添加应用成功。" + "应用:" + model.app_name + "ID" + model.user_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 = "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 = "";
}
}
}
}