public List<StudentUnSetMealList_sus_Info> SearchRecords(StudentUnSetMealList_sus_Info conds) { try { return this.m_StudentUnsetMealListDA.SearchRecords(conds); } catch (Exception ex) { throw ex; } }
private void rsPanel_OnShowReportClick(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; try { StudentUnSetMealList_sus_Info searchInfo = new StudentUnSetMealList_sus_Info(); searchInfo.sus_dQueryDate = dtpQueryDate.Value.Date.ToString("yyyy-MM-dd"); if (rsPanel.RSP_GradeID != Guid.Empty) { searchInfo.GradeID = rsPanel.RSP_GradeID; } if (rsPanel.RSP_ClassID != Guid.Empty) { searchInfo.ClassID = rsPanel.RSP_ClassID; } if (!string.IsNullOrEmpty(rsPanel.RSP_ChaName)) { searchInfo.sus_cStuName = rsPanel.RSP_ChaName; } searchInfo.IsDebt = rbtnDebt.Checked; searchInfo.BreakfastEnabled = cbxBreakfast.Checked; searchInfo.LunchEnabled = cbxLunch.Checked; searchInfo.SupperEnabled = cbxSupper.Checked; List<StudentUnSetMealList_sus_Info> listReportRes = this.m_StudentUnsetMealListBL.SearchRecords(searchInfo); if (listReportRes != null && listReportRes.Count > 0) { ShowReport(listReportRes); } else { base.ShowWarningMessage("未找到符合条件的记录,请设置合适条件后重试。"); } } catch (Exception ex) { this.Cursor = Cursors.Default; ShowErrorMessage("查询报表数据出现异常。" + Environment.NewLine + ex.Message); } this.Cursor = Cursors.Default; }
public List<StudentUnSetMealList_sus_Info> SearchRecords(StudentUnSetMealList_sus_Info conds) { if (conds == null) return null; if (!conds.BreakfastEnabled && !conds.LunchEnabled && !conds.SupperEnabled) return null; List<StudentUnSetMealList_sus_Info> listRes = new List<StudentUnSetMealList_sus_Info>(); try { #region SQL StringBuilder sbSql = new StringBuilder(); sbSql.AppendLine("select sus_cCardNo=ucp_iCardNo,sus_cClassName=csm_cClassName,sus_cStuName=cus_cChaName,sus_dQueryDate='" + conds.sus_dQueryDate + "'"); sbSql.AppendLine(",case when mbh_cTargetType='" + Common.DefineConstantValue.StuMealBookingType.StudentDefault + "' then N'个人默认设置' when mbh_cTargetType='" + Common.DefineConstantValue.StuMealBookingType.StudentCustom + "' then N'个人自定义设置'"); sbSql.AppendLine("when mbh_cTargetType='" + Common.DefineConstantValue.StuMealBookingType.ClassDefault + "' then N'班级默认设置' when mbh_cTargetType='" + Common.DefineConstantValue.StuMealBookingType.ClassCustom + "' then N'班级自定义设置'"); sbSql.AppendLine("when mbh_cTargetType='" + Common.DefineConstantValue.StuMealBookingType.GradeDefault + "' then N'年级默认设置' when mbh_cTargetType='" + Common.DefineConstantValue.StuMealBookingType.GradeCustom + "' then N'年级自定义设置'"); sbSql.AppendLine("when mbh_cTargetType='" + Common.DefineConstantValue.MealType.DebtAuto + "' then N'欠费停餐' else '未知' end as sus_cSettingType"); sbSql.AppendLine(",case when mbh_cMealType='" + Common.DefineConstantValue.MealType.Breakfast + "' then N'早餐' when mbh_cMealType='" + Common.DefineConstantValue.MealType.Lunch + "' then N'午餐'"); sbSql.AppendLine("when mbh_cMealType='" + Common.DefineConstantValue.MealType.Supper + "' then N'晚餐' else '未知' end as sus_cMealTypeDesc"); sbSql.AppendLine("from MealBookingHistory_mbh with(nolock)"); sbSql.AppendLine("join vie_AllStudentCardUserInfos with(nolock) on cus_cRecordID=mbh_cTargetID"); sbSql.AppendLine("where mbh_lIsSet=0"); sbSql.AppendLine("and mbh_dMealDate='" + conds.sus_dQueryDate + "'"); if (!conds.IsDebt) sbSql.AppendLine("and mbh_cTargetType<>'" + Common.DefineConstantValue.MealType.DebtAuto + "'"); sbSql.AppendLine("and mbh_cMealType in ("); List<string> listMeals = new List<string>(); if (conds.BreakfastEnabled) listMeals.Add("" + Common.DefineConstantValue.MealType.Breakfast + ""); if (conds.LunchEnabled) listMeals.Add("" + Common.DefineConstantValue.MealType.Lunch + ""); if (conds.SupperEnabled) listMeals.Add("" + Common.DefineConstantValue.MealType.Supper + ""); if (listMeals.Count > 0) { for (int i = 0; i < listMeals.Count; i++) { sbSql.Append("'" + listMeals[i] + "'"); if (i < listMeals.Count - 1) { sbSql.Append(","); } } sbSql.AppendLine(")"); } sbSql.AppendLine("order by mbh_cMealType,csm_cClassName,cus_cChaName"); #endregion using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext()) { db.CommandTimeout = 600000; IEnumerable<StudentUnSetMealList_sus_Info> query = db.ExecuteQuery<StudentUnSetMealList_sus_Info>(sbSql.ToString(), new object[] { }); if (query != null) { listRes = query.ToList(); } } } catch (Exception ex) { throw ex; } return listRes; }