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_Edit : 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) { if (!IsPostBack) { BindDeviceType("5", dp_devicetype, ""); BindDeviceType("9", status, ""); DataLoad(); } } protected void DataLoad() { string Id = Request.Params["Id"]; if (!string.IsNullOrWhiteSpace(Id)) { var model = bll.GetModel(Id); device_name.Text = model.device_name; purpose.Text = model.purpose; desc.Text = model.dsc; dp_devicetype.SelectedValue = model.device_type; start_time.SelectedDate = model.start_time; status.SelectedValue = model.state; r1.Text = model.r1; if (!string.IsNullOrEmpty(model.device_logo)) { imgTopic.ImageUrl = model.device_logo; } } else { OnError(null); } } protected void btnSure_Click(object sender, EventArgs e) { DataService.Model.pro_device model = bll.GetModel(Request.Params["Id"]); model.device_name = device_name.Text.Trim(); model.purpose = purpose.Text.Trim(); model.dsc = desc.Text.Trim(); model.device_type = dp_devicetype.SelectedValue; model.start_time = start_time.SelectedDate; model.r1 = r1.Text; model.device_logo = imgTopic.ImageUrl; model.state = status.SelectedValue; if (bll.Update(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 = ""; } } } }