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.
125 lines
4.7 KiB
C#
125 lines
4.7 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.ClientCompany;
|
|
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 ClientCompanyController : 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<ClientCompanymb> GetDataList(string strCondition, string sort)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append(" select * from (select icc.customergid,ic.shortname customername,icc.companyid,c.name companyname ");
|
|
strSql.Append(" ,icc.relationshipname ,icc.fieldname,icc.value,icc.value1,icc.value2,icc.numvalue,icc.inserted,ic.CODENAME ");
|
|
strSql.Append(" from info_client_company icc ");
|
|
strSql.Append(" left join info_client ic on ic.gid=icc.customerGID ");
|
|
strSql.Append(" left join [company] c on c.gid=icc.companyid ");
|
|
strSql.Append(" union ALL ");
|
|
strSql.Append(" select gid,shortname,'','','财务代码','CWDM','','','',0,null,codename from info_client)tt ");
|
|
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<ClientCompanymb> SetData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<ClientCompanymb>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
var data = new ClientCompanymb();
|
|
#region Set DB data to Object
|
|
data.CustomerGID = Convert.ToString(reader["CustomerGID"]);
|
|
data.CompanyID = Convert.ToString(reader["CompanyID"]);
|
|
data.RelationShipName = Convert.ToString(reader["RelationShipName"]);
|
|
data.FieldName = Convert.ToString(reader["FieldName"]);
|
|
data.Value = Convert.ToString(reader["Value"]);
|
|
data.Value1 = Convert.ToString(reader["Value1"]);
|
|
data.Value2 = Convert.ToString(reader["Value2"]);
|
|
data.NumValue = Convert.ToString(reader["NumValue"]);
|
|
data.INSERTED = Convert.ToString(reader["INSERTED"]);
|
|
data.CustomerName = Convert.ToString(reader["CustomerName"]);
|
|
data.CompanyName = Convert.ToString(reader["CompanyName"]);
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
|
|
public ContentResult Save(string CCBody, string CCDelBody)
|
|
{
|
|
var CCBodyList = JsonConvert.Deserialize<List<ClientCompanymb>>(CCBody);
|
|
var CCDelBodyList = JsonConvert.Deserialize<List<ClientCompanymb>>(CCDelBody);
|
|
|
|
var modb = new ModelObjectRepository();
|
|
DBResult result = modb.SaveComm(
|
|
ModelObjectConvert<ClientCompanymb>.ToModelObjectList(CCBodyList),
|
|
ModelObjectConvert<ClientCompanymb>.ToModelObjectList(CCDelBodyList)
|
|
);
|
|
|
|
//刷新父窗口上的父节点
|
|
var jsonRespose = new JsonResponse
|
|
{
|
|
Success = result.Success,
|
|
Message = result.Message,
|
|
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
|
|
};
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
|
|
|
|
}
|
|
}
|