Example #1
0
        public ActionResult AddEditSpend(int itemId)
        {
            SpendReport model = new SpendReport();

            if (itemId > 0)
            {
                model = objSpend.GetSpendData(itemId);
            }
            return(PartialView("_spendForm", model));
        }
Example #2
0
 public ActionResult Create(SpendReport newSpend)
 {
     if (ModelState.IsValid)
     {
         if (newSpend.ItemId > 0)
         {
             objSpend.UpdateSpend(newSpend);
         }
         else
         {
             objSpend.AddSpend(newSpend);
         }
     }
     return(RedirectToAction("Index"));
 }
Example #3
0
        private void BtnReport_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                SqlParameter from, to, id; DataTable dt = null;
                from = new SqlParameter {
                    ParameterName = "@fromDate", Value = txtFromDate.SelectedDate
                };
                to = new SqlParameter {
                    ParameterName = "@toDate", Value = txtToDate.SelectedDate
                };
                id = new SqlParameter {
                    ParameterName = "@sourceId", Value = cmbSourceName.SelectedValue
                };
                String Path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                if (txtFromDate.SelectedDate == null && txtToDate.SelectedDate == null)
                {
                    from = new SqlParameter {
                        ParameterName = "@fromDate", Value = DBNull.Value
                    };
                    to = new SqlParameter {
                        ParameterName = "@toDate", Value = DBNull.Value
                    };
                }

                //income
                if (cmbreportType.SelectedIndex == 0 && GroupBy.IsChecked == false)
                {
                    var list = new TruckDbContext(DbSettingHelper.BuildConnectionString()).Database.SqlQuery <SpGetIncomeModel>("exec dbo.SpGetIncome @sourceId,@fromDate,@toDate", id, from, to).ToList <SpGetIncomeModel>();
                    dt = ApplicationState.ToDataTable(list);
                    IncomeReport incomeReport = new IncomeReport();
                    // Path = System.IO.Path.Combine(Path, @"Reports\IncomeReport.rpt");
                    var fi = System.AppDomain.CurrentDomain.BaseDirectory;
                    incomeReport.Load("~/Reports/IncomeReport.rpt");
                    incomeReport.SetDataSource(dt);
                    incomeReport.Refresh();
                    reportViewer.ViewerCore.ReportSource = incomeReport;
                }
                //income Group By

                if (cmbreportType.SelectedIndex == 0 && GroupBy.IsChecked == true)
                {
                    var list = new TruckDbContext(DbSettingHelper.BuildConnectionString()).Database.SqlQuery <SpGetIncomeModel>("exec dbo.SpGetIncome @sourceId,@fromDate,@toDate", id, from, to).ToList <SpGetIncomeModel>();
                    dt = ApplicationState.ToDataTable(list);
                    IncomeReportByGroup incomeReport = new IncomeReportByGroup();
                    Path = System.IO.Path.Combine(Path, @"Reports\IncomeReportByGroup.rpt");
                    incomeReport.Load(Path);
                    incomeReport.SetDataSource(dt);
                    incomeReport.Refresh();
                    reportViewer.ViewerCore.ReportSource = incomeReport;
                }

                //spend Group By

                if (cmbreportType.SelectedIndex == 1 && GroupBy.IsChecked == true)
                {
                    var list = new TruckDbContext(DbSettingHelper.BuildConnectionString()).Database.SqlQuery <SpGetSpendModel>("exec SpGetSpend @sourceId,@fromDate,@toDate", id, from, to).ToList <SpGetSpendModel>();
                    dt = ApplicationState.ToDataTable(list);
                    SpendReportByGroup spendReport = new SpendReportByGroup();
                    Path = System.IO.Path.Combine(Path, @"Reports\SpendReportByGroup.rpt");
                    spendReport.Load(Path);

                    spendReport.SetDataSource(dt);
                    spendReport.Refresh();

                    reportViewer.ViewerCore.ReportSource = spendReport;
                }
                //spend
                if (cmbreportType.SelectedIndex == 1 && GroupBy.IsChecked == false)
                {
                    var list = new TruckDbContext(DbSettingHelper.BuildConnectionString()).Database.SqlQuery <SpGetSpendModel>("exec SpGetSpend @sourceId,@fromDate,@toDate", id, from, to).ToList <SpGetSpendModel>();
                    dt = ApplicationState.ToDataTable(list);
                    SpendReport spendReport = new SpendReport();
                    Path = System.IO.Path.Combine(Path, @"Reports\SpendReport.rpt");
                    spendReport.Load(Path);
                    spendReport.SetDataSource(dt);
                    spendReport.Refresh();
                    reportViewer.ViewerCore.ReportSource = spendReport;
                }
            }
            catch (Exception ex)
            {
                status.Text   = $"প্রোগ্রাম সম্পর্কিত সমস্যা: {ex.Message}";
                Dialog.IsOpen = true;
                _unitOfWork.Log.Add(new Log {
                    Date = DateTime.Now, Exception = ex.Message, Level = "Test", Logger = "Test", Thread = "Test", Message = ex.Message
                });
                _unitOfWork.Complete();
            }
        }