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.Project; 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.Import.Models.XXH; namespace DSWeb.Areas.OA.Controllers { /// /// 项目信息明细 /// public class ProjectController : 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 ISOVER when 1 then '是' else '否' end ISOVER_DEF from oa_ProjectInfo "); 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 Projectmb(); #region Set DB data to Object data.GID = Convert.ToString(reader["GID"]); data.PROJECTNO = Convert.ToString(reader["PROJECTNO"]); data.BLNO = Convert.ToString(reader["BLNO"]); data.PROTYPE = Convert.ToString(reader["PROTYPE"]); data.BLNOTYPE = Convert.ToString(reader["BLNOTYPE"]); data.ISOVER = Convert.ToString(reader["ISOVER"]); data.ISOVER_DEF = Convert.ToString(reader["ISOVER_DEF"]); data.OVERDATE = Convert.ToString(reader["OVERDATE"]); data.INSERTED = Convert.ToString(reader["INSERTED"]); #endregion headList.Add(data); } reader.Close(); } return headList; } public ContentResult GetBLNO(string condition) { var dataList = GetBLNOList(condition); var list = dataList.Skip(0).Take(500); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } private static List GetBLNOList(string Condition) { var strSql = new StringBuilder(); //strSql.Append(" select distinct MBLNO from op_seai where MBLNO not in (select blno from oa_projectinfo)"); strSql.Append(" select distinct MBLNO from vw_settlement where MBLNO not in (select blno from oa_projectinfo)"); if (!string.IsNullOrEmpty(Condition)) { strSql.Append(" where " + Condition); } return SetBLNO(strSql); } private static List SetBLNO(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 BLNOmb(); #region Set DB data to Object data.BLNO = Convert.ToString(reader["MBLNO"]); #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); /* 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.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) }; } public ContentResult GetData(string PROJECTNO, string BLNO,string FEEID) { HTmb head = null; var strCondition = " BLNO='" + BLNO + "' and GID<>'" + FEEID + "'";//PROJECTNO='"+PROJECTNO+"' or var list = GetData(strCondition); if (list.Count > 0) head = list[0]; if (head == null) { head = new HTmb(); } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } static public List GetData(string strCondition) { //合同信息/商品信息 var strSql = new StringBuilder(); strSql.Append(" select count(*) [Count] from oa_projectinfo "); if (!string.IsNullOrEmpty(strCondition)) { strSql.Append(" where " + strCondition); } return SetProjectData(strSql); } private static List SetProjectData(StringBuilder strSql) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { HTmb data = new HTmb(); #region Set DB data to Object data.Count = Convert.ToString(reader["Count"]); #endregion headList.Add(data); } reader.Close(); } return headList; } } }