public ActionResult Edit(long id) { BCBSClient client = new BCBSClient(); string customerlist = client.GetcustomerList(); ContractModel contract = new ContractModel(); contract.FromDate = DateTime.Now; contract.EndDate = DateTime.Now; if (!string.IsNullOrEmpty(customerlist)) { ViewBag.Customers = JsonConvert.DeserializeObject<List<CustomerModel>>(customerlist).Select(x => new { x.Id, x.Name }); } else { ViewBag.Customers = ""; } string projectList = client.GetProjectList(); if (!string.IsNullOrEmpty(projectList)) { ViewBag.Projects = JsonConvert.DeserializeObject<List<ProjectModel>>(projectList).Select(x => new { x.Id, x.Name }); } else { ViewBag.Projects = ""; } if (id > 0) { string ContractData = client.GetcontractById(id); if (!string.IsNullOrEmpty(ContractData)) { contract = JsonConvert.DeserializeObject<ContractModel>(ContractData); string servicelist = client.GetServiceTypesByProjectId(contract.ProjectId); if (!string.IsNullOrEmpty(servicelist)) { ViewBag.Services = JsonConvert.DeserializeObject<List<ServiceModel>>(servicelist).Select(x => new { x.Id, x.Name }); } else { ViewBag.Services = ""; } } else { TempData["Error"] = "Requested contract not available!!"; return RedirectToAction("Index", "Contract"); } } return View(contract); }
public ActionResult NewActivity(string Id) { ActivityModel activity = new ActivityModel(); activity.FromDate = DateTime.Now; activity.EndDate = DateTime.Now; activity.ActivityCode = GenerateUniqueActivityCode(); if (!string.IsNullOrEmpty(Id)) { BCBSClient client = new BCBSClient(); ContractModel contract = new ContractModel(); string result = client.GetcontractById(Convert.ToInt64(Id)); if (!string.IsNullOrEmpty(result)) { contract = JsonConvert.DeserializeObject<ContractModel>(result); activity.ContractCode = contract.ContractCode; } activity.ContractId = Convert.ToInt64(Id); ViewBag.AvailableBalance = client.GetContractAvailableBalance(Convert.ToInt64(Id)); } return View(activity); }
public ActionResult New(ContractModel contract, HttpPostedFileBase file) { if (ModelState.IsValid) { BCBSClient client = new BCBSClient(); long Id = 0; string fname = string.Empty; if (file != null && file.ContentLength > 0) { byte[] imgarray; using (var binaryReader = new BinaryReader(Request.Files[0].InputStream)) { imgarray = binaryReader.ReadBytes(Request.Files[0].ContentLength); string logodata = Convert.ToBase64String(imgarray); string lg = "data:image/*;base64," + logodata; } try { // extract only the fielname var fileName = Path.GetFileName(file.FileName); string ext = Path.GetExtension(file.FileName); Guid g = Guid.NewGuid(); fname = g.ToString() + ext; // store the file inside ~/UploadDocuments/uploads folder var path = Path.Combine(Server.MapPath("~/UploadDocuments/Contracts"), fname); file.SaveAs(path); contract.FileName = fname; } catch (Exception ex) { } } Id = client.Insertcontract(contract.CustomerId, contract.ServiceId, contract.FromDate, contract.EndDate, contract.Dirrection, contract.Estimate, contract.Status, contract.Volume, contract.Amount, contract.ProjectId, contract.Description, contract.ContractCode, contract.FileName,contract.FeesType); if (Id > 0) { TempData["Message"] = "Contract Added successfully..!"; } else { TempData["Error"] = "Contract Adding failed..!"; } ModelState.Clear(); return RedirectToAction("Index", "Contract"); } else { return View(contract); } }
public ActionResult New() { BCBSClient client = new BCBSClient(); string customerlist = client.GetcustomerList(); ContractModel contract = new ContractModel(); contract.FromDate = DateTime.Now; contract.EndDate = DateTime.Now; contract.ContractCode = GenerateUniqueContractCode().ToUpper(); if (!string.IsNullOrEmpty(customerlist)) { ViewBag.Customers = JsonConvert.DeserializeObject<List<CustomerModel>>(customerlist).Select(x => new { x.Id, x.Name }); } else { ViewBag.Customers = ""; } //string servicelist = client.GetServiceTypeList(); //if (!string.IsNullOrEmpty(servicelist)) //{ // ViewBag.Services = JsonConvert.DeserializeObject<List<ServiceModel>>(servicelist).Select(x => new { x.Id, x.Name }); //} //else //{ // ViewBag.Services = ""; //} string projectList = client.GetProjectList(); if (!string.IsNullOrEmpty(projectList)) { ViewBag.Projects = JsonConvert.DeserializeObject<List<ProjectModel>>(projectList).Select(x => new { x.Id, x.Name }); } else { ViewBag.Projects = ""; } return View(contract); }
public ActionResult Edit(ContractModel contract, FormCollection fc) { if (ModelState.IsValid) { BCBSClient client = new BCBSClient(); long Id = 0; string oldDescription = fc["OldDescription"].ToString(); contract.Description += System.Environment.NewLine + System.Environment.NewLine + oldDescription; contract.Description = contract.Description.Replace("'", "''"); Id = client.UpdatecontractById(contract.Id, contract.EndDate, contract.Status, contract.Description); if (Id > 0) { TempData["Message"] = "Contract Updated successfully..!"; } else { TempData["Error"] = "Contract Update failed..!"; } ModelState.Clear(); return RedirectToAction("Index", "Contract"); } else { return View(contract); } }
public ActionResult Invoice(InvoiceViewModel invoiceModel, HttpPostedFileBase file, FormCollection fc) { BCBSClient client = new BCBSClient(); //ModelState.Where(m => m.Key == "CustomerCode").FirstOrDefault().Value.Errors.Clear(); //if (ModelState.IsValid) //{ long Id = 0; string fname = string.Empty; if (file != null && file.ContentLength > 0) { // extract only the fielname var fileName = Path.GetFileName(file.FileName); string ext = Path.GetExtension(file.FileName); Guid g = Guid.NewGuid(); fname = g.ToString() + ext; // store the file inside ~/UploadDocuments/uploads folder var path = Path.Combine(Server.MapPath("~/UploadDocuments/uploads"), fname); file.SaveAs(path); invoiceModel.SupportingDocuments = fname; } //string csv = string.Empty; Id = client.InsertCustomerInvoice(invoiceModel.InvoiceNumber, invoiceModel.CustomerId, invoiceModel.InvoiceDate, invoiceModel.PrepareBy, invoiceModel.PrepareByExt, invoiceModel.AuthorizedBy, invoiceModel.AuthorizedByExt, invoiceModel.Division, invoiceModel.IsDeffered, invoiceModel.DefferedAccount, invoiceModel.FromDate, invoiceModel.ToDate, invoiceModel.SpecialInstuction, invoiceModel.SupportingDocuments, invoiceModel.TotalAmount); if (Id > 0) { //csv += "Invoice Number," + invoiceModel.InvoiceNumber + "\n"; //csv += "Invoice Date," + invoiceModel.InvoiceDate.ToString("MM/dd/yyyy") + "\n"; //csv += "Prepared by," + invoiceModel.PrepareBy + ", Authorized By," + invoiceModel.AuthorizedBy + "\n"; //csv += "Devision," + invoiceModel.Division + "\n\n"; //csv += "Customer Name," + invoiceModel.Customer.Name + "\n"; //csv += "Address\n"; //csv += invoiceModel.Customer.CustomerAddress + " " + invoiceModel.Customer.City + " " + invoiceModel.Customer.State + " " + invoiceModel.Customer.PostalCode + "\n"; //csv += "Contact Name," + invoiceModel.Customer.FirstName + " " + invoiceModel.Customer.LastName + "\n"; //csv += "Phone," + invoiceModel.Customer.Phone + "\n\n"; SBFEmailViewModel sbfemail = new SBFEmailViewModel(); //mailer.SBF(); string fcActivities = fc["Activities"].ToString(); List<string> activities = new List<string>(); if (!string.IsNullOrEmpty(fcActivities)) { bool isbilled = client.SetActivityBilled(fcActivities); if (isbilled) { var activityIds = fcActivities.Split(','); foreach (var x in activityIds) { if (!string.IsNullOrEmpty(x)) { long activityId = Convert.ToInt64(x); long sbfActivityId = client.InsertSBFActivity(Id, activityId); if (sbfActivityId > 0) { activities.Add(activityId.ToString()); continue; } else { break; } } } } } if (activities != null && activities.Count > 0) { string ids = string.Join(",", activities.ToArray()); string result = client.GetActivitiesByActivityIds(ids); List<ActivityListModel> activity = JsonConvert.DeserializeObject<List<ActivityListModel>>(result); if (sbfemail.ActivityList == null) { //csv += "Contract -Activity\n\n"; //csv += "Project Name,Service Type,From Date,End Date,Charges,Value,Amount\n"; sbfemail.ActivityList = new List<ActivityListModel>(); } if (activity != null) { foreach (ActivityListModel x in activity) { string charge = string.Empty; if (x.Charges == true) { charge = "Expense"; } else { charge = "Revenue"; } string estimate = string.Empty; if (x.Estimate == true) { estimate = "Real"; } else { estimate = "Estimate"; } //csv += x.ProjectName + "," + x.Service + "," + x.FromDate.ToString("MM/dd/yyyy") + "," + x.EndDate.ToString("MM/dd/yyyy") + "," + charge + "," + estimate + "," + x.Amount + "\n"; } //csv += ",,,,,Total," + invoiceModel.TotalAmount + "\n\n"; //if (invoiceModel.IsDeffered == true) //{ //csv += "Deffered Account," + invoiceModel.DefferedAccount + "\n"; //} //csv += "From Date," + invoiceModel.FromDate.ToString("MM/dd/yyyy") + ",,End Date," + invoiceModel.ToDate.ToString("MM/dd/yyyy") + "\n"; sbfemail.ActivityList = activity; } } IUserMailer mailer = new UserMailer(); sbfemail.Invoice = invoiceModel; string CustomerData = client.GetcustomerById(invoiceModel.CustomerId); if (!string.IsNullOrEmpty(CustomerData)) { sbfemail.Customer = JsonConvert.DeserializeObject<CustomerModel>(CustomerData); } string ContractData = client.GetcontractById(invoiceModel.ContractId); ContractModel contract = new ContractModel(); if (!string.IsNullOrEmpty(ContractData)) { contract = JsonConvert.DeserializeObject<ContractModel>(ContractData); sbfemail.Contract = contract; } string fileName = "SBF_" + sbfemail.Invoice.InvoiceNumber + "_" + DateTime.Now.ToString("MM_dd_yyyy_HH_mm_ss"); string excelFileName = CreatExcel(sbfemail, fileName); mailer.SBF(sbfemail, file, "SBF Invoice - BCBS Acc Sys").Send(); if (!string.IsNullOrEmpty(excelFileName)) { string path = Path.Combine(Server.MapPath("~/UploadDocuments/uploads/xlsx"), excelFileName); return File(path, "text/csv", excelFileName); } else { TempData["Message"] = "Customer Invoice generated successfully..!"; //string fileName = "SBF_" + invoiceModel.InvoiceNumber + "_" + DateTime.Now.ToString("MM-dd-yyyy"); // return RedirectToAction("Index", "Customer"); } } else { string fullPath = Request.MapPath("~/UploadDocuments/uploads/" + fname); if (System.IO.File.Exists(fullPath)) { System.IO.File.Delete(fullPath); } TempData["Error"] = "Customer Invoice generation failed..!"; return View(invoiceModel); } ModelState.Clear(); //} //else //{ // string customerlist = client.GetcustomerList(); // if (!string.IsNullOrEmpty(customerlist)) // { // ViewBag.Customers = JsonConvert.DeserializeObject<List<CustomerModel>>(customerlist).Select(x => new { x.Id, x.Name }); // } // else // { // ViewBag.Customers = ""; // } // return View(invoiceModel); //} }
public ActionResult SBFEmailView(SBFEmailViewModel sbf) { BCBSClient client = new BCBSClient(); sbf.ActivityList = new List<ActivityListModel>(); string result = client.GetActivitiesByContractIds("23,24"); List<ActivityListModel> activity = JsonConvert.DeserializeObject<List<ActivityListModel>>(result); sbf.ActivityList = activity; string CustomerData = client.GetcustomerById(4); if (!string.IsNullOrEmpty(CustomerData)) { sbf.Customer = JsonConvert.DeserializeObject<CustomerModel>(CustomerData); } InvoiceViewModel ivm = new InvoiceViewModel(); ivm.AuthorizedBy = "Paatrick Egan"; ivm.AuthorizedByExt = "5497"; ivm.ContractId = 12; ivm.CustomerId = 4; ivm.FromDate = DateTime.Now; ivm.ToDate = DateTime.Now.AddDays(2); ivm.TotalAmount = 350.00; sbf.Invoice = ivm; string ContractData = client.GetcontractById(24); ContractModel contract = new ContractModel(); if (!string.IsNullOrEmpty(ContractData)) { contract = JsonConvert.DeserializeObject<ContractModel>(ContractData); sbf.Contract = contract; } return View(sbf); }