protected override void SetupDependencies() { OnDependency <IReportingRepository>() .Setup(x => x.Update <AccountDetailsReport>(It.IsAny <object>(), It.IsAny <object>())) .Callback <object, object>((u, w) => { UpdateAccountDetailsObject = u; WhereAccountDetailsObject = w; }); OnDependency <IReportingRepository>() .Setup(x => x.Save(It.IsAny <LedgerReport>())) .Callback <LedgerReport>(l => { LedgerReportObject = l; }); }
public void Will_be_able_to_save_and_retrieve_a_ledger_dto() { var ledgerDto = new LedgerReport(Guid.NewGuid(), Guid.NewGuid(), "Action", 12.3M); _repository.Save(ledgerDto); var sut = _repository.GetByExample <LedgerReport>(new { Action = "Action", Amount = 12.3M }).FirstOrDefault(); Assert.That(sut.Id, Is.EqualTo(ledgerDto.Id)); Assert.That(sut.AccountDetailsReportId, Is.EqualTo(ledgerDto.AccountDetailsReportId)); Assert.That(sut.Amount, Is.EqualTo(ledgerDto.Amount)); Assert.That(sut.Action, Is.EqualTo(ledgerDto.Action)); }
private LedgerReport CreateLedgerReport(long sobId, long fromCodeCombinationId, long toCodeCombinationId, DateTime fromDate, DateTime toDate) { List <LedgerModel> modelList = mapLedgerModel(service.Ledger(AuthenticationHelper.User.CompanyId, sobId, fromCodeCombinationId >= toCodeCombinationId ? toCodeCombinationId : fromCodeCombinationId, toCodeCombinationId <= fromCodeCombinationId ? fromCodeCombinationId : toCodeCombinationId, fromDate, toDate)); LedgerReport report = new LedgerReport(); report.Parameters["CompanyName"].Value = companyService .GetSingle(AuthenticationHelper.User.CompanyId.ToString(), AuthenticationHelper.User.CompanyId).Name; report.Parameters["SOBId"].Value = sobId; report.Parameters["FromDate"].Value = fromDate; report.Parameters["ToDate"].Value = toDate; report.Parameters["FromCodeCombinationId"].Value = fromCodeCombinationId; report.Parameters["ToCodeCombinationId"].Value = toCodeCombinationId; report.DataSource = modelList; return(report); }
private void btnViewLedger_Click(object sender, EventArgs e) { if (cmbLedger.Text == "" && (chkAll.Checked == false)) { MessageBox.Show("Please select the Ledger to display!", "Falcon", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } using (SqlConnection conn = new SqlConnection(ClassDBUtils.DBConnString)) { try { conn.Open(); if (chkAll.Checked == false) { string strSQL = "select ledgercode from LedgerAccount where ledgername like '" + cmbLedger.Text + "%'"; SqlCommand cmdClient = new SqlCommand(strSQL, conn); string code = cmdClient.ExecuteScalar().ToString(); SqlCommand cmd = new SqlCommand("PopulateLedger2", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 5000; SqlParameter p1 = new SqlParameter("@Login", ClassGenLib.username); SqlParameter p2 = new SqlParameter("@ClientNo", code); SqlParameter p3 = new SqlParameter("@StartDate", dtStart.DateTime.Date); SqlParameter p4 = new SqlParameter("@EndDate", dtEnd.DateTime.Date); cmd.Parameters.Add(p1); cmd.Parameters.Add(p2); cmd.Parameters.Add(p3); cmd.Parameters.Add(p4); cmd.ExecuteNonQuery(); LedgerReport rptLedger = new LedgerReport(); rptLedger.Parameters["start"].Value = dtStart.Text; rptLedger.Parameters["end"].Value = dtEnd.Text; rptLedger.Parameters["ledger"].Value = cmbLedger.Text; rptLedger.Parameters["username"].Value = ClassGenLib.username; ((SqlDataSource)rptLedger.DataSource).ConfigureDataConnection += SelectReport_ConfigureDataConnection; ReportPrintTool tool = new ReportPrintTool(rptLedger); tool.ShowPreview(); } else { SqlCommand cmd1 = new SqlCommand("spConsolidatedCharges", conn); cmd1.CommandType = CommandType.StoredProcedure; SqlParameter p1 = new SqlParameter("@start", dtStart.Text); SqlParameter p2 = new SqlParameter("@end", dtEnd.Text); SqlParameter p3 = new SqlParameter("@user", ClassGenLib.username); cmd1.Parameters.Add(p1); cmd1.Parameters.Add(p2); cmd1.Parameters.Add(p3); cmd1.ExecuteNonQuery(); ConsildatedCharges cchgs = new ConsildatedCharges(); cchgs.Parameters["start"].Value = dtStart.Text; cchgs.Parameters["end"].Value = dtEnd.Text; ((SqlDataSource)cchgs.DataSource).ConfigureDataConnection += SelectReport_ConfigureDataConnection; ReportPrintTool tool = new ReportPrintTool(cchgs); tool.ShowPreview(); } //CrystalForm rpts = new CrystalForm("Ledger - " + cmbLedger.Text, "", "", dtStart.DateTime, dtEnd.DateTime); //rpts.ShowDialog(); } catch (Exception ex) { MessageBox.Show("Error connecting to database! Reason:- " + ex.Message, "Falcon20", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (conn != null) { conn.Close(); } } chkAll.Enabled = true; } }