107 lines
3.5 KiB
C#
107 lines
3.5 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 DeviceManage_Add : BasePage
|
||
{
|
||
DataService.BLL.admin_log log = new DataService.BLL.admin_log();
|
||
DataService.BLL.pro_device bll = new DataService.BLL.pro_device();
|
||
protected override void Page_Load(object sender, EventArgs e)
|
||
{
|
||
base.Page_Load(sender, e);
|
||
if (!IsPostBack)
|
||
{
|
||
BindDeviceType("5",dp_devicetype, "");
|
||
BindDeviceType("9", status, "");
|
||
|
||
}
|
||
}
|
||
protected void btnSure_Click(object sender, EventArgs e)
|
||
{
|
||
if (string.IsNullOrEmpty(device_name.Text))
|
||
{
|
||
RadAjaxManager1.Alert("设备名称不能为空!");
|
||
return;
|
||
}
|
||
|
||
if (string.IsNullOrEmpty(dp_devicetype.SelectedValue))
|
||
{
|
||
RadAjaxManager1.Alert("设备类型不能为空!");
|
||
return;
|
||
}
|
||
|
||
if (bll.GetRecordCount(string.Format(" device_name = '{0}' ", device_name.Text.Trim())) > 0)
|
||
{
|
||
RadAjaxManager1.Alert("设备名称禁止重复!");
|
||
return;
|
||
}
|
||
|
||
DataService.Model.pro_device model = new DataService.Model.pro_device();
|
||
model.device_id = GetNewId("dev");
|
||
model.device_name = device_name.Text.Trim();
|
||
model.purpose = purpose.Text.Trim();
|
||
|
||
model.dsc = desc.Text.Trim();
|
||
//model.device_logo = device_logo.Text;
|
||
model.device_logo = imgTopic.ImageUrl;
|
||
model.state = status.SelectedValue;
|
||
model.device_type = dp_devicetype.SelectedValue;
|
||
model.create_time = DateTime.Now;
|
||
model.start_time = start_time.SelectedDate;
|
||
model.r1 = r1.Text;
|
||
if (bll.Add(model))
|
||
{
|
||
log.write_log("添加设备成功。" + "设备名称:" + device_name.Text.Trim() + ",设备ID:" + model.device_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 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))
|
||
{
|
||
imgTopic.ImageUrl = "~" + filePath;
|
||
}
|
||
else
|
||
{
|
||
RadAjaxManager1.Alert("上传失败!");
|
||
}
|
||
}
|
||
|
||
protected void btnRemove_Click(object sender, EventArgs e)
|
||
{
|
||
if (!string.IsNullOrEmpty(imgTopic.ImageUrl))
|
||
{
|
||
string path = Server.MapPath(imgTopic.ImageUrl);
|
||
File.Delete(path);
|
||
imgTopic.ImageUrl = "";
|
||
}
|
||
}
|
||
}
|
||
} |