Example #1
0
 public ActionResult GenerateInvoice(string Id)
 {
     InvoiceViewModel invoiceModel = new InvoiceViewModel();
     invoiceModel.Customer = new CustomerModel();
     invoiceModel.FromDate = DateTime.Now;
     invoiceModel.ToDate = DateTime.Now;
     invoiceModel.InvoiceDate = DateTime.Now;
     if (!string.IsNullOrEmpty(Id))
     {
         BCBSClient client = new BCBSClient();
         string CustomerData = client.GetcustomerById(Convert.ToInt64(Id));
         if (!string.IsNullOrEmpty(CustomerData))
         {
             CustomerModel Customer = new CustomerModel();
             Customer = JsonConvert.DeserializeObject<CustomerModel>(CustomerData);
             if (Customer != null)
             {
                 invoiceModel.Customer = Customer;
             }
         }
     }
     return PartialView(invoiceModel);
 }
Example #2
0
 public ActionResult Edit(CustomerModel Customer)
 {
     if (ModelState.IsValid)
     {
         BCBSClient client = new BCBSClient();
         long Id = 0;
         Id = client.UpdatecustomerById(Customer.Id, Customer.Name, Customer.ChargeCode, Customer.CustomerType, Customer.CustomerAddress, Customer.City,
             Customer.PostalCode, Customer.State, Customer.Country, Customer.FirstName, Customer.LastName, Customer.Phone, Customer.Fax,
             Customer.Occupation, Customer.Email, Customer.Status);
         if (Id > 0)
         {
             TempData["Message"] = "Customer Updated successfully..!";
         }
         else
         {
             TempData["Error"] = "Customer Update failed..!";
         }
         ModelState.Clear();
         return RedirectToAction("Index", "Customer");
     }
     else
     {
         return View(Customer);
     }
 }
