public void UpdateDelete_() { int accID; // create var accDA = new AccountDA(_options); accID = accDA.CreateAccount("code", "name", 100, true, AccountTypes.Test).AccountID; var acc = accDA.GetAccounts().FirstOrDefault(r => r.AccountID == accID); acc.Code = "code1"; acc.Name = "name1"; acc.CommPerc = 200; acc.IsShortEnable = false; acc.AccountType = AccountTypes.Real; accDA.UpdateAccount(acc); var acc1 = accDA.GetAccounts().FirstOrDefault(r => r.AccountID == accID); Assert.Equal(accID, acc1.AccountID); Assert.Equal("code1", acc1.Code); Assert.Equal("name1", acc1.Name); Assert.Equal(200, acc1.CommPerc); Assert.False(acc1.IsShortEnable); Assert.Equal(AccountTypes.Real, acc1.AccountType); // delete and cleanp accDA.DeleteAccount(accID); var list = accDA.GetAccounts(); Assert.Empty(list.Where(a => a.AccountID == accID)); }
public HttpResponseMessage PutChangePassword([FromBody] ChangePasswordBindingModel model) { HttpResponseMessage br = new HttpResponseMessage() { StatusCode = HttpStatusCode.BadRequest }; if (!ModelState.IsValid) { br.ReasonPhrase = "Passwords don't match."; return(br); } ClaimsPrincipal p = RequestContext.Principal as ClaimsPrincipal; var data = User.Identity; int affected = AccountDA.UpdatePassword(Convert.ToInt32(p.Claims.FirstOrDefault(c => c.Type == "userid").Value), model, p.Claims); if (affected != 0) { return(new HttpResponseMessage() { StatusCode = HttpStatusCode.OK }); } br.ReasonPhrase = "Old password incorrect."; return(br); }
public static void Open() { HQService.SubscribeStart(); var accounts = AccountDA.List <Account>(); foreach (Account account in accounts) { LoadAccount(account); } var units = UnitDA.List <Unit>(); foreach (Unit unit in units) { LoadUnit(unit); } var positions = PositionDA.List(); foreach (Position position in positions) { LoadPosition(position); } var items = AccountGroupDA.ListItems(); foreach (AccountGroupItem item in items) { LoadAccountGroupItem(item); } HQService.Get(positions.Select(p => p.code)); TradeBiz.Start(); }
protected void Page_Load(object sender, EventArgs e) { var dtAccounts = AccountDA.GetActiveAccountManagers(); if (Request.QueryString["export"] == "csv") { StringBuilder sb = new StringBuilder(); sb.AppendLine("Account Name,ShortCode,Project Number,Manager,Technical Field,Funding Source"); foreach (DataRow dr in dtAccounts.Rows) { sb.AppendLine(string.Join(",", dr.Field <string>("AccountName"), dr.Field <string>("ShortCode"), dr.Field <string>("ProjectNumber"), dr.Field <string>("ManagerDisplayName"), dr.Field <string>("TechnicalFieldName"), dr.Field <string>("FundingSourceName"))); } Response.Clear(); Response.ContentType = "text/csv"; Response.AddHeader("Content-Disposition", string.Format("attachment;filename=active-accounts-{0:yyyyMMddHHmmss}.csv", DateTime.Now)); Response.Write(sb.ToString()); Response.End(); } else { rptAccount.DataSource = dtAccounts; rptAccount.DataBind(); litCurrentTime.Text = DateTime.Now.ToString(); } }
public void LoginCLI() { User user = new User(); PasswordProtection pp = new PasswordProtection(); AccountDA account = new AccountDA(); Console.WriteLine("--------- Welcome | Login the System to continue ----------"); Console.WriteLine(""); Console.WriteLine("User Name: "); user.userName = Console.ReadLine(); Console.WriteLine("Password: "******"successfully Login...!"); Console.Clear(); } else { Console.WriteLine("Invalied Login Attempt...!"); } }
public static DataTable GetAccountsByClientIDAndDate(int clientId, int year, int month) { DateTime sDate = new DateTime(year, month, 1); DateTime eDate = sDate.AddMonths(1); return(AccountDA.GetAccountsByClientIDAndDate(clientId, sDate, eDate)); }
public Result <List <Base> > List4Filter() { UserRoleEnum role = (UserRoleEnum)int.Parse(UserRA.Get(user_id.ToString(), "role")); List <Base> lst = AccountDA.List <Base>(role == UserRoleEnum.Administrator ? 0 : user_id); return(Result(lst)); }
public static DataTable GetManagersByPeriod(DateTime StartPeriod, DateTime EndPeriod, int ChargeTypeID) { if (StartPeriod > EndPeriod) { return(null); } return(AccountDA.GetManagersByPeriod(StartPeriod, EndPeriod, ChargeTypeID)); }
public DataTable GetExistingAccountBL() { DataTable dt = new DataTable(); AccountDA AccountDAOBJ = new AccountDA(); dt = AccountDAOBJ.GetExistingAccountFromDB(); return(dt); }
public void Series_CreateGetDelete() { int accID; // create account var accDA = new AccountDA(_options); accID = accDA.CreateAccount("code", "name", 100, true, AccountTypes.Test).AccountID; var s1 = accDA.CreateSeries(accID, "key1", "name1", Platform.SeriesAxis.LeftAxis, "data1"); var series = accDA.GetSeries(accID).ToList(); Assert.Single(series); Assert.Equal(accID, series[0].AccountID); Assert.Equal("key1", series[0].Key); Assert.Equal("name1", series[0].Name); Assert.Equal(Platform.SeriesAxis.LeftAxis, series[0].Axis); Assert.Equal("data1", series[0].Data); var s2 = accDA.CreateSeries(accID, "key2", "name2", Platform.SeriesAxis.AxisX, "data2"); var series2 = accDA.GetSeries(accID).ToList(); Assert.Equal(2, series2.Count); // create series values accDA.CreateValues(new List <Platform.SeriesValue>() { new Platform.SeriesValue() { SeriesID = s1.SeriesID, Time = new DateTime(2010, 1, 1, 10, 0, 0), EndTime = null, Value = 100, EndValue = null, Data = "d1" } }); accDA.CreateValues(new List <Platform.SeriesValue>() { new Platform.SeriesValue() { SeriesID = s2.SeriesID, Time = new DateTime(2010, 1, 1, 10, 0, 0), EndTime = new DateTime(2010, 1, 1, 10, 0, 1), Value = 1000, EndValue = 2000, Data = "d2" } }); var vals1 = accDA.GetValues(s1.SeriesID).ToList(); var vals2 = accDA.GetValues(s2.SeriesID).ToList(); Assert.Single(vals1); Assert.Single(vals2); Assert.Equal(s1.SeriesID, vals1[0].SeriesID); Assert.Equal(new DateTime(2010, 1, 1, 10, 0, 0), vals1[0].Time); Assert.Null(vals1[0].EndTime); Assert.Equal(100, vals1[0].Value); Assert.Null(vals1[0].EndValue); Assert.Equal("d1", vals1[0].Data); // delete and cleanp accDA.DeleteAccountData(accID); accDA.DeleteAccount(accID); }
public static void SaveAccountCapital() { string[] keys = TradeRA.KeySearch("A_*"); foreach (string key in keys) { Account account = AccountRA.Get(key); AccountDA.UpdateCapital(account); } }
public Result UpdateStatusOrder(StatusOrder model) { ApiResultEnum result = AccountDA.UpdateStatusOrder(model); if (result == ApiResultEnum.Success && MonitorRA.GetStatusTrade() != 0) { AccountRA.UpdateStatusOrder(model.status, "A_" + model.id); } return(Result(result)); }
public Result Update(Model.DB.Account model) { model.created_by = user_id; ApiResultEnum result = AccountDA.Update(model); if (result == ApiResultEnum.Success && MonitorRA.GetStatusTrade() != 0) { OpenCloseBiz.LoadAccount(model, false); } return(Result(result)); }
public static DataTable GetActiveManagers(int currentUserClientId) { if (HttpContext.Current.User.IsInRole("Administrator")) { return(AccountDA.GetActiveManagers(-1)); } else { //Executieves only see him/herself return(AccountDA.GetActiveManagers(currentUserClientId)); } }
public Result <int> Add(Model.DB.Account model) { int id = 0; model.created_by = user_id; ApiResultEnum result = AccountDA.Add(model, ref id); if (result == ApiResultEnum.Success && MonitorRA.GetStatusTrade() != 0) { model.id = id; OpenCloseBiz.LoadAccount(model); } return(Result(result, id)); }
public bool DeleteAnewAccountAndSendToDA(Accounts accounts) { if (accounts.AID == " ") { this.Message = "AID IS INCORRECT"; return(false); } else { AccountDA AccountDAOBJ = new AccountDA(); bool result = AccountDAOBJ.DeleteANewAccountToDB(accounts); return(result); } }
protected void BtnReport_Click(object sender, EventArgs e) { var year = pp1.SelectedYear; var month = pp1.SelectedMonth; var orgId = int.Parse(ddlOrg.SelectedValue); var sw = Stopwatch.StartNew(); var dt = AccountDA.GetAccountDetailsByOrgID(year, month, orgId); sw.Stop(); litDebug.Text = $"<div class=\"debug\"><em>Query completed in {sw.Elapsed.TotalSeconds:0.00} seconds</em></div>"; gvReport.DataSource = dt; gvReport.DataBind(); }
public bool DeleteTeacher(string _teacherID) { AccountDA accountDA = new AccountDA(); bool isExist = false; bool success = accountDA.AccountExist(_teacherID, ref isExist); if (isExist) { success = accountDA.DeleteAccount(_teacherID); } if (success) { success = teacherDA.DeleteTeacher(_teacherID); } return(success); }
public Result Delete(Model.DB.Account model) { var account_groups = AccountGroupDA.List4Account(model.id); if (account_groups.Count > 0) { return(Result(ApiResultEnum.Cited, string.Join(",", account_groups.Select(u => u.code)))); } model.created_by = user_id; ApiResultEnum result = AccountDA.Delete(model); if (result == ApiResultEnum.Success && MonitorRA.GetStatusTrade() != 0) { TradeBiz.RemoveAccount(model.id); AccountRA.Delete("A_" + model.id); } return(Result(result)); }
private static DataTable ConstructRealTable(int ManagerOrgID) { DataSet ds = AccountDA.GetClientAccountDataSet(ManagerOrgID); DataTable dtAccounts = ds.Tables[0]; DataTable dtClientOrgs = ds.Tables[1]; DataTable dtAssociation = ds.Tables[2]; // Construct a table to display DataTable dtDisplay = new DataTable("DisplayTable"); dtDisplay.Columns.Add("DisplayName", typeof(string)); //Add all Accounts as columns foreach (DataRow dr in dtAccounts.Rows) { dtDisplay.Columns.Add("chk" + dr["AccountID"].ToString(), typeof(string)); } //Populate the data string strColumn = string.Empty; foreach (DataRow dr in dtClientOrgs.Rows) { DataRow ndr = dtDisplay.NewRow(); ndr["DisplayName"] = dr["DisplayName"]; DataRow[] adr = dtAssociation.Select(string.Format("ClientOrgID = {0}", dr["ClientOrgID"])); foreach (DataRow assocdr in adr) { strColumn = string.Format("chk{0}", assocdr["AccountID"]); ndr[strColumn] = true; } dtDisplay.Rows.Add(ndr); } //Save the necessary data into session for future reuse if user changes Account Display HttpContext.Current.Session["ClientAccount_dtAccounts"] = dtAccounts; HttpContext.Current.Session["ClientAccount_dtDisplay"] = dtDisplay; //We need to use the session variable to determine if new manager is selected. This saves resource if user only changes Account Display type HttpContext.Current.Session["ClientAccount_ManagerOrgID"] = ManagerOrgID; return(dtDisplay); }
public void CreateGet_() { var accDA = new AccountDA(_options); var acc = accDA.CreateAccount("code", "name", 100, true, AccountTypes.Test); var accounts = accDA.GetAccounts().ToList(); var accs = accounts.Where(a => a.AccountID == acc.AccountID).ToList(); Assert.Single(accs); var acc1 = accs[0]; Assert.Equal(acc.Code, acc1.Code); Assert.Equal(acc.Name, acc1.Name); Assert.Equal(acc.CommPerc, acc1.CommPerc); Assert.Equal(acc.IsShortEnable, acc1.IsShortEnable); Assert.Equal(acc.AccountType, acc1.AccountType); // cleanup accDA.DeleteAccount(acc.AccountID); }
/// <summary> /// custom authorize trong .Net core api phải implement AuthorizeAttribute và IAuthorizationFilter /// </summary> /// <param name="context"></param> public void OnAuthorization(AuthorizationFilterContext context) { var services = context.HttpContext.RequestServices; var Dis = (IDistributedCache)services.GetService(typeof(IDistributedCache)); // Tìm trong mảng Filter xem có AllowAnonymous không ? var check = context.Filters.Any(x => x is IAllowAnonymousFilter); if (check) { return; } // Get token string token = context.HttpContext.Request.Headers[AccountConstant.Authorization]; if (!String.IsNullOrEmpty(token)) { var acc = new AccountDA(Dis, null, null); try { token = token.Length != 0 ? token.Replace(AccountConstant.BearerReplace, string.Empty) : string.Empty; token = accountCommon.MD5Hash(token); string str = acc.GetStringCache(AccountConstant.ListLogoutToken); if (!string.IsNullOrEmpty(str)) { if (str.Contains(token)) { context.Result = new UnauthorizedResult(); return; } } } catch (Exception ex) { Console.WriteLine(ex); context.Result = new UnauthorizedResult(); return; } } }
public void DeleteAccountData_() { int accID; // create var accDA = new AccountDA(_options); var insDA = new InstrumDA(_options); var posDA = new PositionDA(_options); int insID = insDA.InsertInstrum("", "", "", 1, 0, 1); accID = accDA.CreateAccount("code", "name", 100, true, AccountTypes.Test).AccountID; accDA.CreateCash(accID, 0, 0, 0, 0, 0, 0); var order = accDA.CreateOrder(accID, DateTime.Now, insID, Platform.BuySell.Buy, 1, null, Platform.OrderStatus.Active, null, 0); var trade = accDA.CreateTrade(accID, order.OrderID, DateTime.Now, insID, Platform.BuySell.Buy, 1, 0, 0, 0); var so = accDA.CreateStopOrder(accID, DateTime.Now, insID, Platform.BuySell.Buy, Platform.StopOrderType.StopLoss, null, 0, null, 0, Platform.StopOrderStatus.Active, null, 0); var h = accDA.CreateHolding(accID, insID, 1); var pos = posDA.CreatePosition(accID, insID, PosTypes.Long, DateTime.Now, 0, 0, null, null); posDA.AddPosTrade(pos.PosID, trade.TradeID); accDA.DeleteAccountData(accID); Assert.Null(accDA.GetCash(accID)); // данные удалились Assert.Empty(accDA.GetOrders(accID)); Assert.Empty(accDA.GetStopOrders(accID)); Assert.Empty(accDA.GetTrades(accID)); Assert.Empty(accDA.GetHoldings(accID)); Assert.Empty(posDA.GetPosTrades(new List <int>() { pos.PosID })); Assert.Empty(posDA.GetPositions(accID, false)); Assert.NotNull(accDA.GetAccountByID(accID)); // а сам account остался // cleanup insDA.DeleteInstrumByID(insID); accDA.DeleteAccount(accID); }
public AccountController() { accountDA = new AccountDA(); }
protected override void FillDataTable(DataTable dt) { BillingUnit summaryUnit = summaryUnits.First(); Compile mCompile = new Compile(); DataTable dtRoomDB = mCompile.CalcCost("Room", string.Empty, "ChargeTypeID", 5, EndPeriod.AddMonths(-1), 0, 0, Compile.AggType.CliAcctType); DataTable dtClientWithCharges = mCompile.GetTable(1); double roomCapCost = mCompile.CapCost; //***************************************************************************** //2008-01-22 The code below is an EXTRA step for calculating the cost of room charge // Right now the strategy is not to change Compile.CalcCost at all and if I want to // add new features that would affect CalcCost, I would rather do it after CalcCost is called. // But future new design is required else the system will get too complicated. //2208-05-15 the reason why we are doing this extra step is to show NAP rooms (as of now, it's DC Test lab and Chem room) //with correct monthly fee on the JE //dtNAPRoomForAllChargeType's columns //CostID //ChargeTypeID //TableNameOrDescript //RoomID //AcctPer //AddVal //RoomCost //effDate //Get all active NAP Rooms with their costs, all chargetypes are returned //This is a temporary table, it's used to derive the really useful table below DataTable dtNAPRoomForAllChargeType = BLL.RoomManager.GetAllNAPRoomsWithCosts(EndPeriod); //filter out the chargetype so that we only have Internal costs with each NAP room DataRow[] drsNAPRoomForInternal = dtNAPRoomForAllChargeType.Select("ChargeTypeID = 5"); //Loop through each room and find out this specified month's apportionment data. foreach (DataRow dr1 in drsNAPRoomForInternal) { DataTable dtApportionData = BLL.RoomApportionDataManager.GetNAPRoomApportionDataByPeriod(StartPeriod, EndPeriod, dr1.Field <int>("RoomID")); foreach (DataRow dr2 in dtApportionData.Rows) { DataRow[] drs = dtRoomDB.Select(string.Format("ClientID = {0} AND AccountID = {1} AND RoomID = {2}", dr2["ClientID"], dr2["AccountID"], dr2["RoomID"])); if (drs.Length == 1) { drs[0].SetField("TotalCalcCost", (dr2.Field <double>("Percentage") * dr1.Field <double>("RoomCost")) / 100); } } } dtRoomDB.Columns.Add("DebitAccount", typeof(string)); dtRoomDB.Columns.Add("CreditAccount", typeof(string)); dtRoomDB.Columns.Add("LineDesc", typeof(string)); dtRoomDB.Columns.Add("TotalAllAccountCost", typeof(double)); //dtRoom - ClientID, AccountID, RoomID, TotalCalCost, TotalEntries, TotalHours // cap costs - capping is per clientorg, thus apportion cappeing across charges // note that this assumes that there is only one org for internal academic!!! object temp; double totalRoomCharges; foreach (DataRow drCWC in dtClientWithCharges.Rows) { temp = dtRoomDB.Compute("SUM(TotalCalcCost)", string.Format("ClientID = {0}", drCWC["ClientID"])); if (temp == null || temp == DBNull.Value) { totalRoomCharges = 0; } else { totalRoomCharges = Convert.ToDouble(temp); } if (totalRoomCharges > roomCapCost) { DataRow[] fdr = dtRoomDB.Select(string.Format("ClientID = {0}", drCWC["ClientID"])); for (int i = 0; i < fdr.Length; i++) { fdr[i].SetField("TotalCalcCost", fdr[i].Field <double>("TotalCalcCost") * roomCapCost / totalRoomCharges); } } } DataTable dtClient = ClientDA.GetAllClient(StartPeriod, EndPeriod); DataTable dtAccount = AccountDA.GetAllInternalAccount(StartPeriod, EndPeriod); DataTable dtClientAccount = ClientDA.GetAllClientAccountWithManagerName(StartPeriod, EndPeriod); //used to find out manager's name //Get the general lab account ID and lab credit account ID GlobalCost gc = GlobalCostDA.GetGlobalCost(); //2008-05-15 very complicated code - trying to figure out the percentage distribution for monthly users, since the "TotalCalcCost" has //been calculated based on percentage in the CalcCost function, so we need to figure out the percentage here again by findind out the total //and divide the individual record's "TotalCalcCost' foreach (DataRow drCWC in dtClientWithCharges.Rows) { DataRow[] fdr = dtRoomDB.Select(string.Format("ClientID = {0} AND RoomID = {1}", drCWC["ClientID"], (int)BLL.LabRoom.CleanRoom)); if (fdr.Length > 1) { //this user has multiple account for the clean room usage, so we have to find out the total of all accounts on this clean room double tempTotal = Convert.ToDouble(dtRoomDB.Compute("SUM(TotalCalcCost)", string.Format("ClientID = {0} AND RoomID = {1}", drCWC["ClientID"], (int)BLL.LabRoom.CleanRoom))); DataRow[] fdrRoom = dtRoomDB.Select(string.Format("ClientID = {0} AND RoomID = {1}", drCWC["ClientID"], (int)BLL.LabRoom.CleanRoom)); for (int i = 0; i < fdrRoom.Length; i++) { fdrRoom[i].SetField("TotalAllAccountCost", tempTotal); //assign the total to each record } } } //2008-08-28 Get Billing Type DataTable dtBillingType = BillingTypeDA.GetAllBillingTypes(); foreach (DataRow dr in dtRoomDB.Rows) { dr["DebitAccount"] = dtAccount.Rows.Find(dr.Field <int>("AccountID"))["Number"]; dr["CreditAccount"] = dtAccount.Rows.Find(gc.LabCreditAccountID)["Number"]; //2007-06-19 financial manager may not be an administrator, but their username must be on JE dr["LineDesc"] = GetLineDesc(dr, dtClient, dtBillingType); //2008-05-15 the code below handles the clean room monthly users - it's special code that we have to get rid of when all //billingtype are all gone int billingTypeId = dr.Field <int>("BillingType"); if (dr.Field <BLL.LabRoom>("RoomID") == BLL.LabRoom.CleanRoom) //6 is clean room { if (BillingTypes.IsMonthlyUserBillingType(billingTypeId)) { if (dr["TotalAllAccountCost"] == DBNull.Value) { //if TotalAllAccountCost is nothing, it means this user has only one account //2008-10-27 but it might also that the user has only one internal account, and he apportion all hours to his external accouts //so we must also check 'TotalHours' to make sure the user has more than 0 hours if (dr.Field <double>("TotalHours") != 0) { dr.SetField("TotalCalcCost", BLL.BillingTypeManager.GetTotalCostByBillingType(billingTypeId, 0, 0, BLL.LabRoom.CleanRoom, 1315)); } } else { double total = dr.Field <double>("TotalAllAccountCost"); dr.SetField("TotalCalcCost", (dr.Field <double>("TotalCalcCost") / total) * BLL.BillingTypeManager.GetTotalCostByBillingType(billingTypeId, 0, 0, BLL.LabRoom.CleanRoom, 1315)); } } } } //****** apply filters ****** //Get the list below so that we can exclude users who spent less than X minutes in lab(Clean or Chem) in this month DataTable dtlistClean = RoomUsageData.GetUserListLessThanXMin(StartPeriod, EndPeriod, int.Parse(ConfigurationManager.AppSettings["CleanRoomMinTimeMinute"]), "CleanRoom"); DataTable dtlistChem = RoomUsageData.GetUserListLessThanXMin(StartPeriod, EndPeriod, int.Parse(ConfigurationManager.AppSettings["ChemRoomMinTimeMinute"]), "ChemRoom"); //For performance issue, we have to calculate something first, since it's used on all rows string depRefNum = string.Empty; double fTotal = 0; string creditAccount = dtAccount.Rows.Find(gc.LabCreditAccountID)["Number"].ToString(); string creditAccountShortCode = dtAccount.Rows.Find(gc.LabCreditAccountID)["ShortCode"].ToString(); //Do not show an item if the charge and xcharge accounts are the 'same' - can only happen for 941975 //Do not show items that are associated with specific accounts - need to allow users to add manually here in future foreach (DataRow sdr in dtRoomDB.Rows) { if (sdr.Field <double>("TotalCalcCost") > 0) { var excludedAccounts = new[] { gc.LabAccountID, 143, 179, 188 }; if (!excludedAccounts.Contains(sdr.Field <int>("AccountID")) && sdr.Field <int>("BillingType") != BillingTypes.Other) { //2006-12-21 get rid of people who stayed in the lab less than 30 minutes in a month string expression = string.Format("ClientID = {0}", sdr["ClientID"]); DataRow[] foundRows; bool flag = false; if (sdr.Field <BLL.LabRoom>("RoomID") == BLL.LabRoom.CleanRoom) //6 = clean room { foundRows = dtlistClean.Select(expression); } else if (sdr.Field <BLL.LabRoom>("RoomID") == BLL.LabRoom.ChemRoom) //25 = chem room { foundRows = dtlistChem.Select(expression); } else //DCLab { foundRows = null; } if (foundRows == null) { flag = true; //add to the SUB } else { if (foundRows.Length == 0) { flag = true; } } if (flag) //if no foundrow, we can add this client to JE { DataRow ndr = dt.NewRow(); DataRow drAccount = dtAccount.Rows.Find(sdr.Field <int>("AccountID")); string debitAccount = drAccount["Number"].ToString(); string shortCode = drAccount["ShortCode"].ToString(); //get manager's name DataRow[] drClientAccount = dtClientAccount.Select(string.Format("AccountID = {0}", sdr["AccountID"])); if (drClientAccount.Length > 0) { depRefNum = drClientAccount[0]["ManagerName"].ToString(); } else { depRefNum = "No Manager Found"; } AccountNumber debitAccountNum = AccountNumber.Parse(debitAccount); ndr["CardType"] = 1; ndr["ShortCode"] = shortCode; ndr["Account"] = debitAccountNum.Account; ndr["FundCode"] = debitAccountNum.FundCode; ndr["DeptID"] = debitAccountNum.DeptID; ndr["ProgramCode"] = debitAccountNum.ProgramCode; ndr["Class"] = debitAccountNum.Class; ndr["ProjectGrant"] = debitAccountNum.ProjectGrant; ndr["VendorID"] = "0000456136"; ndr["InvoiceDate"] = EndPeriod.AddMonths(-1).ToString("yyyy/MM/dd"); ndr["InvoiceID"] = $"{ReportSettings.CompanyName} Room Charge"; ndr["Uniqname"] = dtClient.Rows.Find(sdr.Field <int>("ClientID"))["UserName"]; ndr["DepartmentalReferenceNumber"] = depRefNum; ndr["ItemDescription"] = GetItemDesc(sdr, dtClient, dtBillingType); ndr["QuantityVouchered"] = "1.0000"; double chargeAmount = Math.Round(sdr.Field <double>("TotalCalcCost"), 5); ndr["UnitOfMeasure"] = chargeAmount; ndr["MerchandiseAmount"] = Math.Round(chargeAmount, 2); ndr["CreditAccount"] = creditAccount; //Used to calculate the total credit amount fTotal += chargeAmount; dt.Rows.Add(ndr); } } } } //Summary row summaryUnit.CardType = 1; summaryUnit.ShortCode = creditAccountShortCode; summaryUnit.Account = creditAccount.Substring(0, 6); summaryUnit.FundCode = creditAccount.Substring(6, 5); summaryUnit.DeptID = creditAccount.Substring(11, 6); summaryUnit.ProgramCode = creditAccount.Substring(17, 5); summaryUnit.ClassName = creditAccount.Substring(22, 5); summaryUnit.ProjectGrant = creditAccount.Substring(27, 7); summaryUnit.InvoiceDate = EndPeriod.AddMonths(-1).ToString("yyyy/MM/dd"); summaryUnit.Uniqname = ReportSettings.FinancialManagerUserName; summaryUnit.DepartmentalReferenceNumber = depRefNum; summaryUnit.ItemDescription = ReportSettings.FinancialManagerUserName; summaryUnit.MerchandiseAmount = Math.Round(-fTotal, 2); summaryUnit.CreditAccount = creditAccount; //Clean things up manually might help performance in general dtRoomDB.Clear(); dtClient.Clear(); dtAccount.Clear(); }
//public static string GenerateInvoiceExcelReport(DateTime startPeriod, DateTime endPeriod, int clientId, bool showRemote, ExternalInvoiceHeader orgItem, string subFolder, bool deleteWorkDir, ref string alert) //{ // ExternalInvoiceManager mgr = new ExternalInvoiceManager(orgItem.AccountID, startPeriod, endPeriod, showRemote); // string result = GenerateInvoiceExcelReport(mgr, clientId, orgItem, subFolder, deleteWorkDir, ref alert); // return result; //} public static string MakeSpreadSheet(int accountId, string invoiceNumber, string deptRef, string orgName, int currentUserClientId, DateTime startPeriod, DateTime endPeriod) { var dtAddress = DataCommand.Create() .Param("Action", "ByAccount") .Param("AccountID", accountId) .FillDataTable("dbo.Address_Select"); // get client data // using All is hackish. It was ByOrg, but this caused a problem with remote users // the other option is to select for each client, but that is probably even less efficient var dtClient = DataCommand.Create() .Param("Action", "All") .Param("sDate", startPeriod) .Param("eDate", endPeriod) .FillDataTable("dbo.Client_Select"); dtClient.PrimaryKey = new[] { dtClient.Columns["ClientID"] }; // NOTE: all reports here are for external users DataRow drUsage; DataTable dtUsage = new DataTable(); dtUsage.Columns.Add("Descrip", typeof(string)); dtUsage.Columns.Add("Quantity", typeof(double)); dtUsage.Columns.Add("Cost", typeof(double)); DataRow cdr; DataTable dtAggCost; string[] costType = { "Room", "StoreInv", "Tool", "Misc" }; Compile mCompile = new Compile(); DataTable dtClientWithCharges; double capCost; object temp; double totalCharges; //2009-01 this for loop will loop through different Cost types, so when added code for each specific type, remember to distinguish each CostType for (int i = 0; i < costType.Length; i++) { dtAggCost = mCompile.CalcCost(costType[i], string.Empty, "AccountID", accountId, startPeriod, 0, 0, Compile.AggType.CliAcct); //dtAggCost is the main table that contains chargeable items //0 ClientID //1 AccountID //2 RoomID //3 TotalCalcCost //4 TotalEntries //5 TotalHours //Only Room costtype will execute the code below if (costType[i] == "Room") { //******** The code below handles the cost of NAP rooms, because at this point, all NAP rooms access data have total cost of zero**** //Get all active NAP Rooms with their costs, all chargetypes are returned DataTable dtNAPRoomForAllChargeType = RoomManager.GetAllNAPRoomsWithCosts(startPeriod); //filter out the chargetype so that we only have Internal costs with each NAP room DataRow[] dtdrsNAPRoomForExternal = dtNAPRoomForAllChargeType.Select(string.Format("ChargeTypeID = {0}", AccountDA.GetChargeType(accountId))); //Loop through each room and find out this specified month's apportionment data. foreach (DataRow dr1 in dtdrsNAPRoomForExternal) { DataTable dtApportionData = RoomApportionDataManager.GetNAPRoomApportionDataByPeriod(startPeriod, endPeriod, dr1.Field <int>("RoomID")); foreach (DataRow dr2 in dtApportionData.Rows) { DataRow[] drs = dtAggCost.Select(String.Format("ClientID = {0} AND AccountID = {1} AND RoomID = {2}", dr2["ClientID"], dr2["AccountID"], dr2["RoomID"])); if (drs.Length == 1) { //2008-06-19 Sandrine requested all monthly room should have charge of the same across all organizations //so if a guy works for two diferent companies, he should be charged full amount for both companeis on all monthly rooms. //the only exception is when the apportionment percentage is 0 for this organization. When it's 0 percent, we simply //cannot charge this organizaiton at all if (dr2.Field <double>("Percentage") > 0) { drs[0]["TotalCalcCost"] = dr1["RoomCost"]; } } } } //2009-01 remember not to charge clean/chem room usage for less than x amount of minutes int cleanRoomMinMinutes = int.Parse(ConfigurationManager.AppSettings["CleanRoomMinTimeMinute"]); int chemRoomMinMinutes = int.Parse(ConfigurationManager.AppSettings["ChemRoomMinTimeMinute"]); //we simply set totalCalcCost to 0.0 at this point, then those 0.0 charges items will not be published to excel report foreach (DataRow drAggCost in dtAggCost.Rows) { if (drAggCost.Field <LabRoom>("RoomID") == LabRoom.CleanRoom) { if (drAggCost.Field <double>("TotalHours") < cleanRoomMinMinutes / 60) { drAggCost.SetField("TotalCalcCost", 0.0); } } else if (drAggCost.Field <LabRoom>("RoomID") == LabRoom.ChemRoom) { if (drAggCost.Field <double>("TotalHours") < chemRoomMinMinutes / 60) { drAggCost.SetField("TotalCalcCost", 0.0); } } } } if (costType[i] != "Misc") { dtClientWithCharges = mCompile.GetTable(1); capCost = mCompile.CapCost; foreach (DataRow drCWC in dtClientWithCharges.Rows) { temp = dtAggCost.Compute("SUM(TotalCalcCost)", string.Format("ClientID = {0}", drCWC["ClientID"])); if (temp == null || temp == DBNull.Value) { totalCharges = 0.0; } else { totalCharges = Convert.ToDouble(temp); } //BUG FIX: I have to exclude StoreInv charge here since the CapCost for it is always 0 if (totalCharges > capCost && costType[i] != "StoreInv") { DataRow[] fdr = dtAggCost.Select(string.Format("ClientID = {0}", drCWC["ClientID"])); for (int j = 0; j < fdr.Length; j++) { fdr[j].SetField("TotalCalcCost", fdr[j].Field <double>("TotalCalcCost") * capCost / totalCharges); } } } } foreach (DataRow drAggCost in dtAggCost.Rows) { cdr = dtClient.Rows.Find(drAggCost.Field <int>("ClientID")); drUsage = dtUsage.NewRow(); if (costType[i] == "Misc") { drUsage["Descrip"] = drAggCost["Description"]; drUsage["Quantity"] = drAggCost["Quantity"]; drUsage["Cost"] = drAggCost["UnitCost"]; } else { drUsage["Descrip"] = string.Format("{0} usage for {1}. {2}", costType[i].Substring(0, 5), cdr["FName"].ToString().Substring(0, 1), cdr["LName"]); drUsage["Quantity"] = 1; drUsage["Cost"] = drAggCost["TotalCalcCost"]; } dtUsage.Rows.Add(drUsage); } } // Write to excel using (var mgr = NewExcelManager()) { string fileName = Utility.GetRequiredAppSetting("Invoice_Template"); mgr.OpenWorkbook(GetTemplatePath(fileName)); mgr.SetActiveWorksheet("Invoice"); // show invoice date mgr.SetCellTextValue("F4", DateTime.Now.ToShortDateString()); int startRow; int useRow = 0; foreach (DataRow drAddr in dtAddress.Rows) { if (drAddr["AddrType"].ToString() == "Billing") { startRow = 7; } else { startRow = 13; } FillField(mgr, "C", startRow, orgName, ref useRow); FillField(mgr, "C", 0, drAddr.Field <string>("InternalAddress"), ref useRow); FillField(mgr, "C", 0, drAddr.Field <string>("StrAddress1"), ref useRow); FillField(mgr, "C", 0, drAddr.Field <string>("StrAddress2"), ref useRow); FillField(mgr, "C", 0, drAddr.Field <string>("City") + ", " + drAddr.Field <string>("State") + " " + drAddr.Field <string>("Zip"), ref useRow); } // invoice number that needs to be entered mgr.SetCellTextValue("E12", invoiceNumber); mgr.SetCellTextValue("I14", deptRef); int rowRef = 21; string rowCell; // now print charges foreach (DataRow dr in dtUsage.Rows) { if (dr.Field <double>("Cost") != 0) { rowCell = "C" + rowRef.ToString(); mgr.SetCellTextValue(rowCell, startPeriod.ToString("MM/yyyy")); rowCell = "D" + rowRef.ToString(); mgr.SetCellTextValue(rowCell, dr["Descrip"]); rowCell = "H" + rowRef.ToString(); mgr.SetCellNumberValue(rowCell, dr["Quantity"]); rowCell = "I" + rowRef.ToString(); mgr.SetCellNumberValue(rowCell, dr["Cost"]); rowRef += 1; } } string workFilePath = Path.Combine(GetWorkPath(currentUserClientId), orgName + Path.GetExtension(fileName)); mgr.SaveAs(workFilePath); return(workFilePath); } }
public bool ValidateAnewAccountAndSendToDA(Accounts accounts) { if (accounts.AID == " ") { this.Message = "ID IS INCORRECT"; return(false); } else { if (accounts.AdmissonFee == " ") { this.Message = "Admission is Fee"; return(false); } else { if (accounts.LibraryFee == " ") { this.Message = "Library is Incorrect"; return(false); } else { if (accounts.LabratoreyFee == " ") { this.Message = "LabretoryFee is Invalid"; return(false); } else { if (accounts.LibraryFee == " ") { this.Message = "LibraryFee is Invalid"; return(false); } else { if (accounts.SemisterFee == " ") { this.Message = "Semister is Overlaped"; return(false); } else { if (accounts.TotalPaid == " ") { this.Message = "TotalPaid is Overlaped"; return(false); } else { if (accounts.TransPortFee == " ") { this.Message = "TransportFee is Invalid"; return(false); } else { if (accounts.TutionFee == "") { this.Message = "Tution Fee is Invalid"; return(false); } else { if (accounts.Waiver == " ") { this.Message = "Waiver Is Invalid"; return(false); } else { if (accounts.ExtraCarriculamFee == " ") { this.Message = "ExtraCurriCUlamFee is Incorrect"; return(false); } else { if (accounts.Due == " ") { this.Message = "Due Is Not Found"; return(false); } else { AccountDA AccountDAOBJ = new AccountDA(); bool result = AccountDAOBJ.SaveANewAccountToDB(accounts); return(result); } } } } } } } } } } } } }
protected override void FillDataTable(DataTable dt) { BillingUnit summaryUnit1 = summaryUnits[0]; BillingUnit summaryUnit2 = summaryUnits[1]; Compile mCompile = new Compile(); //Get Cleints who order items in store in the Period with Credit and Debit and TotalCost calculated DataTable dtStoreDB = mCompile.CalcCost("StoreJE", string.Empty, string.Empty, 0, EndPeriod.AddMonths(-1), 0, 0, Compile.AggType.CliAcct); //Return dtStoreDB //DataTable dtStore = new DataTable(); //BuildDataTable(dtStore); DataTable dtClient = ClientDA.GetAllClient(StartPeriod, EndPeriod); DataTable dtAccount = AccountDA.GetAllInternalAccount(StartPeriod, EndPeriod); DataTable dtClientAccount = ClientDA.GetAllClientAccountWithManagerName(StartPeriod, EndPeriod); //used to find out manager's name //Get the general lab account ID and lab credit account ID GlobalCost gc = GlobalCostDA.GetGlobalCost(); //For performance issue, we have to calculate something first, since it's used on all rows string depRefNum = string.Empty; double fTotal = 0; string lastCreditAccount = "default"; string creditAccount = string.Empty; string creditAccountShortCode = string.Empty; //we also have to show those credit accounts' shortcodes string lastCreditAccountShortCode = string.Empty; //we need this, just like we need 'LastCreditAccount' to track the changes AccountNumber creditAccountNum; DataView dv = dtStoreDB.DefaultView; dv.Sort = "CreditAccountID"; //This for loop will loop through each transaction record and create SUB record on every transactional record foreach (DataRowView sdr in dv) { //do not show an item if the charge and xcharge accounts are the 'same' - can only happen for 941975 if (!(Convert.ToInt32(sdr["DebitAccountID"]) == gc.LabAccountID && Convert.ToInt32(sdr["CreditAccountID"]) == gc.LabCreditAccountID)) { DataRow ndr = dt.NewRow(); DataRow drAccount = dtAccount.Rows.Find(Convert.ToInt32(sdr["DebitAccountID"])); string debitAccount = string.Empty; string shortCode = string.Empty; if (drAccount == null) { debitAccount = string.Format("unknown_{0}", sdr["DebitAccountID"]); shortCode = string.Format("unknown_{0}", sdr["DebitAccountID"]); } else { debitAccount = drAccount["Number"].ToString(); shortCode = drAccount["ShortCode"].ToString(); } //get manager's name DataRow[] drClientAccount = dtClientAccount.Select(string.Format("AccountID = {0}", sdr["DebitAccountID"])); if (drClientAccount.Length > 0) { depRefNum = drClientAccount[0]["ManagerName"].ToString(); } else { depRefNum = "No Manager Found"; } ndr["CardType"] = 1; ndr["ShortCode"] = shortCode; AccountNumber debitAccountNum = AccountNumber.Parse(debitAccount); ndr["Account"] = debitAccountNum.Account; ndr["FundCode"] = debitAccountNum.FundCode; ndr["DeptID"] = debitAccountNum.DeptID; ndr["ProgramCode"] = debitAccountNum.ProgramCode; ndr["Class"] = debitAccountNum.Class; ndr["ProjectGrant"] = debitAccountNum.ProjectGrant; ndr["InvoiceDate"] = StartPeriod.ToString("yyyy/MM/dd"); ndr["InvoiceID"] = $"{ReportSettings.CompanyName} Store Charge"; ndr["Uniqname"] = dtClient.Rows.Find(Convert.ToInt32(sdr["ClientID"]))["UserName"]; ndr["DepartmentalReferenceNumber"] = depRefNum; ndr["ItemDescription"] = dtClient.Rows.Find(Convert.ToInt32(sdr["ClientID"]))["DisplayName"].ToString().Substring(0, 30); ndr["QuantityVouchered"] = "1.0000"; double chargeAmount = Math.Round(Convert.ToDouble(sdr["TotalCalcCost"]), 5); ndr["UnitOfMeasure"] = chargeAmount; ndr["MerchandiseAmount"] = Math.Round(chargeAmount, 2); creditAccount = dtAccount.Rows.Find(Convert.ToInt32(sdr["CreditAccountID"]))["Number"].ToString(); ndr["CreditAccount"] = creditAccount; //2008-10-09 Depend on credit account, we have different vendor ID creditAccountNum = AccountNumber.Parse(creditAccount); if (creditAccountNum.ProjectGrant == "U023440") { ndr["VendorID"] = "0000456136"; } else { ndr["VendorID"] = "0000456133"; } //Used to calculate the total credit amount fTotal += chargeAmount; //2008-10-08 We have to find out the shortcode for the credit account as well, requested by Sandrine creditAccountShortCode = dtAccount.Rows.Find(Convert.ToInt32(sdr["CreditAccountID"]))["ShortCode"].ToString(); if (creditAccount != lastCreditAccount && lastCreditAccount != "default") { //Summary row fTotal -= chargeAmount; //we have to deduct the charge amount again because its no longer belong to this group AccountNumber lastCreditAccountNum = AccountNumber.Parse(lastCreditAccount); summaryUnit2.CardType = 1; summaryUnit2.ShortCode = lastCreditAccountShortCode; summaryUnit2.Account = lastCreditAccountNum.Account; summaryUnit2.FundCode = lastCreditAccountNum.FundCode; summaryUnit2.DeptID = lastCreditAccountNum.DeptID; summaryUnit2.ProgramCode = lastCreditAccountNum.ProgramCode; summaryUnit2.ClassName = lastCreditAccountNum.Class; summaryUnit2.ProjectGrant = lastCreditAccountNum.ProjectGrant; summaryUnit2.InvoiceDate = EndPeriod.AddMonths(-1).ToString("yyyy/MM/dd"); summaryUnit2.Uniqname = "CreditAccount"; summaryUnit2.DepartmentalReferenceNumber = depRefNum; summaryUnit2.ItemDescription = "CreditAccount"; summaryUnit2.MerchandiseAmount = Math.Round(-fTotal, 2); summaryUnit2.CreditAccount = creditAccount; fTotal = chargeAmount; //add the chargeamount back, because we have new group } lastCreditAccount = creditAccount; lastCreditAccountShortCode = creditAccountShortCode; dt.Rows.Add(ndr); } } //Summary row creditAccountNum = AccountNumber.Parse(creditAccount); summaryUnit1.CardType = 1; summaryUnit1.ShortCode = creditAccountShortCode; summaryUnit1.Account = creditAccountNum.Account; summaryUnit1.FundCode = creditAccountNum.FundCode; summaryUnit1.DeptID = creditAccountNum.DeptID; summaryUnit1.ProgramCode = creditAccountNum.ProgramCode; summaryUnit1.ClassName = creditAccountNum.Class; summaryUnit1.ProjectGrant = creditAccountNum.ProjectGrant; summaryUnit1.InvoiceDate = EndPeriod.AddMonths(-1).ToString("yyyy/MM/dd"); summaryUnit1.Uniqname = "CreditAccount"; summaryUnit1.DepartmentalReferenceNumber = depRefNum; summaryUnit1.ItemDescription = "CreditAccount"; summaryUnit1.MerchandiseAmount = Math.Round(-fTotal, 2); summaryUnit1.CreditAccount = creditAccount; //Clean things up manually might help performance in general dtStoreDB.Clear(); dtClient.Clear(); dtAccount.Clear(); }
private IEnumerable <OrganizationReportItem> GetOrganizationReport(int year, int month, int orgId) { var dt = AccountDA.GetAccountDetailsByOrgID(year, month, orgId); return(GetOrganizationReportItems(dt)); }
protected override void FillDataTable(DataTable dt) { BillingUnit summaryUnit = summaryUnits.First(); Compile mCompile = new Compile(); DataTable dtToolDB = mCompile.CalcCost("Tool", string.Empty, "ChargeTypeID", 5, EndPeriod.AddMonths(-1), 0, 0, Compile.AggType.CliAcct); DataTable dtClientWithCharges = mCompile.GetTable(1); double toolCapCost = mCompile.CapCost; // cap costs - capping is per ClientOrg, thus apportion capping across charges // note that this assumes that there is only one org for internal academic!!! object temp; double totalToolCharges; foreach (DataRow drCWC in dtClientWithCharges.Rows) { temp = dtToolDB.Compute("SUM(TotalCalcCost)", string.Format("ClientID = {0}", drCWC["ClientID"])); if (temp == null || temp == DBNull.Value) { totalToolCharges = 0; } else { totalToolCharges = Convert.ToDouble(temp); } if (totalToolCharges > toolCapCost) { DataRow[] fdr = dtToolDB.Select(string.Format("ClientID = {0}", drCWC["ClientID"])); for (int i = 0; i < fdr.Length; i++) { fdr[i].SetField("TotalCalcCost", fdr[i].Field <double>("TotalCalcCost") * toolCapCost / totalToolCharges); } } } DataTable dtClient = ClientDA.GetAllClient(StartPeriod, EndPeriod); DataTable dtAccount = AccountDA.GetAllInternalAccount(StartPeriod, EndPeriod); DataTable dtClientAccount = ClientDA.GetAllClientAccountWithManagerName(StartPeriod, EndPeriod); //used to find out manager's name DataTable dtBillingType = BillingTypeDA.GetAllBillingTypes(); //Get the general lab account ID and lab credit account ID GlobalCost gc = GlobalCostDA.GetGlobalCost(); //For performance issue, we have to calculate something first, since it's used on all rows string depRefNum = string.Empty; double fTotal = 0; string creditAccount = dtAccount.Rows.Find(gc.LabCreditAccountID)["Number"].ToString(); string creditAccountShortCode = dtAccount.Rows.Find(gc.LabCreditAccountID)["ShortCode"].ToString(); //Do not show an item if the charge and xcharge accounts are the 'same' - can only happen for 941975 //Do not show items that are associated with specific accounts - need to allow users to add manually here in future foreach (DataRow sdr in dtToolDB.Rows) { if (sdr.Field <double>("TotalCalcCost") > 0) { var excludedAccounts = new[] { gc.LabAccountID, 143, 179, 188 }; if (!excludedAccounts.Contains(sdr.Field <int>("AccountID")) && sdr.Field <int>("BillingType") != BillingTypes.Other) { DataRow ndr = dt.NewRow(); DataRow drAccount = dtAccount.Rows.Find(sdr.Field <int>("AccountID")); string debitAccount = drAccount["Number"].ToString(); string shortCode = drAccount["ShortCode"].ToString(); //get manager's name DataRow[] drClientAccount = dtClientAccount.Select(string.Format("AccountID = {0}", sdr["AccountID"])); if (drClientAccount.Length > 0) { depRefNum = drClientAccount.First()["ManagerName"].ToString(); } else { depRefNum = "No Manager Found"; } AccountNumber debitAccountNum = AccountNumber.Parse(debitAccount); ndr["CardType"] = 1; ndr["ShortCode"] = shortCode; ndr["Account"] = debitAccountNum.Account; ndr["FundCode"] = debitAccountNum.FundCode; ndr["DeptID"] = debitAccountNum.DeptID; ndr["ProgramCode"] = debitAccountNum.ProgramCode; ndr["Class"] = debitAccountNum.Class; ndr["ProjectGrant"] = debitAccountNum.ProjectGrant; ndr["VendorID"] = "0000456136"; ndr["InvoiceDate"] = EndPeriod.AddMonths(-1).ToString("yyyy/MM/dd"); ndr["InvoiceID"] = $"{ReportSettings.CompanyName} Tool Charge"; ndr["Uniqname"] = dtClient.Rows.Find(sdr.Field <int>("ClientID"))["UserName"]; ndr["DepartmentalReferenceNumber"] = depRefNum; ndr["ItemDescription"] = GetItemDesc(sdr, dtClient, dtBillingType); ndr["QuantityVouchered"] = "1.0000"; double chargeAmount = Math.Round(sdr.Field <double>("TotalCalcCost"), 5); ndr["UnitOfMeasure"] = chargeAmount.ToString(); ndr["MerchandiseAmount"] = Math.Round(chargeAmount, 2).ToString(); ndr["CreditAccount"] = creditAccount; //Used to calculate the total credit amount fTotal += chargeAmount; dt.Rows.Add(ndr); } } } //Summary row AccountNumber creditAccountNum = AccountNumber.Parse(creditAccount); summaryUnit.CardType = 1; summaryUnit.ShortCode = creditAccountShortCode; summaryUnit.Account = creditAccountNum.Account; summaryUnit.FundCode = creditAccountNum.FundCode; summaryUnit.DeptID = creditAccountNum.DeptID; summaryUnit.ProgramCode = creditAccountNum.ProgramCode; summaryUnit.ClassName = creditAccountNum.Class; summaryUnit.ProjectGrant = creditAccountNum.ProjectGrant; summaryUnit.InvoiceDate = EndPeriod.AddMonths(-1).ToString("yyyy/MM/dd"); summaryUnit.Uniqname = ReportSettings.FinancialManagerUserName; summaryUnit.DepartmentalReferenceNumber = depRefNum; summaryUnit.ItemDescription = ReportSettings.FinancialManagerUserName; summaryUnit.MerchandiseAmount = Math.Round(-fTotal, 2); summaryUnit.CreditAccount = creditAccount; //Clean things up manually might help performance in general dtToolDB.Clear(); dtClient.Clear(); dtAccount.Clear(); }