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; using DSWeb.SoftMng.Filter; namespace DSWeb.Areas.OA.Controllers { /// /// 项目信息明细 /// public class DeptFundsLimitController : Controller { // // GET: /Import/RptImportFeedetail/ public ActionResult Index() { return View(); } public ActionResult Edit() { return View(); } [SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器 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 }; } [SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器 private static List 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 SetData(StringBuilder strSql) { var headList = new List(); 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>(ProjectBody); var ProjectDelBodyList = JsonConvert.Deserialize>(ProjectDelBody); var modb = new ModelObjectRepository(); DBResult result = modb.SaveComm( ModelObjectConvert.ToModelObjectList(ProjectBodyList), ModelObjectConvert.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) }; } } }