public DataSet GetFoodArrangement() { using ( FoodManagementDataAccess foodManagementDataAccess = new FoodManagementDataAccess() ) { try { return foodManagementDataAccess.GetFoodArrangement(); } catch(Exception e) { Util.WriteLog(e.Message,Util.EXCEPTION_LOG_TITLE); return null; } } }
//食物营养修改 public int doUpdateNutrition() { using ( FoodManagementDataAccess foodManagementDataAccess = new FoodManagementDataAccess() ) { try { return foodManagementDataAccess.UpdateNutrition(foodMgmt); } catch(Exception e) { Util.WriteLog(e.Message,Util.EXCEPTION_LOG_TITLE); return -1; } } }
public DataSet GetAccFood(string getFoodCateName,string getFoodName,string getBegDate,string getEndDate) { using ( FoodManagementDataAccess foodManagementDataAccess = new FoodManagementDataAccess() ) { try { return foodManagementDataAccess.DoGetAccFood(getFoodCateName,getFoodName,getBegDate,getEndDate); } catch(Exception e) { Util.WriteLog(e.Message,Util.EXCEPTION_LOG_TITLE); return null; } } }
//每日食谱保存 public int doInsertAccFood(string getFoodID,string getTakeAmount,string getDate,string getRemark) { using ( FoodManagementDataAccess foodManagementDataAccess = new FoodManagementDataAccess() ) { try { double takeAmount = Convert.ToDouble(getTakeAmount); return foodManagementDataAccess.InsertAccFood(getFoodID,takeAmount,getDate,getRemark); } catch(Exception e) { Util.WriteLog(e.Message,Util.EXCEPTION_LOG_TITLE); return -1; } } }
public int DeleteAccFood(string getFoodID,string getDate) { using ( FoodManagementDataAccess foodManagementDataAccess = new FoodManagementDataAccess() ) { try { return foodManagementDataAccess.DeleteAccFood(getFoodID,getDate); } catch(Exception e) { Util.WriteLog(e.Message,Util.EXCEPTION_LOG_TITLE); return -1; } } }
public int doDeleteFoodArrMeal() { using ( FoodManagementDataAccess foodManagementDataAccess = new FoodManagementDataAccess() ) { try { return foodManagementDataAccess.DeleteFoodArrMeal(foodMgmt); } catch(Exception e) { Util.WriteLog(e.Message,Util.EXCEPTION_LOG_TITLE); return -1; } } }
public DataSet doGetFoodArrGrade(bool selStyle) { using ( FoodManagementDataAccess foodManagementDataAccess = new FoodManagementDataAccess() ) { try { return foodManagementDataAccess.GetFoodArrGrade(foodMgmt,selStyle); } catch(Exception e) { Util.WriteLog(e.Message,Util.EXCEPTION_LOG_TITLE); return null; } } }
private void getDairy() //计算乳类总数 { DataSet dsGetDairy = new FoodManagementDataAccess().GetDairy(BegDate.Date.ToString("yyyy-MM-dd"),EndDate.Date.ToString("yyyy-MM-dd"), Convert.ToInt32(BegDate.Date.ToString("MM"))); if ( dsGetDairy.Tables[0].Rows[0][0] is DBNull ) { m_objRange = m_objSheet.get_Range(m_objSheet.Cells[140,2],m_objSheet.Cells[140,2]); m_objRange.set_Item(1,1,0); } else { m_objRange = m_objSheet.get_Range(m_objSheet.Cells[140,2],m_objSheet.Cells[140,2]); m_objRange.set_Item(1,1,Convert.ToDouble(dsGetDairy.Tables[0].Rows[0][0])); } }
private void writeElement() //成份 { m_objSheet = (Excel._Worksheet)(m_objSheets.get_Item(7)); for ( int cateID=1; cateID<=9; cateID++ ) { DataSet dsFoodNutPar = new FoodManagementDataAccess().GetFoodNut(BegDate.Date.ToString("yyyy-MM-dd"),EndDate.Date.ToString("yyyy-MM-dd"), Convert.ToInt32(BegDate.Date.ToString("MM")),cateID); if ( dsFoodNutPar.Tables[0].Rows.Count > 0 ) { switch(cateID) { case 1: setElementRow = 6; //肉禽 hasElRowChanged = false; foreach(DataRow row in dsFoodNutPar.Tables[0].Rows) { if ( setElementRow > 83 ) break; if( setElementRow > 67 && !hasElRowChanged ) { hasElRowChanged = true; setElementRow = 77; } setElement(Convert.ToDouble(row[1]),Convert.ToDouble(row[2]),Convert.ToDouble(row[3]),setElementRow,4); setElement(Convert.ToDouble(row[1]),Convert.ToDouble(row[2]),Convert.ToDouble(row[3]),setElementRow,6); setElement(Convert.ToDouble(row[1]),Convert.ToDouble(row[2]),Convert.ToDouble(row[3]),setElementRow,8); setElementRow ++; } break; case 2: setElementRow = 199; //水果 hasElRowChanged = false; foreach(DataRow row in dsFoodNutPar.Tables[0].Rows) { if ( setElementRow > 231 ) break; if ( setElementRow > 208 && !hasElRowChanged ) { hasElRowChanged = true; setElementRow = 217; } setElement(Convert.ToDouble(row[1]),Convert.ToDouble(row[2]),Convert.ToDouble(row[3]),setElementRow,4); setElement(Convert.ToDouble(row[1]),Convert.ToDouble(row[2]),Convert.ToDouble(row[3]),setElementRow,6); setElement(Convert.ToDouble(row[1]),Convert.ToDouble(row[2]),Convert.ToDouble(row[3]),setElementRow,8); setElementRow ++; } break; case 3: setElementRow = 170; //蔬菜 hasElRowChanged = false; foreach(DataRow row in dsFoodNutPar.Tables[0].Rows) // { if ( setElementRow >= 170 && hasVegChanged ) //控制要操作的单元格 break; if ( setElementRow > 197 ) { setElementRow = 119; hasVegChanged = true; } if ( setElementRow > 138 && !hasElRowChanged && hasVegChanged ) { hasElRowChanged = true; setElementRow = 147; } setElement(Convert.ToDouble(row[1]),Convert.ToDouble(row[2]),Convert.ToDouble(row[3]),setElementRow,4); setElement(Convert.ToDouble(row[1]),Convert.ToDouble(row[2]),Convert.ToDouble(row[3]),setElementRow,6); setElement(Convert.ToDouble(row[1]),Convert.ToDouble(row[2]),Convert.ToDouble(row[3]),setElementRow,8); setElementRow ++; } break; case 4: setElementRow = 233; //粮食 hasElRowChanged = false; foreach(DataRow row in dsFoodNutPar.Tables[0].Rows) { if ( setElementRow > 250 ) break; setElement(Convert.ToDouble(row[1]),Convert.ToDouble(row[2]),Convert.ToDouble(row[3]),setElementRow,4); setElement(Convert.ToDouble(row[1]),Convert.ToDouble(row[2]),Convert.ToDouble(row[3]),setElementRow,6); setElement(Convert.ToDouble(row[1]),Convert.ToDouble(row[2]),Convert.ToDouble(row[3]),setElementRow,8); setElementRow ++; } break; case 5: setElementRow = 291; //调味品 hasElRowChanged = false; foreach(DataRow row in dsFoodNutPar.Tables[0].Rows) { if ( setElementRow > 307 ) break; setElement(Convert.ToDouble(row[1]),Convert.ToDouble(row[2]),Convert.ToDouble(row[3]),setElementRow,4); setElement(Convert.ToDouble(row[1]),Convert.ToDouble(row[2]),Convert.ToDouble(row[3]),setElementRow,6); setElement(Convert.ToDouble(row[1]),Convert.ToDouble(row[2]),Convert.ToDouble(row[3]),setElementRow,8); setElementRow ++; } break; case 6: setElementRow = 264; //糕点 hasElRowChanged = false; foreach(DataRow row in dsFoodNutPar.Tables[0].Rows) { if ( setElementRow > 289 ) break; if ( setElementRow > 278 && !hasElRowChanged ) { hasElRowChanged = true; setElementRow = 287; } setElement(Convert.ToDouble(row[1]),Convert.ToDouble(row[2]),Convert.ToDouble(row[3]),setElementRow,4); setElement(Convert.ToDouble(row[1]),Convert.ToDouble(row[2]),Convert.ToDouble(row[3]),setElementRow,6); setElement(Convert.ToDouble(row[1]),Convert.ToDouble(row[2]),Convert.ToDouble(row[3]),setElementRow,8); setElementRow ++; } break; case 7: setElementRow = 85; //豆制品 foreach(DataRow row in dsFoodNutPar.Tables[0].Rows) { if ( setElementRow > 117 ) break; setElement(Convert.ToDouble(row[1]),Convert.ToDouble(row[2]),Convert.ToDouble(row[3]),setElementRow,4); setElement(Convert.ToDouble(row[1]),Convert.ToDouble(row[2]),Convert.ToDouble(row[3]),setElementRow,6); setElement(Convert.ToDouble(row[1]),Convert.ToDouble(row[2]),Convert.ToDouble(row[3]),setElementRow,8); setElementRow ++; } break; case 8: foreach(DataRow row in dsFoodNutPar.Tables[0].Rows) { if ( setElementRow > 117 ) break; setElement(Convert.ToDouble(row[1]),Convert.ToDouble(row[2]),Convert.ToDouble(row[3]),setElementRow,4); setElement(Convert.ToDouble(row[1]),Convert.ToDouble(row[2]),Convert.ToDouble(row[3]),setElementRow,6); setElement(Convert.ToDouble(row[1]),Convert.ToDouble(row[2]),Convert.ToDouble(row[3]),setElementRow,8); setElementRow ++; } break; case 9: setElementRow = 252; //菌藻类 foreach(DataRow row in dsFoodNutPar.Tables[0].Rows) { if ( setElementRow > 262 ) break; setElement(Convert.ToDouble(row[1]),Convert.ToDouble(row[2]),Convert.ToDouble(row[3]),setElementRow,4); setElement(Convert.ToDouble(row[1]),Convert.ToDouble(row[2]),Convert.ToDouble(row[3]),setElementRow,6); setElement(Convert.ToDouble(row[1]),Convert.ToDouble(row[2]),Convert.ToDouble(row[3]),setElementRow,8); setElementRow ++; } break; } } } getDairy(); }
private void writeACC2() //月食物营养摄取表2 { m_objSheet = (Excel._Worksheet)(m_objSheets.get_Item(6)); int setRow = 6; int setColumn = 1; int endTime = Convert.ToInt32(EndDate.Date.ToString("dd")); int begTime; DataSet dsGetConsumption = new FoodManagementDataAccess().GetAcc2(BegDate.Date.ToString("yyyy-MM-dd"),EndDate.Date.ToString("yyyy-MM-dd"), Convert.ToInt32(BegDate.Date.ToString("MM"))); DataSet dsGetEachDayConsum = null; foreach(DataRow row in dsGetConsumption.Tables[0].Rows) { setColumn = 1; double countTotal = 0; m_objRange = m_objSheet.get_Range(m_objSheet.Cells[setRow,setColumn],m_objSheet.Cells[setRow,setColumn]); m_objRange.set_Item(1,1,row[2].ToString()); for ( begTime=Convert.ToInt32(BegDate.Date.ToString("dd")); begTime<=endTime; begTime++ ) { dsGetEachDayConsum = new FoodManagementDataAccess().GetAcc2EachDay(BegDate.Date.ToString("yyyy-MM-dd"),EndDate.Date.ToString("yyyy-MM-dd"), Convert.ToInt32(BegDate.Date.ToString("MM")),begTime,Convert.ToInt32(row[0])); if ( dsGetEachDayConsum.Tables[0].Rows.Count > 0 ) { setColumn ++; m_objRange = m_objSheet.get_Range(m_objSheet.Cells[setRow,setColumn],m_objSheet.Cells[setRow,setColumn]); m_objRange.set_Item(1,1,dsGetEachDayConsum.Tables[0].Rows[0][0].ToString()); countTotal += Convert.ToDouble(dsGetEachDayConsum.Tables[0].Rows[0][0]); } else setColumn++; } m_objRange = m_objSheet.get_Range(m_objSheet.Cells[setRow,33],m_objSheet.Cells[setRow,33]); m_objRange.set_Item(1,1,countTotal); setRow ++; } }
private void writeACC1() //月食物营养摄取表1 { m_objSheet = (Excel._Worksheet)(m_objSheets.get_Item(5)); for(int cateID=1;cateID<=10;cateID++) { DataSet dsGetFoodAmount = new FoodManagementDataAccess().GetAcc1(BegDate.Date.ToString("yyyy-MM-dd"),EndDate.Date.ToString("yyyy-MM-dd"), Convert.ToInt32(BegDate.Date.ToString("MM")),cateID); switch(cateID) { case 1: setACCRow = 9; //肉禽 hasACCRowChanged = false; foreach ( DataRow row in dsGetFoodAmount.Tables[0].Rows ) { if ( setACCRow > 51 && !hasACCRowChanged ) { hasACCRowChanged = true; setACCRow = 63; } if ( setACCRow > 88 ) break; setACC1(new FoodManagementDataAccess().GetAcc1FoodName(Convert.ToInt32(row[0])),Convert.ToDouble(row[1]),setACCRow,1,true); setACC1(new FoodManagementDataAccess().GetAcc1FoodName(Convert.ToInt32(row[0])),Convert.ToDouble(row[1]),setACCRow,2,false); setACCRow ++; } break; case 2: setACCRow = 63; //水果 hasACCRowChanged = false; foreach ( DataRow row in dsGetFoodAmount.Tables[0].Rows ) { if ( setACCRow > 87 ) break; setACC1(new FoodManagementDataAccess().GetAcc1FoodName(Convert.ToInt32(row[0])),Convert.ToDouble(row[1]),setACCRow,4,true); setACC1(new FoodManagementDataAccess().GetAcc1FoodName(Convert.ToInt32(row[0])),Convert.ToDouble(row[1]),setACCRow,5,false); setACCRow ++; } break; case 3: setACCRow = 9; //蔬菜 hasACCRowChanged = false; foreach ( DataRow row in dsGetFoodAmount.Tables[0].Rows ) { if ( setACCRow > 36 && !hasACCRowChanged ) { hasACCRowChanged = true; setACCRow = 116; } if ( setACCRow > 159 ) break; setACC1(new FoodManagementDataAccess().GetAcc1FoodName(Convert.ToInt32(row[0])),Convert.ToDouble(row[1]),setACCRow,4,true); setACC1(new FoodManagementDataAccess().GetAcc1FoodName(Convert.ToInt32(row[0])),Convert.ToDouble(row[1]),setACCRow,5,false); setACCRow ++; } break; case 4: setACCRow = 89; //粮食 hasACCRowChanged = false; foreach ( DataRow row in dsGetFoodAmount.Tables[0].Rows ) { if ( setACCRow > 106 ) break; setACC1(new FoodManagementDataAccess().GetAcc1FoodName(Convert.ToInt32(row[0])),Convert.ToDouble(row[1]),setACCRow,1,true); setACC1(new FoodManagementDataAccess().GetAcc1FoodName(Convert.ToInt32(row[0])),Convert.ToDouble(row[1]),setACCRow,2,false); setACCRow ++; } break; case 5: setACCRow = 37; //调味品 hasACCRowChanged = false; foreach ( DataRow row in dsGetFoodAmount.Tables[0].Rows ) { if ( setACCRow > 53 ) break; setACC1(new FoodManagementDataAccess().GetAcc1FoodName(Convert.ToInt32(row[0])),Convert.ToDouble(row[1]),setACCRow,4,true); setACC1(new FoodManagementDataAccess().GetAcc1FoodName(Convert.ToInt32(row[0])),Convert.ToDouble(row[1]),setACCRow,5,false); setACCRow ++; } break; case 6: setACCRow = 88; //糕点 hasACCRowChanged = false; foreach ( DataRow row in dsGetFoodAmount.Tables[0].Rows ) { if ( setACCRow > 105) break; setACC1(new FoodManagementDataAccess().GetAcc1FoodName(Convert.ToInt32(row[0])),Convert.ToDouble(row[1]),setACCRow,4,true); setACC1(new FoodManagementDataAccess().GetAcc1FoodName(Convert.ToInt32(row[0])),Convert.ToDouble(row[1]),setACCRow,5,false); setACCRow ++; } break; case 7: setACCRow = 116; //豆制品 hasACCRowChanged = false; foreach ( DataRow row in dsGetFoodAmount.Tables[0].Rows ) { if ( setACCRow > 148 ) break; setACC1(new FoodManagementDataAccess().GetAcc1FoodName(Convert.ToInt32(row[0])),Convert.ToDouble(row[1]),setACCRow,1,true); setACC1(new FoodManagementDataAccess().GetAcc1FoodName(Convert.ToInt32(row[0])),Convert.ToDouble(row[1]),setACCRow,2,false); setACCRow ++; } break; case 8: hasACCRowChanged = false; //乳类 foreach ( DataRow row in dsGetFoodAmount.Tables[0].Rows ) { if ( setACCRow > 148 ) break; setACC1(new FoodManagementDataAccess().GetAcc1FoodName(Convert.ToInt32(row[0])),Convert.ToDouble(row[1]),setACCRow,1,true); setACC1(new FoodManagementDataAccess().GetAcc1FoodName(Convert.ToInt32(row[0])),Convert.ToDouble(row[1]),setACCRow,2,false); setACCRow ++; } break; case 9: setACCRow = 149; //菌藻类 hasACCRowChanged = false; foreach ( DataRow row in dsGetFoodAmount.Tables[0].Rows ) { if ( setACCRow > 159 ) break; setACC1(new FoodManagementDataAccess().GetAcc1FoodName(Convert.ToInt32(row[0])),Convert.ToDouble(row[1]),setACCRow,1,true); setACC1(new FoodManagementDataAccess().GetAcc1FoodName(Convert.ToInt32(row[0])),Convert.ToDouble(row[1]),setACCRow,2,false); setACCRow ++; } break; } } }
private void writeStuAmount() //人数 { try { int endTime = Convert.ToInt32(EndDate.Date.ToString("dd")); int begTime; int rangeRow = 6; m_objSheet = (Excel._Worksheet)(m_objSheets.get_Item(2)); foreach(DataRow row in new GradesDataAccess().GetGradeInfoList(0).Tables[0].Rows) { int countTotal = 0; if(Convert.ToInt32(row[0])>0) { m_objRange = m_objSheet.get_Range(m_objSheet.Cells[rangeRow,1],m_objSheet.Cells[rangeRow,1]); m_objRange.set_Item(1,1,row[1].ToString()); for( begTime = Convert.ToInt32(BegDate.Date.ToString("dd")); begTime <= endTime; begTime++ ) { try { using ( FoodManagementDataAccess foodManagementDataAccess = new FoodManagementDataAccess() ) { int getAmount = foodManagementDataAccess.GetStuAmountForNut(BegDate,EndDate,Convert.ToInt32(BegDate.Date.ToString("MM")), begTime,Convert.ToInt32(row[0])); m_objRange = m_objSheet.get_Range(m_objSheet.Cells[rangeRow,1],m_objSheet.Cells[rangeRow,1]); m_objRange.set_Item(1,begTime+1,getAmount.ToString()); countTotal += Convert.ToInt32(getAmount); } } catch(Exception e) { Util.WriteLog(e.Message,Util.EXCEPTION_LOG_TITLE); } } m_objRange = m_objSheet.get_Range(m_objSheet.Cells[rangeRow,17],m_objSheet.Cells[rangeRow,17]); m_objRange.set_Item(1,17,countTotal.ToString()); rangeRow++; } } } catch(Exception e) { Util.WriteLog(e.Message,Util.EXCEPTION_LOG_TITLE); } }