Beispiel #1
0
 public UnitOfWork(TruckDbContext context)
 {
     _context     = context;
     Incomes      = new IncomeRepository(_context);
     IncomeSource = new IncomeSourceRepository(_context);
     Spends       = new SpendRepository(_context);
     SpendSource  = new SpendSourceRepository(_context);
     User         = new UserRepository(_context);
     Role         = new RoleRepository(_context);
     Log          = new LogRepository(_context);
 }
Beispiel #2
0
        public virtual void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                if (_dbContext != null)
                {
                    _dbContext.Dispose();
                    _dbContext = null;
                }
            }

            // release any unmanaged objects
            // set the object references to null

            _disposed = true;
        }
 public IncomeRepository(TruckDbContext context) : base(context)
 {
 }
 public RoleRepository(TruckDbContext context) : base(context)
 {
 }
Beispiel #5
0
 public TrucksController(TruckDbContext context)
 {
     _context = context;
 }
 public SpendSourceRepository(TruckDbContext context) : base(context)
 {
 }
Beispiel #7
0
 public KirimsController(TruckDbContext context)
 {
     _context = context;
 }
Beispiel #8
0
 public TruckDbContext Init()
 {
     return(_dbContext ?? (_dbContext = new TruckDbContext()));
 }
Beispiel #9
0
 public UserRepository(TruckDbContext context) : base(context)
 {
 }
Beispiel #10
0
 public KaryawansController(TruckDbContext context)
 {
     _context = context;
 }
Beispiel #11
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();
            }
        }
 public LogRepository(TruckDbContext context) : base(context)
 {
 }