181 lines
6.2 KiB
C#
181 lines
6.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;
|
||
|
||
namespace VRS.Management
|
||
{
|
||
public partial class UserManage_Edit : BasePage
|
||
{
|
||
DataService.BLL.admin_user bll = new DataService.BLL.admin_user();
|
||
//DataService.BLL.admin_user_role bllAUR = new DataService.BLL.admin_user_role();
|
||
DataService.BLL.admin_log log = new DataService.BLL.admin_log();
|
||
protected override void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
//VerifyPermissions("10016");
|
||
//BindSystemRoles(dpRole);
|
||
BindRole(dpRole, "");
|
||
DataLoad();
|
||
}
|
||
}
|
||
|
||
protected void DataLoad()
|
||
{
|
||
string Id = Request.Params["Id"];
|
||
if (!string.IsNullOrWhiteSpace(Id))
|
||
{
|
||
var model = bll.GetModel(Id);
|
||
login_name.Text = model.login_name;
|
||
login_name.Enabled = false;
|
||
real_name.Text = model.real_name;
|
||
nick_name.Text = model.nick_name;
|
||
//id_card.Text = model.id_card;
|
||
|
||
mobile.Text = model.mobile;
|
||
sex.SelectedValue = model.sex;
|
||
cbx_unit.Text = model.unit;
|
||
|
||
lock_state.SelectedValue = model.is_lock;
|
||
dpRole.SelectedValue = model.user_role;
|
||
imgTopic.ImageUrl = model.photo;
|
||
|
||
//remark.Text = model.r1;
|
||
|
||
if (model.login_name.Equals("admin"))
|
||
{
|
||
//job_state.Enabled = false;
|
||
dpRole.Enabled = false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
OnError(null);
|
||
}
|
||
}
|
||
|
||
protected void btnSure_Click(object sender, EventArgs e)
|
||
{
|
||
string Id = Request.Params["Id"];
|
||
//var validity = password_validity.SelectedDate.HasValue ? password_validity.SelectedDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
|
||
if (string.IsNullOrEmpty(real_name.Text))
|
||
{
|
||
RadAjaxManager1.Alert("姓名不能为空!");
|
||
return;
|
||
}
|
||
|
||
//if (bll.GetRecordCount(string.Format(" user_id != '{0}' AND mac_address = '{1}' ", Id, mac_address.Text.Trim())) > 0)
|
||
//{
|
||
// RadAjaxManager1.Alert("MAC地址禁止重复!");
|
||
// return;
|
||
//}
|
||
|
||
DataService.Model.admin_user model = bll.GetModel(Id);
|
||
model.real_name = real_name.Text.Trim();
|
||
if (!string.IsNullOrWhiteSpace(password.Text.Trim()))
|
||
model.password = GetMD5(password.Text.Trim());
|
||
|
||
model.nick_name = nick_name.Text.Trim();
|
||
model.mobile = mobile.Text.Trim();
|
||
model.sex = sex.SelectedValue;
|
||
|
||
model.unit = cbx_unit.Text.Trim();
|
||
model.is_lock = lock_state.SelectedValue;
|
||
//model.r1 = remark.Text;
|
||
model.user_role = dpRole.SelectedValue;
|
||
model.photo = imgTopic.ImageUrl;
|
||
|
||
if (bll.Update(model))
|
||
{
|
||
//string CacheKey = "admin_userModelList";
|
||
//var objModel = bll.GetModelList(" login_name!='admin'");
|
||
//Maticsoft.Common.DataCache.SetCache(CacheKey, objModel);
|
||
log.write_log("修改用户成功。" + "姓名:" + real_name.Text.Trim() + ",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.Delete(path);
|
||
}
|
||
video.Src = "";
|
||
}
|
||
}
|
||
}
|
||
} |