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.CustomerBalance; 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 { /// /// 项目信息明细 /// public class CustomerBalanceController : 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 * from (select * from [VW_CustomerBalance] "); strSql.Append(" union ALL "); strSql.Append(" select newid(),ic.gid,0,0,0,0,0,ic.SHORTNAME,'','','','',ic.CODENAME,0,0,0,0,0,null from info_client ic)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 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 CustomerBalancemb(); #region Set DB data to Object data.GID = Convert.ToString(reader["GID"]); data.CustomerGID = Convert.ToString(reader["CustomerGID"]); data.CustomerName = Convert.ToString(reader["CustomerName"]); data.StartTime = Convert.ToString(reader["StartTime"]); data.DeptGID = Convert.ToString(reader["DeptGID"]); data.DeptName = Convert.ToString(reader["DeptName"]); data.CodeName = Convert.ToString(reader["CodeName"]); data.Balance_1 = Convert.ToString(reader["Balance_1"]);//已开票未收余额 data.Balance_2 = Convert.ToString(reader["Balance_2"]);//未开票未收余额 data.Balance_3 = Convert.ToString(reader["Balance_3"]);//已开票未付余额 data.Balance_4 = Convert.ToString(reader["Balance_4"]);//未开票未付余额 data.Balance_5 = Convert.ToString(reader["Balance_5"]);//未开票已收余额 data.C_Balance_2 = Convert.ToString(//未开票未收余额 Convert.ToDouble(reader["Balance_2"]) + Convert.ToDouble(reader["wkp"]) - Convert.ToDouble(reader["wkys"]));// // - Convert.ToDouble(reader["ykws"]) - Convert.ToDouble(reader["wkys"]) - Convert.ToDouble(reader["ykys"]));// data.C_Balance_1 = Convert.ToString(Convert.ToDouble(reader["Balance_1"]) + Convert.ToDouble(reader["ykws"])) ;// data.C_Balance_5 = Convert.ToString(Convert.ToDouble(reader["Balance_5"]) + Convert.ToDouble(reader["wkys"])) ;// data.C_Balance_4 = Convert.ToString(Convert.ToDouble(reader["Balance_4"]) + Convert.ToDouble(reader["ykwf"]));// data.C_Balance_3 = Convert.ToString(Convert.ToDouble(reader["Balance_3"]) + Convert.ToDouble(reader["ykwf"]));// data.INSERTED = Convert.ToString(reader["INSERTED"]); //data.CodeName = Convert.ToString(reader["CodeName"]); #endregion headList.Add(data); } reader.Close(); } return headList; } public ContentResult Save(string CBBody, string CBDelBody) { var CBBodyList = JsonConvert.Deserialize>(CBBody); var CBDelBodyList = JsonConvert.Deserialize>(CBDelBody); var modb = new ModelObjectRepository(); DBResult result = modb.SaveComm( ModelObjectConvert.ToModelObjectList(CBBodyList), ModelObjectConvert.ToModelObjectList(CBDelBodyList) ); //刷新父窗口上的父节点 var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } }