Пример #1
0
        public DataSet GetControlSheet(DateTime dateTime, string connetionStringName)
        {
            StoreRemoteDataBaseUitility db = new StoreRemoteDataBaseUitility(connetionStringName);

            // This procedure set 7 day data
            DateTime weekStartDate = ValidationUtility.GetActualWeekStartDate(dateTime);
            DateTime weekEndDate = weekStartDate.AddDays(6);
            SqlParameter[] sqlParams = new SqlParameter[] {
            new SqlParameter("@StartDate",weekStartDate ),
            new SqlParameter("@EndDate",weekEndDate ),};

            db.ExecuteSPDataTable("dbo.CalculateCashControlData", sqlParams);

            // This procedure is use for get CashControl data
            SqlParameter[] controlSheetSqlParams = new SqlParameter[] {
            new SqlParameter("@WeekEndingDate",weekEndDate ),};
            DataTable cashControlDataTable = db.ExecuteSPDataTable("Central.ControlSheetReport_CashControl_SelectStoredProcedure", controlSheetSqlParams);

            // This procedure is use for get SalesItemization data
            SqlParameter[] salesItemizationSqlParams = new SqlParameter[] {
            new SqlParameter("@WeekEndingDate",weekEndDate ),};
            DataTable salesItemizationDataTable = db.ExecuteSPDataTable("Central.ControlSheetReport_SalesItemization_SelectStoredProcedure", salesItemizationSqlParams);

            // This procedure is use for get BreadControl data
            SqlParameter[] breadControlSqlParams = new SqlParameter[] {
            new SqlParameter("@WeekEndingDate",weekEndDate ),};
            DataTable breadControlDataTable = db.ExecuteSPDataTable("Central.ControlSheetReport_BreadControl_SelectStoredProcedure", breadControlSqlParams);

            // This procedure is use for get UnitsItemization data
            SqlParameter[] unitsItemizationSqlParams = new SqlParameter[] {
            new SqlParameter("@WeekEndingDate",weekEndDate ),};
            DataTable UnitsItemizationDataTable = db.ExecuteSPDataTable("Central.ControlSheetReport_UnitsItemization_SelectStoredProcedure", unitsItemizationSqlParams);

            // This procedure is use for get Labor data
            SqlParameter[] laborSqlParams = new SqlParameter[] {
            new SqlParameter("@WeekEndingDate",weekEndDate ),};
            DataTable laborDataTable = db.ExecuteSPDataTable("Central.ControlSheetReport_Labor_SelectStoredProcedure", laborSqlParams);

            ArrayList list = new ArrayList();
            for (int i = 0; i <= 6; i++)
            {
                DateTime getDateRecord = weekStartDate.AddDays(i);

                //string innerQuery = " select sum(AmtSubwaySales) as ammount  from Report.OrdersSummary os, dbo.OpeningInformation oi where os.OpeningInformationId = oi.OpeningInformationId and oi.BusinessDate =  '" + getDateRecord.ToString("yyyy/MM/dd") + "' ";
                string innerQuery = " select AmtTotalSales from Report.OpeningInformationsSummary where OpeningInformationId = (select OpeningInformationId from  dbo.OpeningInformation where BusinessDate = '" + SQLUtility.FormateDateYYYYMMDD(getDateRecord) + "' ) ";

                list.Add(db.GetSubWaySale(innerQuery));

            }

            ArrayList list1 = new ArrayList();
            for (int i = 0; i <= 6; i++)
            {
                DateTime getDateRecord = weekStartDate.AddDays(i);

                string innerQuery = " select sum(AmtAdjustedUnitSales) as ammount  from Report.OrdersSummary os, dbo.OpeningInformation oi where os.OpeningInformationId = oi.OpeningInformationId and oi.BusinessDate =  '" + getDateRecord.ToString("yyyy/MM/dd") + "' ";

                list1.Add(db.GetSubWaySale(innerQuery));

            }

            ArrayList list2 = new ArrayList();
            for (int i = 0; i <= 6; i++)
            {
                DateTime getDateRecord = weekStartDate.AddDays(i);

                string innerQuery = " select sum(AmtDrinkSales) as ammount  from Report.OrdersSummary os, dbo.OpeningInformation oi where os.OpeningInformationId = oi.OpeningInformationId and oi.BusinessDate =  '" + getDateRecord.ToString("yyyy/MM/dd") + "' ";

                list2.Add(db.GetSubWaySale(innerQuery));

            }

            DataTable totalSubSaleTable = ConvertListToDataTable(list);
            DataTable totalUnitSaleTable = ConvertListToUnitTable(list1);
            DataTable totalDrinkSaleTable = ConvertListToDrinkTable(list2);

            DataSet dataSet = new DataSet();

            dataSet.Tables.Add(cashControlDataTable);
            dataSet.Tables.Add(salesItemizationDataTable);
            dataSet.Tables.Add(breadControlDataTable);
            dataSet.Tables.Add(UnitsItemizationDataTable);
            dataSet.Tables.Add(laborDataTable);
            dataSet.Tables.Add(totalSubSaleTable);
            dataSet.Tables.Add(totalUnitSaleTable);
            dataSet.Tables.Add(totalDrinkSaleTable);
            dataSet.Tables.Add(HeaderInformation(dateTime));

            return dataSet;
        }