Ejemplo n.º 1
0
        private int ExportSalary(string fileName)
        {
            using (StreamWriter sw = File.CreateText(fileName))
            {
                var transferedSalary = payrollRepository.GetTransfered(Store.ActiveMonth, Store.ActiveYear);
                int transferedCount  = transferedSalary.Count();

                decimal grandTotal = 0;

                foreach (var salary in transferedSalary)
                {
                    sw.WriteLine(salary.AccountNumber + "," + salary.GrandTotal
                                 + "," + "GAJI " + Store.GetMonthName(salary.MonthPeriod).ToUpper() + ","
                                 + salary.Employee.EmployeeCode);

                    grandTotal = grandTotal + salary.GrandTotal;
                }

                var transfer = new Transfer();

                transfer.TransferType  = "GAJI";
                transfer.TransferDate  = dtpDate.Value;
                transfer.TotalEmployee = transferedCount;
                transfer.TotalTransfer = grandTotal;

                transferRepository.Save(transfer);

                return(transferedCount);
            }
        }