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.
DS7/DSWeb/Areas/OA/Controllers/DeptFundsLimitController.cs

116 lines
4.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using DSWeb.Areas.OA.Models.DeptFundsLimit;
using DSWeb.Areas.CommMng.Models;
using DSWeb.TruckMng.Helper;
using DSWeb.TruckMng.Helper.Repository;
using Microsoft.Practices.EnterpriseLibrary.Data;
using HcUtility.Comm;
using HcUtility.Core;
namespace DSWeb.Areas.OA.Controllers
{
/// <summary>
/// 项目信息明细
/// </summary>
public class DeptFundsLimitController : Controller
{
//
// GET: /Import/RptImportFeedetail/
public ActionResult Index()
{
return View();
}
public ActionResult Edit()
{
return View();
}
public ContentResult GetDataList(int start, int limit, string sort, string condition)
{
var dataList = GetDataList(condition,sort);
var list = dataList.Skip(start).Take(limit);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
private static List<DeptFundsLimitmb> GetDataList(string strCondition, string sort)
{
var strSql = new StringBuilder();
strSql.Append(" select * from VW_DeptFundsLimit ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
return SetData(strSql);
}
private static List<DeptFundsLimitmb> SetData(StringBuilder strSql)
{
var headList = new List<DeptFundsLimitmb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var data = new DeptFundsLimitmb();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.DEPTID = Convert.ToString(reader["DEPTID"]);
data.DEPTNAME = Convert.ToString(reader["DEPTNAME"]);
data.COMPANYID = Convert.ToString(reader["COMPANYID"]);
data.Limit_1 = Convert.ToString(reader["Limit_1"]);
data.Limit_2 = Convert.ToString(reader["Limit_2"]);
data.Limit_3 = Convert.ToString(reader["Limit_3"]);
data.INSERTED = Convert.ToString(reader["INSERTED"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
public ContentResult Save(string ProjectBody, string ProjectDelBody)
{
var ProjectBodyList = JsonConvert.Deserialize<List<DeptFundsLimitmb>>(ProjectBody);
var ProjectDelBodyList = JsonConvert.Deserialize<List<DeptFundsLimitmb>>(ProjectDelBody);
var modb = new ModelObjectRepository();
DBResult result = modb.SaveComm(
ModelObjectConvert<DeptFundsLimitmb>.ToModelObjectList(ProjectBodyList),
ModelObjectConvert<DeptFundsLimitmb>.ToModelObjectList(ProjectDelBodyList)
);
//刷新父窗口上的父节点
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
}