Example #1
0
 public Insurance(InsuranceCategory inssuranceCategory, Client client, string insuranceNo, DateTime activeFrom, DateTime activeTill, decimal insuranceSum, decimal insuranceCost, decimal reuirementDays, string responsible)
 {
     InssuranceCategory = inssuranceCategory;
     Client = client;
     InsuranceNo = insuranceNo;
     ActiveFrom = activeFrom;
     ActiveTill = activeTill;
     InsuranceSum = insuranceSum;
     InsuranceCost = insuranceCost;
     ReuirementDays = reuirementDays;
     Responsible = responsible;
 }
Example #2
0
        public void GenerateExcel(Client client)
        {
            var newFile = new FileInfo(Resources.StoragePath + "report " + client + " "  + DateTime.Now.ToString("yyyy-MM-dd hh-mm-ss") + ".xlsx");

            var pck = new ExcelPackage(newFile);
            //Add the Content sheet
            var ws = pck.Workbook.Worksheets.Add("Content");
            var insurances =
                _insuranceService.GetAll().FindAll(insurance => insurance.Client.ToString().Equals(client.ToString()));

            ws.Cells["A1"].Value = "Client";
            ws.Cells["B1"].Value = client.ToString();
            ws.Cells["A2"].Value = "Insurance No";
            ws.Cells["B2"].Value = "Insurance category";
            ws.Cells["C2"].Value = "Active from";
            ws.Cells["D2"].Value = "Active till";
            ws.Cells["E2"].Value = "Sum";
            ws.Cells["F2"].Value = "Cost";
            ws.Cells["G2"].Value = "Requirement days";
            ws.Cells["H2"].Value = "Responsible";
            ws.Cells["A2:H2"].Style.Font.Bold = true;
            var currentRaw = 2;
            foreach (var insurance in insurances)
            {
                currentRaw++;
                ws.Cells["A" + currentRaw].Value = insurance.InsuranceNo;
                ws.Cells["B" + currentRaw].Value = insurance.InssuranceCategory;
                ws.Cells["C" + currentRaw].Value = insurance.ActiveFrom.ToString("dd:MM:yyyy");
                ws.Cells["D" + currentRaw].Value = insurance.ActiveTill.ToString("dd:MM:yyyy");
                ws.Cells["E" + currentRaw].Value = insurance.InsuranceSum;
                ws.Cells["F" + currentRaw].Value = insurance.InsuranceCost;
                ws.Cells["G" + currentRaw].Value = insurance.ReuirementDays;
                ws.Cells["H" + currentRaw].Value = insurance.Responsible;
            }
            pck.Save();
        }