Example #3
0
        public string CreateAcknowledgementExcel(AcknowledgementModel avm, string fileName, string removedProjects, string removedServices)
        {
            string path = Path.Combine(Server.MapPath("~/UploadDocuments/Acknowledgements"));
            DirectoryInfo d = new DirectoryInfo(@path);
            if (d.Exists)
            {
                FileInfo newFile = new FileInfo(d.FullName + @"\" + fileName + ".xlsx");
                if (newFile.Exists)
                {
                    newFile.Delete();  // ensures we create a new workbook
                    newFile = new FileInfo(d.FullName + @"\" + fileName + ".xlsx");
                }
                using (ExcelPackage package = new ExcelPackage(newFile))
                {
                    // add a new worksheet to the empty workbook
                    string titleHeader = string.Empty;
                    titleHeader = "BILLING ACKNOWLEDGEMENT FORM";

                    ExcelWorksheet worksheet = package.Workbook.Worksheets.Add(titleHeader);
                    string imagepath = Path.Combine(Server.MapPath("~/Images/"), "bcbs-excel.png");
                    Image logo = Image.FromFile(imagepath);
                    int a = 1;
                    //worksheet.Row(a * 5).Height = 39.00D;
                    var picture = worksheet.Drawings.AddPicture(a.ToString(), logo);
                    picture.From.Column = 6;
                    picture.From.Row = a;
                    picture.SetSize(130, 100);
                    //Add the headers
                    worksheet.Column(1).Width = 5;
                    worksheet.Column(2).Width = 10;
                    worksheet.Column(3).Width = 10;
                    worksheet.Column(4).Width = 10;
                    worksheet.Column(5).Width = 10;
                    worksheet.Column(6).Width = 10;
                    CustomerModel customer = new CustomerModel();
                    BCBSClient client = new BCBSClient();
                    customer = JsonConvert.DeserializeObject<CustomerModel>(client.GetcustomerById(avm.CustomerId));
                    worksheet.Cells["B1"].Value = titleHeader;
                    worksheet.Cells["B3"].Value = "PLAN/ORGANIZATION:";
                    worksheet.Cells["c3"].Value = customer.Name;
                    worksheet.Cells["C3"].Style.Border.BorderAround(ExcelBorderStyle.Medium, Color.Black);
                    //worksheet.Cells["F4"].Value = "(will be provided by Finance)";

                    worksheet.Cells["B5"].Value = "ATTENTION:";
                    worksheet.Cells["C5"].Value = customer.FirstName + " " + customer.LastName;
                    worksheet.Cells["C5"].Style.Border.BorderAround(ExcelBorderStyle.Medium, Color.Black);

                    worksheet.Cells["B7"].Value = "ADDRESS:";
                    worksheet.Cells["C7"].Value = customer.CustomerAddress;
                    //worksheet.Cells["C7"].Style.Border.BorderAround(ExcelBorderStyle.Medium, Color.Black);
                    worksheet.Cells["C8"].Value = customer.City;
                    //worksheet.Cells["C8"].Style.Border.BorderAround(ExcelBorderStyle.Medium, Color.Black);

                    worksheet.Cells["C9"].Value = customer.State + " " + customer.Country + " " + customer.PostalCode;
                    //worksheet.Cells["C9"].Style.Border.BorderAround(ExcelBorderStyle.Medium, Color.Black);

                    int last = 11;
                    int tableinit = 11;
                    int tableend = 0;

                    for (int i = 0; i < avm.Projects.Count(); i++)
                    {
                        List<string> removedProjectList = new List<string>();
                        if (!string.IsNullOrEmpty(removedProjects))
                        {
                            removedProjectList = removedProjects.Split(',').ToList();
                        }
                        if (removedProjectList.Count > 0)
                        {
                            var r = removedProjectList.Where(x => x.Equals(avm.Projects[i].Project.Id + "@" + i));
                            if (r != null)
                            {
                                if (r.Count() > 0)
                                {
                                    continue;
                                }
                            }
                        }
                        last++;
                        worksheet.Cells["B" + last].Value = avm.Projects[i].Project.Name;
                        tableinit = last;
                        int totalinit = 0;
                        int totalend = 0;
                        for (int j = 0; j < avm.Projects[i].Services.Count; j++)
                        {
                            last++;
                            if (j == 0)
                            {
                                worksheet.Cells["C" + last].Value = "Service Name";
                                worksheet.Cells["D" + last].Value = "Volume";
                                worksheet.Cells["E" + last].Value = "Rate";
                                worksheet.Cells["F" + last].Value = "Total";
                                last++;
                                totalinit = last;
                            }
                            List<string> removedServiceList = new List<string>();
                            if (!string.IsNullOrEmpty(removedServices))
                            {
                                removedServiceList = removedServices.Split(',').ToList();
                            }
                            var r = removedServiceList.Where(x => x.Equals(i + "_" + j));
                            if (r != null)
                            {
                                if (r.Count() > 0)
                                {
                                    last--;
                                    continue;
                                }
                            }
                            worksheet.Cells["C" + last].Value = avm.Projects[i].Services[j].Name;
                            worksheet.Cells["D" + last].Value = avm.Projects[i].Services[j].NewVolume;
                            if (avm.Projects[i].Services[j].FeesType == "Transaction")
                            {
                                worksheet.Cells["E" + last].Value = avm.Projects[i].Services[j].Total.ToString("C") + " / " + avm.Projects[i].Services[j].NewVolume + " " + avm.Projects[i].Services[j].FeesType;//avm.Projects[i].Services[j].Volume;
                            }
                            else
                            {
                                worksheet.Cells["E" + last].Value = avm.Projects[i].Services[j].Total.ToString("C") + "/ " + avm.Projects[i].Services[j].FeesType;
                            }
                            worksheet.Cells["F" + last].Value = avm.Projects[i].Services[j].Total;
                            worksheet.Cells["F" + last].Style.Numberformat.Format = "$#,###0.00";
                        }
                        totalend = last;
                        tableend = last;
                        last++;
                        worksheet.Cells["F" + last].Formula = "=SUM(F" + totalinit + ":F" + totalend + ")";
                        worksheet.Cells["F" + last].Calculate();
                        worksheet.Cells["F" + last].Style.Numberformat.Format = "$#,###0.00";
                        last++;
                        using (var range = worksheet.Cells[tableinit, 2, tableend, 6])
                        {
                            range.Style.Border.BorderAround(ExcelBorderStyle.Medium, Color.Black);
                        }
                    }
                    package.Save();
                }
                return newFile.Name;
            }
            else
            {
                return null;
            }
        }
Example #4
0
 public ActionResult Edit(long id)
 {
     CustomerModel Customer = new CustomerModel();
     if (id > 0)
     {
         BCBSClient client = new BCBSClient();
         string CustomerData = client.GetcustomerById(id);
         if (!string.IsNullOrEmpty(CustomerData))
         {
             Customer = JsonConvert.DeserializeObject<CustomerModel>(CustomerData);
         }
         else
         {
             TempData["Error"] = "Requested customer not available!!";
             return RedirectToAction("Index", "Customer");
         }
     }
     return View(Customer);
 }
Example #5
0
 public ActionResult New()
 {
     CustomerModel customer = new CustomerModel();
     return View(customer);
 }