public void DownloadApplicationPDF(string applicantId, bool isSupervisor) { ApplicantMaster dbApp; using (context = new NPSSEntities()) { int appId = Convert.ToInt32(applicantId); if (isSupervisor) { dbApp = context.ApplicantMasters.Where(x => x.ApplicantID == appId && x.IsAppliedForSupervisor).FirstOrDefault(); if (dbApp != null && dbApp.ApplicantID > 0) { DownloadPDF(Server.MapPath("~/Report/ApplicantDetail.rdlc"), dbApp.ApplicantID, "true", dbApp); } } else { dbApp = context.ApplicantMasters.Where(x => x.ApplicantID == appId && x.ISAppliedForAsstAO).FirstOrDefault(); if (dbApp != null && dbApp.ApplicantID > 0) { DownloadPDF(Server.MapPath("~/Report/ApplicantDetail.rdlc"), dbApp.ApplicantID, "false", dbApp); } } } }
public void ReportDetail() { List <ApplicantMaster> lstappmaster = new List <ApplicantMaster>(); ApplicantMaster dbApplication; using (context = new NPSSEntities()) { lstappmaster = context.Database.SqlQuery <ApplicantMaster>("SP_GetApplicationDetail " + 1).ToList <ApplicantMaster>(); expdetail = context.Database.SqlQuery <ApplicantExperienceDetailViewModel>("SP_ExpierienceDetail " + 1).ToList <ApplicantExperienceDetailViewModel>(); qualificationdetail = context.Database.SqlQuery <ApplicationQualificationDetail>("SP_QualificationDetail " + 1).ToList <ApplicationQualificationDetail>(); dbApplication = context.ApplicantMasters.Where(x => x.ApplicantID == 1).FirstOrDefault(); } CreatePDF("Form", lstappmaster, Server.MapPath("~/Report/ApplicantDetail.rdlc"), 1, "", "true", dbApplication, dbApplication.SupervisotApplicationID); }
public ActionResult Application(int postSelection = 0) { if (postSelection == 0) { return(RedirectToAction("Index", "Home")); } ViewBag.postSelection = Convert.ToString(postSelection); ApplicationViewModel applicationViewModel = new ApplicationViewModel(); using (context = new DBModel.NPSSEntities()) { applicationViewModel.QualificationTypeList = context.QualificationTypes.ToList(); applicationViewModel.QualificationHeaderList = context.QualificationHeaders.ToList(); } return(View(applicationViewModel)); }
private void DownloadPDF(string reportFileName, int applicantID, string isSuperVisor, ApplicantMaster dbApplication) { List <ApplicantMaster> lstappmaster = new List <ApplicantMaster>(); expdetail = new List <ApplicantExperienceDetailViewModel>(); qualificationdetail = new List <ApplicationQualificationDetail>(); using (context = new NPSSEntities()) { lstappmaster = context.Database.SqlQuery <ApplicantMaster>("SP_GetApplicationDetail " + applicantID).ToList <ApplicantMaster>(); expdetail = context.Database.SqlQuery <ApplicantExperienceDetailViewModel>("SP_ExpierienceDetail " + applicantID).ToList <ApplicantExperienceDetailViewModel>(); qualificationdetail = context.Database.SqlQuery <ApplicationQualificationDetail>("SP_QualificationDetail " + applicantID).ToList <ApplicationQualificationDetail>(); } // Create Report DataSource ReportDataSource rds = new ReportDataSource("DataSet1", lstappmaster); // Variables Warning[] warnings; string[] streamIds; string mimeType = string.Empty; string encoding = string.Empty; string extension = string.Empty; // Setup the report viewer object and get the array of bytes ReportViewer viewer = new ReportViewer(); viewer.ProcessingMode = ProcessingMode.Local; viewer.LocalReport.ReportPath = reportFileName; viewer.LocalReport.SetParameters(new ReportParameter("IsSupervisor", isSuperVisor)); viewer.LocalReport.DataSources.Add(rds); // Add datasource here viewer.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(SetSubDataSource); byte[] bytes = viewer.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings); string fileName = "MSBABD_" + (isSuperVisor == "true" ? "SUPERVISOR_" + lstappmaster[0].SupervisotApplicationID : "AsstAO_" + lstappmaster[0].AsstAOApplicationID); Response.Buffer = true; Response.Clear(); Response.ContentType = mimeType; Response.AddHeader("content-disposition", "attachment; filename=" + fileName + "." + extension); Response.BinaryWrite(bytes); // create the file Response.Flush(); // send it to the client to download }
public void Report(string fileName, int applicantID, string toMail, int postSelection, ApplicantMaster dbApplication) { List <ApplicantMaster> lstappmaster = new List <ApplicantMaster>(); expdetail = new List <ApplicantExperienceDetailViewModel>(); qualificationdetail = new List <ApplicationQualificationDetail>(); using (context = new NPSSEntities()) { lstappmaster = context.Database.SqlQuery <ApplicantMaster>("SP_GetApplicationDetail " + applicantID).ToList <ApplicantMaster>(); if (dbApplication.EmailId != null && dbApplication.EmailId != "") { expdetail = context.Database.SqlQuery <ApplicantExperienceDetailViewModel>("SP_ExpierienceDetail " + applicantID).ToList <ApplicantExperienceDetailViewModel>(); qualificationdetail = context.Database.SqlQuery <ApplicationQualificationDetail>("SP_QualificationDetail " + applicantID).ToList <ApplicationQualificationDetail>(); } } if (postSelection == 1) { if (dbApplication.EmailId != null && dbApplication.EmailId != "") { CreatePDF(fileName, lstappmaster, Server.MapPath("~/Report/ApplicantDetail.rdlc"), applicantID, toMail, "true", dbApplication, lstappmaster.FirstOrDefault().SupervisotApplicationID); } SendSMS(dbApplication, "true", lstappmaster.FirstOrDefault().SupervisotApplicationID); } else if (postSelection == 2) { if (dbApplication.EmailId != null && dbApplication.EmailId != "") { CreatePDF(fileName, lstappmaster, Server.MapPath("~/Report/ApplicantDetail.rdlc"), applicantID, toMail, "false", dbApplication, lstappmaster.FirstOrDefault().AsstAOApplicationID); } SendSMS(dbApplication, "false", lstappmaster.FirstOrDefault().AsstAOApplicationID); } else if (postSelection == 3) { if (dbApplication.EmailId != null && dbApplication.EmailId != "") { CreatePDF(fileName, lstappmaster, Server.MapPath("~/Report/ApplicantDetail.rdlc"), applicantID, toMail, "true", dbApplication, lstappmaster.FirstOrDefault().SupervisotApplicationID); CreatePDF(fileName, lstappmaster, Server.MapPath("~/Report/ApplicantDetail.rdlc"), applicantID, toMail, "false", dbApplication, lstappmaster.FirstOrDefault().AsstAOApplicationID); } SendSMS(dbApplication, "true", lstappmaster.FirstOrDefault().SupervisotApplicationID); SendSMS(dbApplication, "false", lstappmaster.FirstOrDefault().AsstAOApplicationID); } }
public ActionResult ApplicationSuccessful(int applicantID = 0) { string str = Convert.ToString(TempData["key"] == null ? string.Empty : TempData["key"]); ApplicantMaster applicantMaster = new ApplicantMaster(); if (applicantID == 0 || str == "") { return(RedirectToAction("Index", "Home")); } else if (applicantID > 0) { using (context = new DBModel.NPSSEntities()) { applicantMaster = context.ApplicantMasters.Where(x => x.ApplicantID == applicantID).FirstOrDefault(); if (applicantMaster == null) { return(RedirectToAction("Index", "Error")); } } } return(View(applicantMaster)); }
public ActionResult CheckApplicant(string appId, string birthdate, string mobile) { ApplicantMaster dbApp; using (context = new NPSSEntities()) { DateTime birth = Convert.ToDateTime(birthdate); Int64 mobileNo = Convert.ToInt64(mobile); dbApp = context.ApplicantMasters.Where(x => x.AsstAOApplicationID == appId && x.BirthDate == birth && x.MobileNumber == mobileNo).FirstOrDefault(); if (dbApp != null && dbApp.ApplicantID > 0) { return(Json(new { IsSuccess = true, applicantId = dbApp.ApplicantID, isSupervisor = false }, JsonRequestBehavior.AllowGet)); } else { dbApp = context.ApplicantMasters.Where(x => x.SupervisotApplicationID == appId && x.BirthDate == birth && x.MobileNumber == mobileNo).FirstOrDefault(); if (dbApp != null && dbApp.ApplicantID > 0) { return(Json(new { IsSuccess = true, applicantId = dbApp.ApplicantID, isSupervisor = true }, JsonRequestBehavior.AllowGet)); } } } return(Json(new { IsSuccess = false }, JsonRequestBehavior.AllowGet)); }
public JsonResult Application(ApplicationViewModel objApplication) { int ApplicantID = 0; bool IsDuplicateFlag = false; string ApplicationNumber = string.Empty; try { byte[] photo = (byte[])TempData["Photo"]; byte[] signBytes = (byte[])TempData["Signature"]; using (context = new DBModel.NPSSEntities()) { if (objApplication != null) { var isDuplicated = context.ApplicantMasters.Where(x => x.Surname == objApplication.Surname && x.FirstName == objApplication.FirstName && x.LastName == objApplication.LastName && x.BirthDate == objApplication.BirthDate && x.MobileNumber == objApplication.MobileNumber && x.EmailId == objApplication.EmailId && (objApplication.postSelected == 1 ? x.IsAppliedForSupervisor : true) && (objApplication.postSelected == 2 ? x.ISAppliedForAsstAO : true)).FirstOrDefault(); if (isDuplicated == null) { #region "Save Basic details" ApplicantMaster dbApplication = new ApplicantMaster() { Surname = objApplication.Surname.Trim(), FirstName = objApplication.FirstName.Trim(), LastName = objApplication.LastName.Trim(), BirthDate = objApplication.BirthDate, AgeOnApplicationDate = objApplication.AgeOnApplicationDate, BirthPlaceVillage = objApplication.BirthPlaceVillage, BirthPlaceCity = objApplication.BirthPlaceCity, BirthPlaceState = objApplication.BirthPlaceState, AadharCardNo = objApplication.AadharCardNo, PhysicalDisability = objApplication.PhysicalDisability, DisabilityPercentage = objApplication.PhysicalDisability ? objApplication.DisabilityPercentage : 0, IsMSBEmp = objApplication.IsMSBEmp, IsAMCEmp = objApplication.IsAMCEmp, Address1 = objApplication.Address1, Address2 = objApplication.Address2, Address3 = objApplication.Address3, MobileNumber = objApplication.MobileNumber, EmailId = objApplication.EmailId, Cast = objApplication.Cast, SubCast = objApplication.SubCast, IsAppliedForSupervisor = objApplication.IsAppliedForSupervisor, SupervisorSeatNumber = objApplication.SupervisorSeatNumber, ISAppliedForAsstAO = objApplication.ISAppliedForAsstAO, AsstAOSeatNumber = objApplication.AsstAOSeatNumber, Category = objApplication.Category, MaritalStaus = objApplication.MaritalStaus, Title = objApplication.Title, Gender = objApplication.Gender, City = objApplication.City.Trim(), State = objApplication.State.Trim(), PinCode = objApplication.PinCode, District = objApplication.District.Trim(), Taluka = objApplication.Taluka.Trim(), Country = "INDIA", CreatedDateTime = DateTime.Now, photo = photo, signature = signBytes, }; context.ApplicantMasters.Add(dbApplication); context.SaveChanges(); ApplicantID = dbApplication.ApplicantID; #endregion #region "Save Qualification details" if (dbApplication.ApplicantID > 0 && objApplication.QualificationDetails != null && objApplication.QualificationDetails.Count > 0) { foreach (var item in objApplication.QualificationDetails) { ApplicantQualificationDetail dbQualification = new ApplicantQualificationDetail() { ApplicantID = dbApplication.ApplicantID, QualificationTypeID = Convert.ToInt32(item.Key.Split('_')[0]), QualificationHeaderID = Convert.ToInt32(item.Key.Split('_')[1]), Value = item.Value.ToString() }; context.ApplicantQualificationDetails.Add(dbQualification); context.SaveChanges(); } } #endregion #region "Save Experience details" if (dbApplication.ApplicantID > 0 && objApplication.ExperienceDetails != null && objApplication.ExperienceDetails.Count > 0) { foreach (var item in objApplication.ExperienceDetails) { var objval = JsonConvert.DeserializeObject <ApplicantExperienceDetail>(Convert.ToString(item.Value)); ApplicantExperienceDetail dbExperience = new ApplicantExperienceDetail() { ApplicantID = dbApplication.ApplicantID, OrganizationName = objval.OrganizationName, Designation = objval.Designation, StartDate = objval.StartDate, EndDate = objval.EndDate, Sequence = Convert.ToInt32(objval.Sequence) }; context.ApplicantExperienceDetails.Add(dbExperience); context.SaveChanges(); } } #endregion context.UpdateApplicationIDByPost(dbApplication.ApplicantID, objApplication.postSelected); Report("Application Form", dbApplication.ApplicantID, dbApplication.EmailId, objApplication.postSelected, dbApplication); TempData["key"] = "fromSave"; } else { IsDuplicateFlag = true; if (objApplication.postSelected == 1) { ApplicationNumber = isDuplicated.SupervisotApplicationID; } else if (objApplication.postSelected == 2) { ApplicationNumber = isDuplicated.AsstAOApplicationID; } else if (objApplication.postSelected == 3) { ApplicationNumber = isDuplicated.SupervisotApplicationID + "@_@" + isDuplicated.AsstAOApplicationID; } } } } } catch (Exception ex) { ErrorSignal.FromCurrentContext().Raise(ex); if (ApplicantID > 0) { using (context = new DBModel.NPSSEntities()) { context.DeleteApplicantDetails(ApplicantID); } } return(Json(new { IsSuccess = false, ApplicantID = ApplicantID, IsDuplicate = IsDuplicateFlag, ApplicationID = ApplicationNumber }, JsonRequestBehavior.AllowGet)); } return(Json(new { IsSuccess = true, ApplicantID = ApplicantID, IsDuplicate = IsDuplicateFlag, ApplicationID = ApplicationNumber }, JsonRequestBehavior.AllowGet)); }