public JsonResult Delete(ScheduleEvent value) { //if (value.ApprovedActivity != true) { var activity = new ScheduleEvent { SheduleID = value.SheduleID }; db.ScheduleEvents.Attach(activity); db.ScheduleEvents.Remove(activity); //db.SaveChanges(); } try { db.SaveChanges(); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } IEnumerable data = new mascisEntities().ScheduleEvents; return(Json(data, JsonRequestBehavior.AllowGet)); }
public ActionResult DialogInsertHSIP(Order_TB_Header value) { EmailJob email = new EmailJob(); context.Configuration.ProxyCreationEnabled = false; mascisEntities db_hv = new mascisEntities(); // OrderOISTIHeaderModels obj = new OrderOISTIHeaderModels(); string OrderNumber = new OrderNumber().GetOrderNumber(System.Convert.ToDateTime(value.DatePrepared), value.FacilityCode, "13", "02"); db_hv.Order_TB_Header.Add(value); value.OrderNumber = OrderNumber; TempData["OrderNumber"] = OrderNumber; //value.OrderNumber = OrderNumber; //TempData["OrderNumber"] = OrderNumber; TempData["FacilityCode"] = value.FacilityCode; TempData["StartDate"] = value.StartDate; TempData["EndDate"] = value.EndDate; value.OrderTypeId = 2; value.OrderStatusId = 1; value.EditedDate = DateTime.Now; value.EditedBy = new UserManagement().getCurrentuser(); db_hv.SaveChanges(); // //obj.SaveLog(value); if (value.FinalSubmission == true) { email.OrderSentToScto(value.FacilityCode, value.OrderNumber, "TB"); } return(Json(value, JsonRequestBehavior.AllowGet)); }
//public ActionResult DialogInsertHSIP(Order_ViralLoadReagents_Header value) //{ // string OrderNumber = new OrderNumber().GetOrderNumber(System.Convert.ToDateTime(value.DatePrepared), value.FacilityCode, "11", "02"); // OrderViralLoadReagentsHeaderModels obj = new OrderViralLoadReagentsHeaderModels(); // obj.OrderNumber = OrderNumber; // TempData["OrderNumber"] = OrderNumber; // obj.DatePrepared = System.Convert.ToDateTime(value.DatePrepared); // obj.FacilityCode = value.FacilityCode; // obj.StartDate = value.StartDate; // obj.EndDate = value.EndDate; // obj.OrderTypeId = 2; // obj.OrderStatusId = 1; // obj.FinalSubmission = System.Convert.ToBoolean(value.FinalSubmission); // obj.EditedBy = new UserManagement().getCurrentuser(); // obj.EditedDate = DateTime.Now; // obj.Save(); // return Json(value, JsonRequestBehavior.AllowGet); //} public ActionResult DialogInsertHSIPCustom(Order_ViralLoadReagents_Header value) { // EmailJob obx = new EmailJob(); context.Configuration.ProxyCreationEnabled = false; mascisEntities db_hv = new mascisEntities(); OrderViralLoadReagentsHeaderModels obj = new OrderViralLoadReagentsHeaderModels(); string OrderNumber = new OrderNumber().GetOrderNumber(System.Convert.ToDateTime(value.DatePrepared), value.FacilityCode, "11", "02"); db_hv.Order_ViralLoadReagents_Header.Add(value); value.OrderNumber = OrderNumber; TempData["OrderNumber"] = OrderNumber; value.OrderTypeId = 1; value.OrderStatusId = 1; value.StartDate = DateTime.Now; value.EndDate = DateTime.Now; value.EditedDate = DateTime.Now; value.EditedBy = new UserManagement().getCurrentuser(); db_hv.SaveChanges(); //obj.SaveLog(value); //EmailJob obx = new EmailJob(); //if (value.FinalSubmission == true) //{ // obx.SendEmail(value.FacilityCode, value.OrderNumber); //} //obx.SendEmail(value.FacilityCode, value.OrderNumber); return(Json(value, JsonRequestBehavior.AllowGet)); }
public ActionResult SaveExpectedReport(LMIS_ExpectedReport value, string fc, string productcategory, string startdate, string enddate) { DateTime sDate = DateTime.ParseExact(startdate, "dd/MM/yyyy", null); DateTime eDate = DateTime.ParseExact(enddate, "dd/MM/yyyy", null); int facility = int.Parse(fc); int pc = int.Parse(productcategory); context.Configuration.ProxyCreationEnabled = false; mascisEntities db_master = new mascisEntities(); LMIS_ExpectedReport table = db_master.LMIS_ExpectedReport.FirstOrDefault(o => o.facility_code == facility && o.product_category == pc && o.start_date == sDate && o.end_date == eDate); ExpectedReports obj = new ExpectedReports(); if (table == null) { //db.Entry(table).CurrentValues.SetValues(value); obj.facility_code = facility; obj.product_category = pc; obj.start_date = sDate; obj.end_date = eDate; //db_master.SaveChanges(); } else { //db.Entry(table).CurrentValues.SetValues(value); obj.facility_code = facility; obj.product_category = pc; obj.start_date = sDate; obj.end_date = eDate; db_master.Entry(table).State = EntityState.Modified; context.Entry(table).CurrentValues.SetValues(table); } obj.Update(); return(Json(value, JsonRequestBehavior.AllowGet)); //return RedirectToAction("DataSourceRFSO"); }
public ActionResult DialogUpdateHSIP(Order_TB_Header value) { EmailJob email = new EmailJob(); context.Configuration.ProxyCreationEnabled = false; mascisEntities db_master = new mascisEntities(); Order_TB_Header table = db_master.Order_TB_Header.FirstOrDefault(o => o.OrderNumber == value.OrderNumber); TempData["OrderNumber"] = value.OrderNumber; TempData["FacilityCode"] = value.FacilityCode; TempData["StartDate"] = value.StartDate; TempData["EndDate"] = value.EndDate; value.OrderTypeId = 2; value.OrderStatusId = 1; value.EditedDate = DateTime.Now; value.EditedBy = new UserManagement().getCurrentuser(); db_master.Entry(table).CurrentValues.SetValues(value); db_master.Entry(table).State = EntityState.Modified; db_master.SaveChanges(); if (value.FinalSubmission == true && value.RFSO_SentBackTofacility == false) { email.OrderSentToScto(value.FacilityCode, value.OrderNumber, "TB"); } if (value.FinalSubmission == true && value.RFSO_SentBackTofacility == true) { email.OrderReSentToScto(value.FacilityCode, value.OrderNumber, "TB"); } return(Json(value, JsonRequestBehavior.AllowGet)); }
//FacilityMap //public ActionResult FacilityMap() //{ // ViewData["datasource"] = Syncfusion_LocationData.GetSyncfusionLocationData(); // return View(); //} public ActionResult ConvertDataTabletoString() { System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); mascisEntities context = new mascisEntities(); var x = context.A_Facilities.AsNoTracking().ToList(); List <MapMarker> syncfusionLocationData = new List <MapMarker>(); foreach (var n in x) { var district = context.A_District.FirstOrDefault(e => e.District_Code == n.DistrrictCode); var DZ = context.A_DeliveryZone.FirstOrDefault(e => e.ZoneCode == n.DeliveryZoneCode); var CP = context.A_ImplimentingPartners.FirstOrDefault(e => e.ImplimentingPartnerCode == n.ComprehensiveImplimentingPartnerCode); var CDC = context.A_CDCRegion.FirstOrDefault(e => e.CDCRegionId == n.CDCRegionId); var CT = context.A_ClientType.FirstOrDefault(e => e.client_type_code == n.client_type_code); var LOC = context.A_Facility_Level_Of_Care.FirstOrDefault(e => e.level_of_care_code == n.level_of_care); LocationData msyncfusionLocationData = new LocationData() { Name = n.Facility, Latitude = Convert.ToDouble(n.Latititude), Longitude = Convert.ToDouble(n.Longtitude), }; if (district != null) { msyncfusionLocationData.District = district.District_Name; } if (LOC != null) { msyncfusionLocationData.LevelOfCare = LOC.level_of_care; } if (CT != null) { msyncfusionLocationData.CleintType = CT.client_type_desc; } if (CDC != null) { msyncfusionLocationData.CDCRegion = CDC.CDCRegion; } if (CP != null) { msyncfusionLocationData.IP = CP.ImplementingPartnerDescription; } if (DZ != null) { msyncfusionLocationData.Sector = DZ.ZoneDescription; } syncfusionLocationData.Add(msyncfusionLocationData); } //List<MapMarker> syncfusionLocationData = new List<MapMarker> //{ // new LocationData {Name = "Chennai", Country = "India", Latitude =13.0839 , Longitude = 80.27 , Description = "Syncfusion's branch office is located in AnnaNagar, Chennai", Address ="EYMARD Complex AJ 217 4th Avenue Shanthi Colony Anna Nagar Chennai-40 India" }, // new LocationData {Name = "North Carolina", Country = "United States", Latitude =35.5 , Longitude = -80 , Description = "Syncfusion's corporate office is located in Research Triangle Park North Carolina", Address ="Company Headquarters 2501 Aerial Center Parkway Suite 200 Morrisville NC 27560 USA" }, //}; // return serializer.Serialize(syncfusionLocationData); return(Json(syncfusionLocationData, JsonRequestBehavior.AllowGet));//syncfusionLocationData; }
public static IList <ScheduleEvent> GetAllRecords() { IList <ScheduleEvent> appoint = (IList <ScheduleEvent>)HttpContext.Current.Session["Appointments"]; if (appoint == null) { HttpContext.Current.Session["Appointments"] = appoint = new mascisEntities().ScheduleEvents.ToList(); } return(appoint); }
public ActionResult BatchUpdate(string key, List <LMIS_ExpectedReport> changed, List <LMIS_ExpectedReport> added, List <LMIS_ExpectedReport> deleted) { mascisEntities dbCase = new mascisEntities(); ExpectedReports obj = new ExpectedReports(); //Performing insert operation if (added != null && added.Count() > 0) { foreach (var temp in added) { //dbCase.A_Facilities.Add(temp); obj.facility_code = temp.facility_code; obj.start_date = temp.start_date; obj.end_date = temp.end_date; obj.product_category = temp.product_category; context.SaveChanges(); } } obj.Update(); if (changed != null && changed.Count() > 0) { foreach (var temp in changed) { obj.facility_code = temp.facility_code; obj.start_date = temp.start_date; obj.end_date = temp.end_date; obj.product_category = temp.product_category; var check = context.LMIS_ExpectedReport.FirstOrDefault(e => e.facility_code == temp.facility_code && e.start_date == temp.start_date && e.end_date == temp.end_date && e.product_category == temp.product_category); context.Entry(check).CurrentValues.SetValues(check); context.Entry(check).State = EntityState.Modified; context.SaveChanges(); } } //dbCase.SaveChanges(); obj.Update(); //Performing delete operation if (deleted != null && deleted.Count() > 0) { foreach (var temp in deleted) { dbCase.LMIS_ExpectedReport.Remove(dbCase.LMIS_ExpectedReport.FirstOrDefault(e => e.facility_code == temp.facility_code && e.start_date == temp.start_date && e.end_date == temp.end_date && e.product_category == temp.product_category)); } } //dbCase.SaveChanges(); obj.Update(); return(RedirectToAction("DataSourceRFSO")); }
public List <string> getCurrentLMISCOdinatorEmail() { mascisEntities dbcontext = new mascisEntities(); List <string> m = new List <string>(); var a = dbcontext.View_fo_Contacts_Details.Where(e => e.Role == "LMISCordinator" && e.LockoutEnabled == false && (e.DisableAll == false || e.DisableAll == null) && e.IsActive == true).ToList(); if (a.Count > 0) { foreach (var n in a) { m.Add(n.ce_email); } } return(m); }
public void LoadChart(List <Chss_Facility_Visits> visits) { mascisEntities db = new mascisEntities(); var Facilities = db.Chss_M_Facilities.ToList(); List <Chss_Facility_Visits> final_Visits = new List <Chss_Facility_Visits>(); foreach (var n in Facilities) { var x = visits.Where(e => e.facility_code == n.FacilityCode).OrderBy(e => e.date_of_visit).ToList(); if (x.Count > 0) { final_Visits.Add(x[0]); } } }
/// <summary> /// This function will return the Data from DB /// </summary> /// <param name="UploadFilePath"></param> /// <param name="Fileextention"></param> /// <param name="Detail"></param> /// <returns></returns> public List <FileList> GetUploadedFileList(int?e_reg_complaint_code) { List <FileList> objfilelist = new List <FileList>(); mascisEntities objmascis = new mascisEntities(); var datacollection = objmascis.FileCollections.ToList(); foreach (var item in datacollection) { if (item.e_reg_complaint_code == e_reg_complaint_code) { objfilelist.Add(new FileList { FileURL = item.FileURL, FileType = item.FileType, Detail = item.Details, e_reg_complaint_code = item.e_reg_complaint_code }); } } return(objfilelist); }
public JsonResult Add(ScheduleEvent value) { if ((value.IsBlockAppointment == true && value.BlockForAll == true) /*|| value.RoundTripActivity == true*/) { if (value.IsBlockAppointment == true) { value.AllDay = true; } } Save(value); // send email EmailJob email = new EmailJob(); email.SendEmailSchedular(value.ParticipationInvitee, value.VenueCode, Convert.ToDateTime(value.StartTime), Convert.ToDateTime(value.EndTime), value.EventCategory); IEnumerable data = new mascisEntities().ScheduleEvents; return(Json(data, JsonRequestBehavior.AllowGet)); }
public List <int> getUserFacilityList() { string UserName = HttpContext.Current.User.Identity.GetUserName(); var userStore = new UserStore <ApplicationUser>(context); mascisEntities masciscontext = new mascisEntities(); var facilities = masciscontext.A_Facilities.Where(f => f.RFSO_UserName == UserName).ToList(); //var districts = new UserManager<ApplicationUser>(userStore).Users.SingleOrDefault(a => a.UserName == UserName).DistrictSupervor; List <int> facilitiesarray = new List <int>(); if (facilities != null) { foreach (A_Facilities f in facilities) { facilitiesarray.Add(f.FacilityCode); } } return(facilitiesarray); }
public IEnumerable <SelectListItem> GetHH_Members(string hh_id) { if (!String.IsNullOrWhiteSpace(hh_id.ToString())) { using (var context = new mascisEntities()) { IEnumerable <SelectListItem> HH_Members = context.View_WebTemplate_Laboratory.AsNoTracking() .OrderBy(n => n.product_order) .Where(n => n.original_product_code.ToString() == hh_id) .Select(n => new SelectListItem { Value = n.product_order.ToString(), Text = n.product_description }).Distinct().ToList(); return(new SelectList(HH_Members, "Value", "Text")); } } return(null); }
public ActionResult DialogUpdateMAULT(Order_MAULT_Header value) { context.Configuration.ProxyCreationEnabled = false; mascisEntities db_master = new mascisEntities(); Order_MAULT_Header table = db_master.Order_MAULT_Header.FirstOrDefault(o => o.OrderNumber == value.OrderNumber); TempData["OrderNumber"] = value.OrderNumber; value.OrderStatusId = 1; value.ProductCategoryId = 13; value.EditedDate = DateTime.Now; value.EditedBy = new UserManagement().getCurrentuser(); db_master.Entry(table).CurrentValues.SetValues(value); db_master.Entry(table).State = EntityState.Modified; db_master.SaveChanges(); //if (value.FinalSubmission == true && value.RFSO_SentBackTofacility == false) //{ // obx.SendEmail(value.FacilityCode, value.OrderNumber); //} return(Json(value, JsonRequestBehavior.AllowGet)); }
//public ActionResult DialogInsertHSIP(Order_SMC_SLM_Header value) //{ // string OrderNumber = new OrderNumber().GetOrderNumber(System.Convert.ToDateTime(value.DatePrepared), value.FacilityCode, "10", "02"); // OrderSMCHeaderModels obj = new OrderSMCHeaderModels(); // obj.OrderNumber = OrderNumber; // TempData["OrderNumber"] = OrderNumber; // obj.DatePrepared = System.Convert.ToDateTime(value.DatePrepared); // obj.FacilityCode = value.FacilityCode; // obj.StartDate = value.StartDate; // obj.EndDate = value.EndDate; // obj.OrderTypeId = 2; // obj.OrderStatusId = 1; // obj.FinalSubmission = System.Convert.ToBoolean(value.FinalSubmission); // obj.EditedBy = new UserManagement().getCurrentuser(); // obj.EditedDate = DateTime.Now; // obj.Save(); // return Json(value, JsonRequestBehavior.AllowGet); //} public ActionResult DialogInsertMAULT(Order_MAULT_Header value) { //EmailJob obx = new EmailJob(); context.Configuration.ProxyCreationEnabled = false; mascisEntities db_hv = new mascisEntities(); string OrderNumber = new OrderNumber().GetOrderNumber(System.Convert.ToDateTime(value.DatePrepared), value.FacilityCode, "10", "01"); db_hv.Order_MAULT_Header.Add(value); value.OrderNumber = OrderNumber; TempData["OrderNumber"] = OrderNumber; value.ProductCategoryId = 10; value.OrderStatusId = 1; value.EditedDate = DateTime.Now; value.EditedBy = new UserManagement().getCurrentuser(); db_hv.SaveChanges(); //obx.SendEmail(value.FacilityCode, value.OrderNumber); //if (value.FinalSubmission == true) //{ // obx.SendEmail(value.FacilityCode, value.OrderNumber); //} return(Json(value, JsonRequestBehavior.AllowGet)); }
public static List <ScheduleEvent> FilterAppointment(DateTime CurrentDate, String CurrentAction, String CurrentView) { DateTime CurrDate = Convert.ToDateTime(CurrentDate); DateTime StartDate = FirstWeekDate(CurrDate.Date); DateTime EndDate = FirstWeekDate(CurrDate.Date); List <ScheduleEvent> appointmentList = new mascisEntities().ScheduleEvents.Where(a => a.IsBlockAppointment != true).ToList(); // GetAllRecords().ToList(); switch (CurrentView) { case "day": StartDate = CurrentDate; EndDate = CurrentDate; break; case "week": EndDate = EndDate.AddDays(7); break; case "workweek": EndDate = EndDate.AddDays(5); break; case "month": StartDate = CurrDate.Date.AddDays(-CurrDate.Day + 1); EndDate = StartDate.AddMonths(1); break; case "Agenda": EndDate = EndDate.AddDays(14); break; } // DateTime st; DateTime et; //appointmentList = new mascisEntities().ScheduleEvents.ToList(). // Where(app => DateTime.TryParse(app.StartTime.ToString(), out st) && // ((st.ToLocalTime().Date >= Convert.ToDateTime(StartDate.Date)) && // DateTime.TryParse(app.EndTime.ToString(), out et) && // (et.ToLocalTime().Date <= Convert.ToDateTime(EndDate.Date))) || app.Recurrence == true).Where(a => a.IsBlockAppointment != true).ToList(); return(appointmentList); }
public List <string> getCurrentFacilityEmail(int?facilityCode) { mascisEntities dbcontext = new mascisEntities(); List <string> m = new List <string>(); var a = dbcontext.View_WebTemplate_RecipientEmail.Where(e => e.FacilityCode == facilityCode && (e.DisableAll == false || e.DisableAll == null) && e.IsActive == true).ToList(); if (a.Count > 0) { foreach (var n in a) { m.Add(n.ce_email); } } return(m); //string UserName = HttpContext.Current.User.Identity.GetUserName(); //var userStore = new UserStore<ApplicationUser>(context); //var x = new UserManager<ApplicationUser>(userStore).Users.SingleOrDefault(a => a.UserName == UserName); //if (x != null) // return dbcontext.View_WebTemplate_RecipientEmail.(a => a.UserName == UserName).FacilityId; //else // return null; }
public JsonResult Update(ScheduleEvent value) { db.Configuration.ProxyCreationEnabled = false; var filterData = db.ScheduleEvents.Where(c => c.SheduleID == value.SheduleID); if (filterData.Count() > 0) { DateTime startTime = Convert.ToDateTime(value.StartTime); DateTime endTime = Convert.ToDateTime(value.EndTime); ScheduleEvent appoint = db.ScheduleEvents.Single(A => A.SheduleID == value.SheduleID); appoint.StartTime = startTime.ToUniversalTime(); appoint.EndTime = endTime.ToUniversalTime(); appoint.Subject = value.Subject; appoint.Location = value.Location; appoint.Description = value.Description; appoint.Owner = value.Owner; appoint.Priority = Convert.ToByte(value.Priority); appoint.Recurrence = Convert.ToBoolean(value.Recurrence); appoint.RecurrenceType = value.RecurrenceType; appoint.RecurrenceTypeCount = Convert.ToInt16(value.RecurrenceTypeCount); appoint.Reminder = value.Reminder; appoint.Categorize = value.Categorize; appoint.AllDay = value.AllDay; appoint.RecurrenceEndDate = value.RecurrenceEndDate != null?Convert.ToDateTime(value.RecurrenceEndDate).ToUniversalTime() : endTime.ToUniversalTime(); appoint.RecurrenceStartDate = value.RecurrenceStartDate != null?Convert.ToDateTime(value.RecurrenceStartDate).ToUniversalTime() : startTime.ToUniversalTime(); appoint.RecurrenceRule = value.RecurrenceRule; appoint.RecurrenceTypeCount = value.RecurrenceTypeCount; appoint.CustomStyle = value.CustomStyle; appoint.RemiderType = value.RemiderType; appoint.RemiderTypeCount = value.RemiderTypeCount; appoint.RemiderStartDate = value.RemiderStartDate; appoint.RemiderEndDate = value.RemiderEndDate; appoint.RemiderRule = value.RemiderRule; appoint.VenueCode = value.VenueCode; appoint.ParticipationInvitee = value.ParticipationInvitee; appoint.ParticipationAttendee = value.ParticipationAttendee; appoint.EventCategory = value.EventCategory; appoint.Organizer = value.Organizer; appoint.MeetingType = value.MeetingType; appoint.PublicHoliday = value.PublicHoliday; appoint.Added_By = new UserManagement().getCurrentuser(); appoint.Date_Added = DateTime.Now; appoint.EventOccured = value.EventOccured; appoint.NoEventOccuredComment = value.NoEventOccuredComment; appoint.IsBlockAppointment = value.IsBlockAppointment; appoint.VenueCode = value.VenueList; appoint.BlockForAll = value.BlockForAll; } else { Save(value); } // db.SaveChanges(); try { db.SaveChanges(); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } IEnumerable data = new mascisEntities().ScheduleEvents; return(Json(data, JsonRequestBehavior.AllowGet)); }
public ActionResult BatchUpdateSMC(string key, List <Order_SMC_SLM_Physical_Count> changed, List <Order_SMC_SLM_Physical_Count> added, List <Order_SMC_SLM_Physical_Count> deleted) { mascisEntities dbCase = new mascisEntities(); //Performing insert operation if (added != null && added.Count() > 0) { foreach (var temp in added) { string iDate = temp.DateOfPhysicalCount.ToString(); DateTime oDate = DateTime.Parse(iDate); temp.DateOfPhysicalCount = oDate; dbCase.Order_SMC_SLM_Physical_Count.Add(temp); temp.Total = temp.Quantity_Dispensary; temp.DateAdded = DateTime.Now; temp.AddedBy = new UserManagement().getCurrentuser(); temp.record_status = true; } } dbCase.SaveChanges(); if (changed != null && changed.Count() > 0) { foreach (var temp in changed) { string iDate = temp.DateOfPhysicalCount.ToString(); DateTime oDate = DateTime.Parse(iDate); temp.DateOfPhysicalCount = oDate; Order_SMC_SLM_Physical_Count old = dbCase.Order_SMC_SLM_Physical_Count. FirstOrDefault(o => o.FacilityCode == temp.FacilityCode && o.DateOfPhysicalCount == temp.DateOfPhysicalCount && o.ProductCode == temp.ProductCode && o.BatchNo == temp.BatchNo); if (old != null) { dbCase.Entry(old).CurrentValues.SetValues(temp); temp.Total = temp.Quantity_Dispensary; temp.DateAdded = DateTime.Now; temp.AddedBy = new UserManagement().getCurrentuser(); temp.record_status = true; } else { dbCase.Order_SMC_SLM_Physical_Count.Add(temp); temp.Total = temp.Quantity_Dispensary; temp.DateAdded = DateTime.Now; temp.AddedBy = new UserManagement().getCurrentuser(); temp.record_status = true; } } } dbCase.SaveChanges(); //Performing delete operation if (deleted != null && deleted.Count() > 0) { foreach (var temp in deleted) { dbCase.Order_SMC_SLM_Physical_Count.Remove(dbCase.Order_SMC_SLM_Physical_Count.FirstOrDefault(o => o.FacilityCode == temp.FacilityCode && o.DateOfPhysicalCount == temp.DateOfPhysicalCount && o.ProductCode == temp.ProductCode && o.BatchNo == temp.BatchNo)); } } dbCase.SaveChanges(); //return RedirectToAction("BatchDataSMC"); var data = 0; return(Json(data, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> Login(LoginViewModel model, string returnUrl) { if (!ModelState.IsValid) { return(View(model)); } // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, change to shouldLockout: true var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout : false); //switch (result) //{ // case SignInStatus.Success: // return RedirectToLocal(returnUrl); // case SignInStatus.LockedOut: // return View("Lockout"); // case SignInStatus.RequiresVerification: // return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }); // case SignInStatus.Failure: // default: // ModelState.AddModelError("", "Invalid login attempt."); // return View(model); //} switch (result) { case SignInStatus.Success: { mascisEntities context = new mascisEntities(); var user = await UserManager.FindAsync(model.Email, model.Password); var lockout = context.AspNetUsers.Find(user.Id); if (lockout.LockoutEnabled == true) { return(View("Lockout")); } else { //var roles = await UserManager.GetRolesAsync(user.Id); var roles = context.View_UsersRoles.SingleOrDefault(a => a.UserName == model.Email); if (roles != null) { if (roles.Name.Contains("Administrator")) { return(RedirectToAction("LMISDashboard", "Dashboard")); } if (roles.Name.Contains("MonitoringAndEvaluationOfficer")) { return(RedirectToAction("LMISDashboard", "Dashboard")); } if (roles.Name.Contains("SCTO")) { return(RedirectToAction("SCTODashboard", "Dashboard")); } if (roles.Name.Contains("MAULT")) { return(RedirectToAction("LMISDashboard", "Dashboard")); } if (roles.Name.Contains("MAULClient")) { return(RedirectToAction("LMISDashboard", "Dashboard")); } if (roles.Name.Contains("HSIPClient")) { return(RedirectToAction("FacilityDashboard", "Dashboard")); } if (roles.Name.Contains("LMISCordinator")) { return(RedirectToAction("LMISDashboard", "Dashboard")); } if (roles.Name.Contains("QualityAssurance")) { return(RedirectToAction("LMISDashboard", "Dashboard")); } if (roles.Name.Contains("CCU")) { return(RedirectToAction("LMISDashboard", "Dashboard")); } if (roles.Name.Contains("CHSS")) { return(RedirectToAction("LMISDashboard", "Dashboard")); } if (roles.Name.Contains("ComplaintHandling")) { return(RedirectToAction("LMISDashboard", "Dashboard")); } else { // return RedirectToLocal(returnUrl); return(RedirectToAction("Login", "Account")); } } else { //return RedirectToLocal(returnUrl); return(RedirectToAction("Login", "Account")); } } } case SignInStatus.LockedOut: return(View("Lockout")); case SignInStatus.RequiresVerification: return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe })); case SignInStatus.Failure: default: ModelState.AddModelError("", "Invalid login attempt."); DataTable dt = new DataTable(); List <Dictionary <string, object> > rows = new List <Dictionary <string, object> >(); Dictionary <string, object> row; string connectionString = ConfigurationManager.ConnectionStrings["MapConnection"].ConnectionString; //using (SqlConnection con = new SqlConnection(@"Password=root85;Persist Security Info=True;User ID=sa;Initial Catalog=MEDICALACCESS;Data Source=MEDACCKAMSAP03\MSSQL2017")) //using (SqlConnection con = new SqlConnection(@"Password=root85;Persist Security Info=True;User ID=sa;Initial Catalog=MEDICALACCESS;Data Source=.")) using (SqlConnection con = new SqlConnection(connectionString)) { using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = "spView_Facility_GIS_CodinatesGetAll"; cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = con; SqlParameter[] sqlParameters = new SqlParameter[1]; sqlParameters[0] = new SqlParameter("@FacilityCode", SqlDbType.Int); sqlParameters[0].IsNullable = true; //if (wdd_Facility.SelectedValue != "") // sqlParameters[0].Value = wdd_Facility.SelectedValue; //else sqlParameters[0].Value = DBNull.Value; sqlParameters[0].Direction = ParameterDirection.Input; cmd.Parameters.Clear(); cmd.Parameters.AddRange(sqlParameters); con.Open(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(dt); System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); foreach (DataRow dr in dt.Rows) { row = new Dictionary <string, object>(); foreach (DataColumn col in dt.Columns) { row.Add(col.ColumnName, dr[col]); } rows.Add(row); } //return serializer.Serialize(rows); } } ViewBag.GISdata = rows; // Syncfusion_LocationData.GetSyncfusionLocationData(); //ViewBag.ReturnUrl = returnUrl; return(View(model)); } }
public JsonResult Batch(EditParams param) { try { if (param.action == "insert" || (param.action == "batch" && param.added != null)) // this block of code will execute while inserting the appointments { var value = param.action == "insert" ? param.value : param.added[0]; db.Configuration.ProxyCreationEnabled = false; //int intMax = db.ScheduleEvents.ToList().Count > 0 ? db.ScheduleEvents.ToList().Max(p => p.Id) : 1; DateTime startTime = Convert.ToDateTime(value.StartTime); DateTime endTime = Convert.ToDateTime(value.EndTime); var currentTimeZone = TimeZone.CurrentTimeZone; ScheduleEvent appoint = new ScheduleEvent() { SheduleID = value.SheduleID, //Id = intMax + 1, StartTime = startTime.ToUniversalTime(), EndTime = endTime.ToUniversalTime(), Subject = value.Subject, Location = value.Location, Description = value.Description, Owner = value.Owner, Priority = value.Priority, Recurrence = value.Recurrence, RecurrenceType = value.RecurrenceType, Reminder = value.Reminder, Categorize = value.Categorize, AllDay = value.AllDay, RecurrenceEndDate = value.RecurrenceEndDate != null?Convert.ToDateTime(value.RecurrenceEndDate).ToUniversalTime() : endTime.ToUniversalTime(), RecurrenceStartDate = value.RecurrenceStartDate != null?Convert.ToDateTime(value.RecurrenceStartDate).ToUniversalTime() : startTime.ToUniversalTime(), RecurrenceRule = value.RecurrenceRule, RecurrenceTypeCount = value.RecurrenceTypeCount, CustomStyle = value.CustomStyle, RemiderType = value.RemiderType, RemiderTypeCount = value.RemiderTypeCount, RemiderStartDate = value.RemiderStartDate, RemiderEndDate = value.RemiderEndDate, RemiderRule = value.RemiderRule, VenueCode = value.VenueCode, ParticipationInvitee = value.ParticipationInvitee, ParticipationAttendee = value.ParticipationAttendee, EventCategory = value.EventCategory, Organizer = value.Organizer, MeetingType = value.MeetingType, PublicHoliday = value.PublicHoliday, Added_By = new UserManagement().getCurrentuser(), //value.Added_By, Date_Added = DateTime.Now, //value.Date_Added, EventOccured = value.EventOccured, NoEventOccuredComment = value.NoEventOccuredComment, IsBlockAppointment = value.IsBlockAppointment, VenueList = value.VenueList, BlockForAll = value.BlockForAll, }; db.Configuration.ProxyCreationEnabled = false; db.ScheduleEvents.Add(appoint); db.SaveChanges(); } else if (param.action == "remove") // this block of code will execute while removing the appointment { ScheduleEvent app = db.ScheduleEvents.Where(c => c.SheduleID.ToString() == param.key).FirstOrDefault(); var myevent = app; if (app != null) { db.ScheduleEvents.Remove(app); } db.SaveChanges(); } else if ((param.action == "batch" && param.changed != null) || param.action == "update") // this block of code will execute while updating the appointment { var value = param.action == "update" ? param.value : param.changed[0]; //var filterData = db.ScheduleEvents.Where(c => c.Id == Convert.ToInt32(value.Id)); db.Configuration.ProxyCreationEnabled = false; var filterData = db.ScheduleEvents.Where(c => c.SheduleID == value.SheduleID); if (filterData.Count() > 0) { DateTime startTime = Convert.ToDateTime(value.StartTime); DateTime endTime = Convert.ToDateTime(value.EndTime); ScheduleEvent appoint = db.ScheduleEvents.Single(A => A.SheduleID == value.SheduleID); appoint.StartTime = startTime.ToUniversalTime(); appoint.EndTime = endTime.ToUniversalTime(); appoint.Subject = value.Subject; appoint.Location = value.Location; appoint.Description = value.Description; appoint.Owner = value.Owner; appoint.Priority = Convert.ToByte(value.Priority); appoint.Recurrence = Convert.ToBoolean(value.Recurrence); appoint.RecurrenceType = value.RecurrenceType; appoint.RecurrenceTypeCount = Convert.ToInt16(value.RecurrenceTypeCount); appoint.Reminder = value.Reminder; appoint.Categorize = value.Categorize; appoint.AllDay = value.AllDay; appoint.RecurrenceEndDate = value.RecurrenceEndDate != null?Convert.ToDateTime(value.RecurrenceEndDate).ToUniversalTime() : endTime.ToUniversalTime(); appoint.RecurrenceStartDate = value.RecurrenceStartDate != null?Convert.ToDateTime(value.RecurrenceStartDate).ToUniversalTime() : startTime.ToUniversalTime(); appoint.RecurrenceRule = value.RecurrenceRule; appoint.RecurrenceTypeCount = value.RecurrenceTypeCount; appoint.CustomStyle = value.CustomStyle; appoint.RemiderType = value.RemiderType; appoint.RemiderTypeCount = value.RemiderTypeCount; appoint.RemiderStartDate = value.RemiderStartDate; appoint.RemiderEndDate = value.RemiderEndDate; appoint.RemiderRule = value.RemiderRule; appoint.VenueCode = value.VenueCode; appoint.ParticipationInvitee = value.ParticipationInvitee; appoint.ParticipationAttendee = value.ParticipationAttendee; appoint.EventCategory = value.EventCategory; appoint.Organizer = value.Organizer; appoint.MeetingType = value.MeetingType; appoint.PublicHoliday = value.PublicHoliday; appoint.Added_By = new UserManagement().getCurrentuser(); appoint.Date_Added = DateTime.Now; appoint.EventOccured = value.EventOccured; appoint.NoEventOccuredComment = value.NoEventOccuredComment; appoint.IsBlockAppointment = value.IsBlockAppointment; appoint.VenueCode = value.VenueList; appoint.BlockForAll = value.BlockForAll; } db.SaveChanges(); } } catch (Exception ex) { throw ex;//new Exception ex.Message; } IEnumerable data = new mascisEntities().ScheduleEvents.ToList(); // nw.Appointment.Take(5); return(Json(data, JsonRequestBehavior.AllowGet)); }