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.TruckMng.Models.CityDistance; 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.TruckMng.Controllers { /// /// 项目信息明细 /// public class CityDistanceController : 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 GetDataList(string strCondition, string sort) { var strSql = new StringBuilder(); strSql.Append(" select *,case IN_PROVINCE when 0 then '省外' else '省内' end IN_PROVINCE_REF from City_Distance "); 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 CityDistancemb(); #region Set DB data to Object data.id = Convert.ToString(reader["id"]); data.NAME = Convert.ToString(reader["NAME"]); data.DISTANCE = Convert.ToString(reader["DISTANCE"]); data.PAY_DISTANCE = Convert.ToString(reader["PAY_DISTANCE"]); data.IN_PROVINCE = Convert.ToString(reader["IN_PROVINCE"]); data.IN_PROVINCE_REF = Convert.ToString(reader["IN_PROVINCE_REF"]); data.WEIGHTPRICE = Convert.ToString(reader["WEIGHTPRICE"]); data.DISTANCEPRICE = Convert.ToString(reader["DISTANCEPRICE"]); data.AREANAME = Convert.ToString(reader["AREANAME"]); data.PROVINCENAME = Convert.ToString(reader["PROVINCENAME"]); #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) }; } } }