/// <summary> /// 是否存在该记录 /// </summary> public bool IsExistsByTaskID(long TaskID) { QueryGroupOrderTask query = new QueryGroupOrderTask(); query.TaskID = TaskID; DataTable dt = new DataTable(); int count = 0; dt = GetGroupOrderTask(query, string.Empty, 1, 1, out count); if (count > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Entities.GroupOrderTask GetGroupOrderTask(long TaskID) { QueryGroupOrderTask query = new QueryGroupOrderTask(); query.TaskID = TaskID; DataTable dt = new DataTable(); int count = 0; dt = GetGroupOrderTask(query, string.Empty, 1, 1, out count); if (count > 0) { return(LoadSingleGroupOrderTask(dt.Rows[0])); } else { return(null); } }
private void BindData() { try { if (!int.TryParse(RequestPageSize, out PageSize)) { PageSize = 20; } QueryGroupOrderTask query = BLL.Util.BindQuery <QueryGroupOrderTask>(this.Context); int _userID = BLL.Util.GetLoginUserID(); query.LoginID = _userID; DataTable dt = BLL.GroupOrderTask.Instance.GetGroupOrderTask(query, "gorder.OrderCreateTime desc", PageCommon.Instance.PageIndex, PageSize, out RecordCount); repeaterTableList.DataSource = dt; repeaterTableList.DataBind(); litPagerDown.Text = PageCommon.Instance.LinkStringByPost(BLL.Util.GetUrl(), GroupLength, RecordCount, PageSize, PageCommon.Instance.PageIndex, 2); } catch (Exception ex) { } }
/// <summary> /// 按照查询条件查询 /// </summary> /// <param name="query">查询条件</param> /// <param name="order">排序</param> /// <param name="currentPage">页号,-1不分页</param> /// <param name="pageSize">每页记录数</param> /// <param name="totalCount">总行数</param> /// <returns>集合</returns> public DataTable GetGroupOrderTask(QueryGroupOrderTask query, string order, int currentPage, int pageSize, out int totalCount) { string where = string.Empty; #region 数据权限判断 if (query.LoginID != Constant.INT_INVALID_VALUE) { string whereDataRight = ""; whereDataRight = Dal.UserGroupDataRigth.Instance.GetSqlRightstr("gtask", "BGID", "AssignUserID", query.LoginID); where += whereDataRight; } #endregion #region 条件 if (query.CustomerTel != Constant.STRING_INVALID_VALUE) { where += " AND gorder.CustomerTel='" + StringHelper.SqlFilter(query.CustomerTel.ToString()) + "'"; } if (query.CustName != Constant.STRING_INVALID_VALUE) { where += " AND gorder.CustomerName like '%" + StringHelper.SqlFilter(query.CustName.ToString()) + "%'"; } if (query.OrderCode != Constant.STRING_INVALID_VALUE) { where += " AND gorder.OrderCode='" + StringHelper.SqlFilter(query.OrderCode) + "'"; } if (query.OrderID != Constant.INT_INVALID_VALUE) { where += " AND gtask.OrderID=" + query.OrderID.ToString(); } if (query.TaskID != Constant.INT_INVALID_VALUE) { where += " AND gtask.TaskID=" + query.TaskID.ToString(); } if (query.ProvinceID != Constant.INT_INVALID_VALUE && query.ProvinceID != -1) { where += " AND gorder.ProvinceID=" + query.ProvinceID.ToString(); } if (query.CityID != Constant.INT_INVALID_VALUE && query.CityID != -1) { where += " AND gorder.CityID=" + query.CityID.ToString(); } if (query.AssignUserID != Constant.INT_INVALID_VALUE) { where += " AND gtask.AssignUserID=" + query.AssignUserID.ToString(); } if (query.Dealer != Constant.STRING_INVALID_VALUE) { where += " AND gorder.DealerName like '%" + StringHelper.SqlFilter(query.Dealer.ToString()) + "%'"; } if (query.TaskStatus != Constant.INT_INVALID_VALUE) { where += " AND gtask.TaskStatus=" + query.TaskStatus.ToString(); } if (query.IsReturnVisit != Constant.INT_INVALID_VALUE) { where += " AND gorder.IsReturnVisit=" + query.IsReturnVisit.ToString(); } //团购订单下单时间 if (query.CreatetimeBegin != Constant.DATE_INVALID_VALUE && query.CreatetimeEnd != Constant.DATE_INVALID_VALUE) { where += " and gorder.OrderCreateTime >= '" + query.CreatetimeBegin + "' and gorder.OrderCreateTime <= '" + query.CreatetimeEnd + "'"; } if (query.SubmitTimeBegin != Constant.DATE_INVALID_VALUE && query.SubmitTimeEnd != Constant.DATE_INVALID_VALUE) { //where += " and gtask.SubmitTime >= '" + query.SubmitTimeBegin + "' and gtask.SubmitTime <= '" + query.SubmitTimeEnd + "'"; where += " and gtask.SubmitTime >= '" + Convert.ToDateTime(query.SubmitTimeBegin).ToShortDateString() + " 0:00:000' and gtask.SubmitTime <= '" + Convert.ToDateTime(query.SubmitTimeEnd).ToShortDateString() + " 23:59:59'"; } if (query.CarMasterID != Constant.INT_INVALID_VALUE && query.CarMasterID != 0) { where += " and gorder.CarMasterID=" + query.CarMasterID; } if (query.CarSerialID != Constant.INT_INVALID_VALUE && query.CarSerialID != 0) { where += " and gorder.CarSerialID=" + query.CarSerialID; } if (query.CarID != Constant.INT_INVALID_VALUE && query.CarID != 0) { where += " and gorder.CarID=" + query.CarID; } if (query.FailReason != Constant.INT_INVALID_VALUE) { where += " and gorder.FailReasonID=" + query.FailReason; } if (query.TelCount != Constant.STRING_INVALID_VALUE && query.TelCount != "-1") //添加"用户下单数"查询条件 Add=masj,Date=2013-11-13 { if (query.TelCount.ToLower().Trim() == "1") //1次 { where += @" and gorder.OrderID IN ( SELECT OrderID FROM ( SELECT gorder.CustomerTel,MIN(gorder.OrderID) AS OrderID,COUNT(*) AS OrderCount FROM dbo.GroupOrderTask(NOLOCK) gtask LEFT JOIN dbo.GroupOrder(NOLOCK) gorder ON gtask.OrderID = gorder.OrderID WHERE 1=1 " + where + @" GROUP BY gorder.CustomerTel HAVING COUNT(*)=1 ) AS b )"; } else if (query.TelCount.ToLower().Trim() == "n") { where += @" and gorder.OrderID IN (SELECT DISTINCT gorder.OrderID FROM dbo.GroupOrderTask(NOLOCK) gtask LEFT JOIN dbo.GroupOrder(NOLOCK) gorder ON gtask.OrderID = gorder.OrderID WHERE 1=1 " + where + ")" + @" and gorder.OrderID Not IN ( SELECT OrderID FROM ( SELECT gorder.CustomerTel,MIN(gorder.OrderID) AS OrderID,COUNT(*) AS OrderCount FROM dbo.GroupOrderTask(NOLOCK) gtask LEFT JOIN dbo.GroupOrder(NOLOCK) gorder ON gtask.OrderID = gorder.OrderID WHERE 1=1 " + where + @" GROUP BY gorder.CustomerTel HAVING COUNT(*)=1 ) AS b )"; } //where += " and gorder.FailReasonID=" + query.FailReason; } #endregion DataSet ds; SqlParameter[] parameters = { new SqlParameter("@where", SqlDbType.NVarChar, 40000), new SqlParameter("@order", SqlDbType.NVarChar, 200), new SqlParameter("@pagesize", SqlDbType.Int, 4), new SqlParameter("@indexpage", SqlDbType.Int, 4), new SqlParameter("@totalRecorder", SqlDbType.Int, 4) }; parameters[0].Value = where; parameters[1].Value = order; parameters[2].Value = pageSize; parameters[3].Value = currentPage; parameters[4].Direction = ParameterDirection.Output; ds = SqlHelper.ExecuteDataset(CONNECTIONSTRINGS, CommandType.StoredProcedure, P_GROUPORDERTASK_SELECT, parameters); totalCount = (int)(parameters[4].Value); return(ds.Tables[0]); }
/// <summary> /// 按照查询条件查询 /// </summary> /// <param name="query">查询条件</param> /// <param name="order">排序</param> /// <param name="currentPage">页号,-1不分页</param> /// <param name="pageSize">每页记录数</param> /// <param name="totalCount">总行数</param> /// <returns>集合</returns> public DataTable GetGroupOrderTask(QueryGroupOrderTask query, string order, int currentPage, int pageSize, out int totalCount) { return(Dal.GroupOrderTask.Instance.GetGroupOrderTask(query, order, currentPage, pageSize, out totalCount)); }