/// <summary> /// 获取订单信息集合 /// </summary> /// <param name="pageSize">页记录数</param> /// <param name="pageIndex">页序号</param> /// <param name="recordCount">总记录数</param> /// <param name="chaXun">查询</param> /// <param name="heJi">合计信息[0:decimal:采购金额][1:decimal:已付款金额]</param> /// <returns></returns> public IList <EyouSoft.Model.MDingDanInfo> GetDingDans(int pageSize, int pageIndex, ref int recordCount, EyouSoft.Model.MDingDanChaXunInfo chaXun, out object[] heJi) { heJi = new object[] { 0M, 0M }; IList <EyouSoft.Model.MDingDanInfo> items = new List <EyouSoft.Model.MDingDanInfo>(); string fields = "*"; StringBuilder sql = new StringBuilder(); string tableName = "view_DingDan"; string orderByString = " IssueTime DESC "; string heJiString = "SUM(JinE) AS JinEHeJi,SUM(CgsYiFuKuanJinE) AS CgsYiFuKuanJinEHeJi"; #region sql sql.Append(" IsDelete='0' "); sql.AppendFormat(" AND Status<>{0} ", (int)EyouSoft.Model.DingDanStatus.计划采购); if (chaXun != null) { if (!string.IsNullOrEmpty(chaXun.CaiGouDanHao)) { sql.AppendFormat(" AND CaiGouDanHao LIKE '%{0}%' ", chaXun.CaiGouDanHao); } if (chaXun.CaiGouTime1.HasValue) { sql.AppendFormat(" AND IssueTime>'{0}' ", chaXun.CaiGouTime1.Value.AddMinutes(-1)); } if (chaXun.CaiGouTime2.HasValue) { sql.AppendFormat(" AND IssueTime<'{0}' ", chaXun.CaiGouTime2.Value.AddDays(1).AddMinutes(-1)); } if (!string.IsNullOrEmpty(chaXun.CgsId)) { sql.AppendFormat(" AND CgsId='{0}' ", chaXun.CgsId); } if (chaXun.DingDanStatus.HasValue) { sql.AppendFormat(" AND Status={0} ", (int)chaXun.DingDanStatus); } if (chaXun.DingDanStatusIn != null && chaXun.DingDanStatusIn.Count() > 0) { sql.AppendFormat(" AND Status IN ({0}) ", Utils.GetSqlIdStrByArray(chaXun.DingDanStatusIn)); } if (!string.IsNullOrEmpty(chaXun.GysId)) { sql.AppendFormat(" AND GysId='{0}' ", chaXun.GysId); } if (!string.IsNullOrEmpty(chaXun.GysName)) { sql.AppendFormat(" AND GysName LIKE '%{0}%' ", chaXun.GysName); } if (chaXun.CgsFuKuanStatus.HasValue) { sql.AppendFormat(" AND CgsFuKuanStatus={0} ", (int)chaXun.CgsFuKuanStatus); } if (chaXun.CgsFuKuanTime1.HasValue) { sql.AppendFormat(" AND CgsFuKuanTime>'{0}' ", chaXun.CgsFuKuanTime1.Value.AddMinutes(-1)); } if (chaXun.CgsFuKuanTime2.HasValue) { sql.AppendFormat(" AND CgsFuKuanTime<'{0}' ", chaXun.CgsFuKuanTime1.Value.AddDays(1).AddMinutes(-1)); } if (chaXun.QueRenStatus.HasValue) { sql.AppendFormat(" AND GysDaoHuoQueRenStatus={0} ", (int)chaXun.QueRenStatus); } if (!string.IsNullOrEmpty(chaXun.CaiGouDanId)) { sql.AppendFormat(" AND CaiGouDanId='{0}' ", chaXun.CaiGouDanId); } if (!string.IsNullOrEmpty(chaXun.CgsName)) { sql.AppendFormat(" AND CgsName LIKE '%{0}%' ", chaXun.CgsName); } } #endregion using (IDataReader rdr = DbHelper.ExecuteReader1(_db, pageSize, pageIndex, ref recordCount, tableName, fields, sql.ToString(), orderByString, heJiString)) { while (rdr.Read()) { var info = new EyouSoft.Model.MDingDanInfo(); info.CaiGouDanId = rdr["CaiGouDanId"].ToString(); info.CgsQueRenRenId = rdr["CgsQueRenRenId"].ToString(); if (!rdr.IsDBNull(rdr.GetOrdinal("CgsQueRenTime"))) { info.CgsQueRenTime = rdr.GetDateTime(rdr.GetOrdinal("CgsQueRenTime")); } info.CgsShouHuoRenId = rdr["CgsShouHuoRenId"].ToString(); if (!rdr.IsDBNull(rdr.GetOrdinal("CgsShouHuoTime"))) { info.CgsShouHuoTime = rdr.GetDateTime(rdr.GetOrdinal("CgsShouHuoTime")); } info.ChanPins = null; if (!rdr.IsDBNull(rdr.GetOrdinal("DaoHuoTime"))) { info.DaoHuoTime = rdr.GetDateTime(rdr.GetOrdinal("DaoHuoTime")); } info.DingDanId = rdr["DingDanId"].ToString(); info.GysBaoJiaRenId = rdr["GysBaoJiaRenId"].ToString(); if (!rdr.IsDBNull(rdr.GetOrdinal("GysBaoJiaTime"))) { info.GysBaoJiaTime = rdr.GetDateTime(rdr.GetOrdinal("GysBaoJiaTime")); } info.GysDaoHuoQueRenRenId = rdr["GysDaoHuoQueRenRenId"].ToString(); if (!rdr.IsDBNull(rdr.GetOrdinal("GysDaoHuoQueRenTime"))) { info.GysDaoHuoQueRenTime = rdr.GetDateTime(rdr.GetOrdinal("GysDaoHuoQueRenTime")); } info.GysFaHuoRenId = rdr["GysFaHuoRenId"].ToString(); if (!rdr.IsDBNull(rdr.GetOrdinal("GysFaHuoTime"))) { info.GysFaHuoTime = rdr.GetDateTime(rdr.GetOrdinal("GysFaHuoTime")); } info.GysId = rdr["GysId"].ToString(); info.GysName = rdr["GysName"].ToString(); info.JinE = rdr.GetDecimal(rdr.GetOrdinal("JinE")); info.SongHuoRenDianHua = rdr["SongHuoRenDianHua"].ToString(); info.SongHuoRenName = rdr["SongHuoRenName"].ToString(); if (!rdr.IsDBNull(rdr.GetOrdinal("SongHuoTime"))) { info.SongHuoTime = rdr.GetDateTime(rdr.GetOrdinal("SongHuoTime")); } info.Status = (EyouSoft.Model.DingDanStatus)rdr.GetInt32(rdr.GetOrdinal("Status")); if (!rdr.IsDBNull(rdr.GetOrdinal("FaBuTime"))) { info.FaBuTime = rdr.GetDateTime(rdr.GetOrdinal("FaBuTime")); } info.XiaDanTime = rdr.GetDateTime(rdr.GetOrdinal("IssueTime")); info.GysFaHuoShuoMing = rdr["GysFaHuoShuoMing"].ToString(); info.CgsName = rdr["CgsName"].ToString(); info.CaiGouDanHao = rdr["CaiGOuDanHao"].ToString(); info.CaiGouDanName = rdr["CaiGouDanName"].ToString(); info.CaiGouBuMen = rdr["CaiGouBuMen"].ToString(); info.FaBuRenName = rdr["FaBuRenName"].ToString(); info.IssueTime = rdr.GetDateTime(rdr.GetOrdinal("IssueTime")); info.YaoQiuDaoHuoTime = Utils.GetDateTimeNullable(rdr["YaoQiuDaoHuoTime"].ToString()); info.CgsShouHuoRen = rdr["CgsShouHuoRen"].ToString(); info.GysDaoHuoQueRenStatus = (EyouSoft.Model.QueRenStatus)rdr.GetInt32(rdr.GetOrdinal("GysDaoHuoQueRenStatus")); if (!rdr.IsDBNull(rdr.GetOrdinal("YuJiDaoHuoTime"))) { info.YuJiDaoHuoTime = rdr.GetDateTime(rdr.GetOrdinal("YuJiDaoHuoTime")); } info.CaoZuoRenName = rdr["CaoZuoRenName"].ToString(); info.CaiGouChanPinXiangShu = rdr.GetInt32(rdr.GetOrdinal("CaiGouChanPinXiangShu")); info.CgsFuKuanStatus = (FuKuanStatus)rdr.GetInt32(rdr.GetOrdinal("CgsFuKuanStatus")); if (!rdr.IsDBNull(rdr.GetOrdinal("CgsFuKuanTime"))) { info.CgsFuKuanTime = rdr.GetDateTime(rdr.GetOrdinal("CgsFuKuanTime")); } info.CgsFuKuanCaoZuoRenId = rdr["CgsFuKuanCaoZuoRenId"].ToString(); info.CgsFuKuanCaoZuoRenName = rdr["CgsFuKuanCaoZuoRenName"].ToString(); info.CgsYiFuKuanJinE = rdr.GetDecimal(rdr.GetOrdinal("CgsYiFuKuanJinE")); info.CgsId = rdr["CgsId"].ToString(); info.CaoZuoRenId = rdr["CaoZuoRenId"].ToString(); info.GysLxQQ = rdr["GysLxQQ"].ToString(); info.CgsLxQQ = rdr["CgsLxQQ"].ToString(); items.Add(info); } rdr.NextResult(); if (rdr.Read()) { if (!rdr.IsDBNull(rdr.GetOrdinal("JinEHeJi"))) { heJi[0] = rdr.GetDecimal(rdr.GetOrdinal("JinEHeJi")); } if (!rdr.IsDBNull(rdr.GetOrdinal("CgsYiFuKuanJinEHeJi"))) { heJi[1] = rdr.GetDecimal(rdr.GetOrdinal("CgsYiFuKuanJinEHeJi")); } } } return(items); }
/// <summary> /// 获取订单信息业务实体 /// </summary> /// <param name="dingDanId">订单编号</param> /// <returns></returns> public EyouSoft.Model.MDingDanInfo GetInfo(string dingDanId) { EyouSoft.Model.MDingDanInfo info = null; var cmd = _db.GetSqlStringCommand("SELECT * FROM view_DingDan WHERE DingDanId=@DingDanId"); _db.AddInParameter(cmd, "DingDanId", DbType.AnsiStringFixedLength, dingDanId); using (var rdr = DbHelper.ExecuteReader(cmd, _db)) { if (rdr.Read()) { info = new EyouSoft.Model.MDingDanInfo(); info.CaiGouDanId = rdr["CaiGouDanId"].ToString(); info.CgsQueRenRenId = rdr["CgsQueRenRenId"].ToString(); if (!rdr.IsDBNull(rdr.GetOrdinal("CgsQueRenTime"))) { info.CgsQueRenTime = rdr.GetDateTime(rdr.GetOrdinal("CgsQueRenTime")); } info.CgsShouHuoRenId = rdr["CgsShouHuoRenId"].ToString(); if (!rdr.IsDBNull(rdr.GetOrdinal("CgsShouHuoTime"))) { info.CgsShouHuoTime = rdr.GetDateTime(rdr.GetOrdinal("CgsShouHuoTime")); } info.ChanPins = null; if (!rdr.IsDBNull(rdr.GetOrdinal("DaoHuoTime"))) { info.DaoHuoTime = rdr.GetDateTime(rdr.GetOrdinal("DaoHuoTime")); } info.DingDanId = dingDanId; info.GysBaoJiaRenId = rdr["GysBaoJiaRenId"].ToString(); if (!rdr.IsDBNull(rdr.GetOrdinal("GysBaoJiaTime"))) { info.GysBaoJiaTime = rdr.GetDateTime(rdr.GetOrdinal("GysBaoJiaTime")); } info.GysDaoHuoQueRenRenId = rdr["GysDaoHuoQueRenRenId"].ToString(); if (!rdr.IsDBNull(rdr.GetOrdinal("GysDaoHuoQueRenTime"))) { info.GysDaoHuoQueRenTime = rdr.GetDateTime(rdr.GetOrdinal("GysDaoHuoQueRenTime")); } info.GysFaHuoRenId = rdr["GysFaHuoRenId"].ToString(); if (!rdr.IsDBNull(rdr.GetOrdinal("GysFaHuoTime"))) { info.GysFaHuoTime = rdr.GetDateTime(rdr.GetOrdinal("GysFaHuoTime")); } info.GysId = rdr["GysId"].ToString(); info.GysName = rdr["GysName"].ToString(); info.JinE = rdr.GetDecimal(rdr.GetOrdinal("JinE")); info.SongHuoRenDianHua = rdr["SongHuoRenDianHua"].ToString(); info.SongHuoRenName = rdr["SongHuoRenName"].ToString(); if (!rdr.IsDBNull(rdr.GetOrdinal("SongHuoTime"))) { info.SongHuoTime = rdr.GetDateTime(rdr.GetOrdinal("SongHuoTime")); } info.Status = (EyouSoft.Model.DingDanStatus)rdr.GetInt32(rdr.GetOrdinal("Status")); if (!rdr.IsDBNull(rdr.GetOrdinal("FaBuTime"))) { info.FaBuTime = rdr.GetDateTime(rdr.GetOrdinal("FaBuTime")); } info.XiaDanTime = rdr.GetDateTime(rdr.GetOrdinal("IssueTime")); info.GysFaHuoShuoMing = rdr["GysFaHuoShuoMing"].ToString(); info.CgsName = rdr["CgsName"].ToString(); info.CaiGouDanHao = rdr["CaiGouDanHao"].ToString(); info.CaiGouDanName = rdr["CaiGouDanName"].ToString(); info.MoBanId = rdr["MoBanId"].ToString(); info.CaiGouBuMen = rdr["CaiGouBuMen"].ToString(); if (!rdr.IsDBNull(rdr.GetOrdinal("YuJiDaoHuoTime"))) { info.YuJiDaoHuoTime = rdr.GetDateTime(rdr.GetOrdinal("YuJiDaoHuoTime")); } info.GysDaoHuoQueRenStatus = (QueRenStatus)rdr.GetInt32(rdr.GetOrdinal("GysDaoHuoQueRenStatus")); info.CgsShouHuoRen = rdr["CgsShouHuoRen"].ToString(); info.CgsFuKuanStatus = (FuKuanStatus)rdr.GetInt32(rdr.GetOrdinal("CgsFuKuanStatus")); if (!rdr.IsDBNull(rdr.GetOrdinal("CgsFuKuanTime"))) { info.CgsFuKuanTime = rdr.GetDateTime(rdr.GetOrdinal("CgsFuKuanTime")); } info.CgsFuKuanCaoZuoRenId = rdr["CgsFuKuanCaoZuoRenId"].ToString(); info.CgsFuKuanCaoZuoRenName = rdr["CgsFuKuanCaoZuoRenName"].ToString(); info.CgsYiFuKuanJinE = rdr.GetDecimal(rdr.GetOrdinal("CgsYiFuKuanJinE")); info.CgsId = rdr["CgsId"].ToString(); info.GysSongHuoRenId = rdr["GysSongHuoRenId"].ToString(); } } if (info != null) { info.ChanPins = GetDingDanChanPins(dingDanId); } return(info); }