public JsonResult ApproveAcknowledgement(string ackId) { bool isResult = false; if (!string.IsNullOrEmpty(ackId)) { BCBSClient client = new BCBSClient(); List<CustomerAcknowledgementServicesModel> ackService = new List<CustomerAcknowledgementServicesModel>(); string dataResult = client.GetAcknowledgementServicesbyAcknowledgemetnId(Convert.ToInt64(ackId)); if (!string.IsNullOrEmpty(dataResult)) { ackService = JsonConvert.DeserializeObject<List<CustomerAcknowledgementServicesModel>>(dataResult); } if (ackService.Count > 0) { foreach (CustomerAcknowledgementServicesModel ack in ackService) { string ContractCode = GenerateUniqueContractCode(); long id = client.Insertcontract(ack.CustomerId, ack.ServiceId, ack.FromDate, ack.EndDate, true, false, "Active",ack.Volume, ack.Total, ack.ProjectId, "", ContractCode, "", ack.FeesType); if (id > 0) { isResult = true; } else { break; } } if (isResult == true) { long id = client.AcknowledgementApprove(Convert.ToInt64(ackId)); } } } return Json(isResult, JsonRequestBehavior.AllowGet); }
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 ViewAcknowledgeForm(AcknowledgementModel avm, FormCollection fc) { bool isResult = false; if (avm.Id > 0) { BCBSClient client = new BCBSClient(); List<CustomerAcknowledgementServicesModel> ackService = new List<CustomerAcknowledgementServicesModel>(); string dataResult = client.GetAcknowledgementServicesbyAcknowledgemetnId(Convert.ToInt64(avm.Id)); if (!string.IsNullOrEmpty(dataResult)) { ackService = JsonConvert.DeserializeObject<List<CustomerAcknowledgementServicesModel>>(dataResult); } if (ackService.Count > 0) { foreach (CustomerAcknowledgementServicesModel ack in ackService) { string ContractCode = GenerateUniqueContractCode().ToUpper(); long id = client.Insertcontract(ack.CustomerId, ack.ServiceId, ack.FromDate, ack.EndDate, true, false, "Active", ack.Volume, ack.Total, ack.ProjectId, "", ContractCode, "", ack.FeesType); //long id = client.Insertcontract(ack.CustomerId, ack.ServiceId, ack.FromDate, ack.EndDate, true, false, "Active", "", ack.Total, ack.ProjectId, "", ContractCode, "", ""); if (id > 0) { isResult = true; } else { break; } } if (isResult == true) { long id = client.AcknowledgementApprove(Convert.ToInt64(avm.Id)); TempData["Message"] = "Acknowledgement Approved ! Contract Added Successfully!!"; return RedirectToAction("acknowledgements", "customer"); } 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 = ""; } 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 = ""; } } } } //BCBSClient client = new BCBSClient(); //string removedProjects = fc["RemovedProjects"].ToString(); //string removedServices = fc["RemovedServices"].ToString(); //List<string> removedProjectList = new List<string>(); //if (!string.IsNullOrEmpty(removedProjects)) //{ // removedProjectList = removedProjects.Split(',').ToList(); //} //List<string> removedServiceList = new List<string>(); //if (!string.IsNullOrEmpty(removedServices)) //{ // removedServiceList = removedServices.Split(',').ToList(); //} //long ackid = avm.Id; ////long ackId = client.InsertCustomerAcknoeledgement(avm.CustomerId); //if (ackid > 0) //{ // if (avm.Projects != null) // { // for (int i = 0; i < avm.Projects.Count(); i++) // { // 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; // } // } // } // if (avm.Projects[i].Services != null) // { // for (int j = 0; j < avm.Projects[i].Services.Count; j++) // { // var r = removedServiceList.Where(x => x.Equals(i + "_" + j)); // if (r != null) // { // if (r.Count() > 0) // { // continue; // } // } // long ackserviceId = avm.Projects[i].Services[j].Id; // //long ackServiceId = client.InsertAcknowledgementServices(ackid, avm.Projects[i].Project.Id, avm.Projects[i].Services[j].Id, avm.Projects[i].Services[j].Total, avm.Projects[i].FromDate, avm.Projects[i].EndDate); // } // } // } // string fileName = "Ack_" + DateTime.Now.ToString("MM_dd_yyyy_HH_mm_ss"); // string retunfileName = CreateAcknowledgementExcel(avm, fileName, removedProjects, removedServices); // if (!string.IsNullOrEmpty(retunfileName)) // { // string path = Path.Combine(Server.MapPath("~/UploadDocuments/Acknowledgements"), retunfileName); // //return File(path, "text/csv", retunfileName); // } // else // { // TempData["Message"] = "Customer grand bill generated successfully..!"; // //string fileName = "SBF_" + invoiceModel.InvoiceNumber + "_" + DateTime.Now.ToString("MM-dd-yyyy"); // // // return RedirectToAction("acknowledgements", "customer"); // } // //TempData["Message"] = "Acknowledgement Bill generated successfully.."; // } //} return View(avm); }