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/TruckMng/Controllers/MsWl_LK_LineController.cs

329 lines
12 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.TruckMng.Models.MsWlPc;
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.Areas.TruckMng.DAL.MsWl_LKPC;
using DSWeb.Areas.CommMng.DAL;
using DSWeb.Areas.RptMng.Comm;
namespace DSWeb.Areas.TruckMng.Controllers
{
/// <summary>
/// 项目信息明细
/// </summary>
public class MsWl_LK_LineController : 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<MsWl_LK_Linemb> GetDataList(string strCondition,string sort)
{
var strSql = new StringBuilder();
strSql.Append(" select GID,NAME,LINETYPE,NoLoadMil,OverLoadMil,Remark,INSERTED,SEQUENCE,AREA from tMsWl_LK_Line ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else {
strSql.Append(" order by SEQUENCE " );
}
return SetData(strSql);
}
private static List<MsWl_LK_Linemb> SetData ( StringBuilder strSql )
{
var headList = new List<MsWl_LK_Linemb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var data = new MsWl_LK_Linemb();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.NAME = Convert.ToString(reader["NAME"]);
data.LINETYPE = Convert.ToString(reader["LINETYPE"]);
data.NoLoadMil = Convert.ToString(reader["NoLoadMil"]);
data.OverLoadMil = Convert.ToString(reader["OverLoadMil"]);
data.Remark = Convert.ToString(reader["Remark"]);
data.INSERTED = Convert.ToString(reader["INSERTED"]);
data.SEQUENCE = Convert.ToString(reader["SEQUENCE"]);
data.AREA = Convert.ToString(reader["AREA"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
public ContentResult SaveLine(string Body, string DelBody)
{
var BodyList = JsonConvert.Deserialize<List<MsWl_LK_Linemb>>(Body);
var DelBodyList = JsonConvert.Deserialize<List<MsWl_LK_Linemb>>(DelBody);
/*
Database db_t = DatabaseFactory.CreateDatabase();
string strCheckRow = " select USERNAME from [user] where gid= '" + UserID + "' ";
object statusObj = SqlHelper.ExecuteScalar(db_t.ConnectionString, CommandType.Text, strCheckRow, null);
var EnName = statusObj.ToString();
* */
var modb = new ModelObjectRepository();
DBResult result = modb.SaveComm(
ModelObjectConvert<MsWl_LK_Linemb>.ToModelObjectList(BodyList),
ModelObjectConvert<MsWl_LK_Linemb>.ToModelObjectList(DelBodyList)
);
//刷新父窗口上的父节点
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#region 节点维护
/*
public ContentResult GetPointList ( int start, int limit, string sort, string condition )
{
var dataList = GetPointList(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<MsWl_LK_Pointmb> GetPointList ( string strCondition, string sort )
{
var strSql = new StringBuilder();
strSql.Append(" select GID,NAME,POINTTYPE,DESCRIPTION,ADDRESS,CONTACTER,TEL,Remark,INSERTED,SEQUENCE ");
strSql.Append(" from tMsWl_LK_Point ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else {
strSql.Append(" order by SEQUENCE " );
}
return SetPointData(strSql);
}*/
public ContentResult GetPointList ( int start, int limit, string sort, string condition )
{
//var condition = " LINE_GID='" + LINE_GID + "' ";
var dataList = MsWl_LKPCDAL.GetPointList(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 };
}
public ContentResult SavePoint ( string Body, string DelBody )
{
var BodyList = JsonConvert.Deserialize<List<MsWl_LK_Pointmb>>(Body);
var DelBodyList = JsonConvert.Deserialize<List<MsWl_LK_Pointmb>>(DelBody);
var modb = new ModelObjectRepository();
DBResult result = modb.SaveComm(
ModelObjectConvert<MsWl_LK_Pointmb>.ToModelObjectList(BodyList),
ModelObjectConvert<MsWl_LK_Pointmb>.ToModelObjectList(DelBodyList)
);
//刷新父窗口上的父节点
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 线路内节点明细
public ContentResult GetLineDetailList ( int start, int limit, string sort, string LINE_GID )
{
var condition = " LINE_GID='" + LINE_GID + "' ";
var dataList = GetLineDetailList(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<MsWl_LK_LineDetailmb> GetLineDetailList ( string strCondition, string sort )
{
var strSql = new StringBuilder();
strSql.Append(" select LD.GID,LD.LINE_GID,LD.POINT_GID,LD.REMARK,LD.INSERTED,LD.SEQUENCE ");
strSql.Append(" ,P.NAME,P.ADDRESS,P.CONTACTER,P.TEL ");
strSql.Append(" from tMsWl_LK_LineDetail LD ");
strSql.Append(" left join tMsWl_LK_Point P on P.gid=LD.POINT_GID ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else {
strSql.Append(" order by SEQUENCE " );
}
return SetLineDetailData(strSql);
}
private static List<MsWl_LK_LineDetailmb> SetLineDetailData ( StringBuilder strSql )
{
var headList = new List<MsWl_LK_LineDetailmb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var data = new MsWl_LK_LineDetailmb();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.LINE_GID = Convert.ToString(reader["LINE_GID"]);
data.POINT_GID = Convert.ToString(reader["POINT_GID"]);
data.REMARK = Convert.ToString(reader["REMARK"]);
data.INSERTED = Convert.ToString(reader["INSERTED"]);
data.SEQUENCE = Convert.ToString(reader["SEQUENCE"]);
data.NAME = Convert.ToString(reader["NAME"]);
data.ADDRESS = Convert.ToString(reader["ADDRESS"]);
data.CONTACTER = Convert.ToString(reader["CONTACTER"]);
data.TEL = Convert.ToString(reader["TEL"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
public ContentResult SaveLineDetail ( string Body, string DelBody )
{
var BodyList = JsonConvert.Deserialize<List<MsWl_LK_LineDetailmb>>(Body);
var DelBodyList = JsonConvert.Deserialize<List<MsWl_LK_LineDetailmb>>(DelBody);
var modb = new ModelObjectRepository();
DBResult result = modb.SaveComm(
ModelObjectConvert<MsWl_LK_LineDetailmb>.ToModelObjectList(BodyList),
ModelObjectConvert<MsWl_LK_LineDetailmb>.ToModelObjectList(DelBodyList)
);
//刷新父窗口上的父节点
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 维护线路内节点明细
public ContentResult AddLineDetail(string LINE_GID, string POINTGIDList)
{
//HTmb head = null;
var _result = MsWl_LKPCDAL.AddLineDetail(LINE_GID, POINTGIDList);
var jsonRespose = new JsonResponse
{
Success = _result.Success,
Message = _result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
//return new ContentResult() { Content = JsonConvert.Serialize("") };
}
public ContentResult DelLineDetail(string LineDetailList)
{
//HTmb head = null;
var _result = MsWl_LKPCDAL.DelLineDetail(LineDetailList);
var jsonRespose = new JsonResponse
{
Success = _result.Success,
Message = _result.Message,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
//return new ContentResult() { Content = JsonConvert.Serialize("") };
}
#endregion
}
}