示例#1
0
        private void btnCessReportExport_Click(object sender, RoutedEventArgs e)
        {
            int categoryId = -1, foodMenuId = -1;

            try
            {
                if (!DateValidated(dpFromDate, dpToDate))
                {
                    var messageBoxResult = WpfMessageBox.Show(StatusMessages.AppTitle, "Please select FROM DATE grater than or equal to TO DATE", MessageBoxButton.OK, EnumUtility.MessageBoxImage.Warning);

                    return;
                }
                CommonMethods           commonMethods = new CommonMethods();
                string                  path = string.Empty, firstLine = string.Empty;
                CustomerOrderViewModel  customerOrderViewModel  = new CustomerOrderViewModel();
                CessReportModel         cessReportModel         = new CessReportModel();
                CessCategoryReportModel cessCategoryReportModel = new CessCategoryReportModel();

                if (chkCess.IsChecked == false)
                {
                    cessReportModel = customerOrderViewModel.GetCessReport(dpFromDate.SelectedDate.Value.ToString(CommonMethods.DateFormat), dpToDate.SelectedDate.Value.ToString(CommonMethods.DateFormat));

                    string fileName       = "CessReport_" + DateTime.Now.ToString("MM-dd-yyyy_HHmmss");
                    var    saveFileDialog = new SaveFileDialog
                    {
                        FileName   = fileName != "" ? fileName : "gpmfca-exportedDocument",
                        DefaultExt = ".xlsx",
                        Filter     = "Common Seprated Documents (.xlsx)|*.xlsx"
                    };

                    if (saveFileDialog.ShowDialog() == true)
                    {
                        path      = saveFileDialog.FileName;
                        firstLine = LoginDetail.ClientName;
                        commonMethods.WriteCessExcelFile(commonMethods.ConvertToDataTable(cessReportModel.CessSummaryList), commonMethods.ConvertToDataTable(cessReportModel.CessDetailList), path, firstLine);
                    }
                }
                else
                {
                    cessCategoryReportModel = customerOrderViewModel.GetCessCategoryReport(dpFromDate.SelectedDate.Value.ToString(CommonMethods.DateFormat), dpToDate.SelectedDate.Value.ToString(CommonMethods.DateFormat), categoryId, foodMenuId);

                    string fileName       = "CategoryWiseCessReport_" + DateTime.Now.ToString("MM-dd-yyyy_HHmmss");
                    var    saveFileDialog = new SaveFileDialog
                    {
                        FileName   = fileName != "" ? fileName : "gpmfca-exportedDocument",
                        DefaultExt = ".xlsx",
                        Filter     = "Common Seprated Documents (.xlsx)|*.xlsx"
                    };

                    if (saveFileDialog.ShowDialog() == true)
                    {
                        path      = saveFileDialog.FileName;
                        firstLine = LoginDetail.ClientName;
                        commonMethods.WriteCessCategoryExcelFile(commonMethods.ConvertToDataTable(cessCategoryReportModel.CessSummaryList), commonMethods.ConvertToDataTable(cessCategoryReportModel.CessDetailList), path, firstLine);
                    }
                }
            }
            catch (Exception ex)
            {
                SystemError.Register(ex);
            }
        }