92 lines
3.0 KiB
C#
92 lines
3.0 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 TopicManage_Add : System.Web.UI.Page
|
|
{
|
|
//DataService.BLL.Usr_Topics bll = new DataService.BLL.Usr_Topics();
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
protected void btnSure_Click(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(txtTopicTitle.Text))
|
|
{
|
|
RadAjaxManager1.Alert("题干不得为空!");
|
|
return;
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(txtChoseA.Text)|| string.IsNullOrEmpty(txtChoseB.Text)|| string.IsNullOrEmpty(txtChoseC.Text))
|
|
{
|
|
RadAjaxManager1.Alert("选项不得为空!");
|
|
return;
|
|
}
|
|
/*
|
|
if (bll.GetRecordCount(string.Format(" TopicTitle = '{0}' ", txtTopicTitle.Text.Trim())) > 0)
|
|
{
|
|
RadAjaxManager1.Alert("无法重复添加数据!");
|
|
return;
|
|
}
|
|
|
|
DataService.Model.Usr_Topics model = new DataService.Model.Usr_Topics();
|
|
model.Id = Guid.NewGuid().ToString();
|
|
model.TopicTitle = txtTopicTitle.Text.Trim();
|
|
model.Remark2 = imgTopic.ImageUrl;
|
|
model.ChoseA = txtChoseA.Text.Trim();
|
|
model.ChoseB = txtChoseB.Text.Trim();
|
|
model.ChoseC = txtChoseC.Text.Trim();
|
|
model.ChoseReal = dpChoseReal.SelectedValue;
|
|
model.CreateTime = DateTime.Now;
|
|
model.Remark1 = txtRemark.Text;
|
|
|
|
if (bll.Add(model))
|
|
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];
|
|
if (uploadFile.GetExtension() != ".jpg" && uploadFile.GetExtension() != ".png")
|
|
{
|
|
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 = "";
|
|
}
|
|
}
|
|
}
|
|
} |