You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
197 lines
8.0 KiB
C#
197 lines
8.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using DSWeb.SoftMng.BLL;
|
|
using DSWeb.SoftMng.Model;
|
|
using DSWeb.SoftMng.Filter;
|
|
|
|
namespace DSWeb.SoftMng.Controllers
|
|
{
|
|
public class EmailSchemeController: Controller
|
|
{
|
|
private readonly t_code_cust_mailprojectBLL _bll = new t_code_cust_mailprojectBLL();
|
|
private readonly t_code_cust_mailproject_detailBLL _tbll = new t_code_cust_mailproject_detailBLL();
|
|
#region View
|
|
/// <summary>
|
|
/// 首页
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
//[ModuleAuthFilter(Name = "secRegist")]//过滤器
|
|
public ActionResult Index()
|
|
{
|
|
if (Session["CODENAME"] == null)
|
|
Response.Redirect("/login.aspx");
|
|
return View();
|
|
}
|
|
#endregion
|
|
#region Handler
|
|
/// <summary>
|
|
/// 获取列表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public JsonResult GetList(int startIndex, int limit, string search)
|
|
{
|
|
StringBuilder where = new StringBuilder();
|
|
where.Append("1=1");
|
|
if (!(String.IsNullOrEmpty(search) || String.IsNullOrWhiteSpace(search)))
|
|
where.Append(string.Format(" And ([方案名称] like '%{0}%' OR [客户名称] like '%{0}%')", search));
|
|
var list = _bll.GetModelList(startIndex, limit, where.ToString(), "[方案代码] ASC");
|
|
var result = from p in list
|
|
select new
|
|
{
|
|
f = p.方案代码,
|
|
k = p.客户名称,
|
|
k_Text=p.客户名称,
|
|
t = p.方案名称,
|
|
d = p.默认方案,
|
|
r = p.方案备注
|
|
};
|
|
var count = _bll.GetRecordCount(where.ToString());//总数
|
|
return Json(new { total = count, rows = result });
|
|
}
|
|
public JsonResult GetDetailList(int id)
|
|
{
|
|
StringBuilder where = new StringBuilder();
|
|
where.Append("[方案代码] = {0}");
|
|
var list = _tbll.GetModelList(string.Format(where.ToString(), id));
|
|
var result = from p in list
|
|
select new
|
|
{
|
|
p.DE_ID,
|
|
f = p.方案代码,
|
|
p = p.单据类型,
|
|
p_Text=p.单据类型,
|
|
s = p.收件人,
|
|
x = p.主题模板,
|
|
y = p.邮件内容,
|
|
z = p.附件名称
|
|
};
|
|
return Json(result);
|
|
}
|
|
/// <summary>
|
|
/// 保存主实例
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public JsonResult Save(t_code_cust_mailproject model)
|
|
{
|
|
bool result;
|
|
model.方案代码 = Convert.ToInt32(Request["f"] == "" ? "0" : Request["f"]);
|
|
if (model.方案代码==0)
|
|
{
|
|
model.方案名称 = Request["t"];
|
|
model.客户名称 = Request["k"];
|
|
model.方案备注 = Request["r"];
|
|
model.默认方案 = Convert.ToBoolean(Request["d"]);
|
|
model.录入人 = Session["SHOWNAME"].ToString();
|
|
model.录入日期 = DateTime.Now;
|
|
result = _bll.Add(model) > 0;
|
|
} //新增
|
|
else
|
|
{
|
|
//类反射
|
|
var oldModel = _bll.GetModel(model.方案代码);
|
|
Type type = typeof(t_code_cust_mailproject);
|
|
PropertyInfo[] piArr = type.GetProperties();
|
|
foreach (var pi in piArr)
|
|
{
|
|
if (Array.IndexOf(Request.Params.AllKeys, pi.Name) < 0)
|
|
pi.SetValue(model, pi.GetValue(oldModel, null), null);
|
|
}
|
|
model.方案名称 = Request["t"];
|
|
model.客户名称 = Request["k"];
|
|
model.方案备注 = Request["r"];
|
|
model.默认方案 = Convert.ToBoolean(Request["d"]);
|
|
result = _bll.Update(model) > 0;
|
|
} //修改
|
|
return Json(new { success = result, message = result ? "操作成功" : "操作失败" });
|
|
}
|
|
/// <summary>
|
|
/// 保存主实例
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public JsonResult SaveDetail(t_code_cust_mailproject_detail model)
|
|
{
|
|
bool result;
|
|
if (model.DE_ID == 0)
|
|
{
|
|
model.方案代码 = Convert.ToInt32(Request["f"] == "" ? "0" : Request["f"]);
|
|
model.单据类型 = Request["p"];
|
|
model.收件人 = Request["s"];
|
|
model.主题模板 = Request["x"];
|
|
model.邮件内容 = Request["y"];
|
|
model.附件名称 = Request["z"];
|
|
result = _tbll.Add(model) > 0;
|
|
} //新增
|
|
else
|
|
{
|
|
//类反射
|
|
var oldModel = _tbll.GetModel(model.DE_ID);
|
|
Type type = typeof(t_code_cust_mailproject_detail);
|
|
PropertyInfo[] piArr = type.GetProperties();
|
|
foreach (var pi in piArr)
|
|
{
|
|
if (Array.IndexOf(Request.Params.AllKeys, pi.Name) < 0)
|
|
pi.SetValue(model, pi.GetValue(oldModel, null), null);
|
|
}
|
|
model.单据类型 = Request["p"];
|
|
model.收件人 = Request["s"];
|
|
model.主题模板 = Request["x"];
|
|
model.邮件内容 = Request["y"];
|
|
model.附件名称 = Request["z"];
|
|
result = _tbll.Update(model) > 0;
|
|
} //修改
|
|
return Json(new { success = result, message = result ? "操作成功" : "操作失败" });
|
|
}
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
/// <param name="ids"></param>
|
|
/// <returns></returns>
|
|
public JsonResult Delete(string ids)
|
|
{
|
|
bool result = _bll.DeleteListWhere(string.Format("[方案代码] in({0})", ids)) > 0;
|
|
return Json(new { success = result, message = result ? "操作成功" : "操作失败" });
|
|
}
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
/// <param name="ids"></param>
|
|
/// <returns></returns>
|
|
public JsonResult DeleteDetail(string ids)
|
|
{
|
|
bool result = _tbll.DeleteListWhere(string.Format("[DE_ID] in({0})", ids)) > 0;
|
|
return Json(new { success = result, message = result ? "操作成功" : "操作失败" });
|
|
}
|
|
/// <summary>
|
|
/// 获取单据类型
|
|
/// </summary>
|
|
/// <param name="pageIndex"></param>
|
|
/// <param name="pageSize"></param>
|
|
/// <param name="query"></param>
|
|
/// <returns></returns>
|
|
public JsonResult GetDocType(int pageIndex, int pageSize, string query)
|
|
{
|
|
tSysEnumValueBLL ibll = new tSysEnumValueBLL();
|
|
StringBuilder where = new StringBuilder();
|
|
where.Append("EnumTypeID='8000'");
|
|
if (!String.IsNullOrEmpty(query))
|
|
where.Append(string.Format("EnumValueName LIKE '%{0}%' OR EnumValueID LIKE '%{0}%' ", query));
|
|
var list = ibll.GetModelList(pageIndex, pageSize, where.ToString(), "EnumValueName collate Chinese_PRC_CS_AS_KS_WS");
|
|
var total = ibll.GetRecordCount(where.ToString());
|
|
var result = from p in list
|
|
select new
|
|
{
|
|
id = p.EnumValueName,
|
|
text = p.EnumValueName
|
|
};
|
|
return Json(new { data = result, total }, JsonRequestBehavior.AllowGet);
|
|
}
|
|
#endregion
|
|
}
|
|
} |