public ActionResult Index(string branch) { ViewBag.BranchList = ToSelectList((from A in db.SiteMasters select new DropDownModel { Id = A.BUCode, Value = A.BUCode + " - " + A.BUDescription }).ToList()); List <DoubleSite> list = (from A in db.DoublePunchMasters join B in db.SiteMasters on A.BUCode equals B.BUCode select new DoubleSite { Id = A.Id, BUCode = A.BUCode, BUDescription = B.BUDescription }).ToList(); DoublePunchMaster site = db.DoublePunchMasters.Where(x => x.BUCode == branch).FirstOrDefault(); if (site == null) { DoublePunchMaster site1 = new DoublePunchMaster(); site1.BUCode = branch; site1.DoublePunchMechanism = "Double"; db.DoublePunchMasters.Add(site1); db.SaveChanges(); ViewBag.Error = ""; return(RedirectToAction("Index")); } else { ViewBag.Error = "You Have Already Added this Site"; return(View(list)); } }
public ActionResult Create([Bind(Include = "id,Reasons,isactive")] ReasonMaster reasonMaster) { string LoginId = Session["LoginId"].ToString(); if (LoginId == "" || LoginId == null) { return(RedirectToAction("LogOut", "LoginPortal")); } if (ModelState.IsValid) { db.ReasonMasters.Add(reasonMaster); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(reasonMaster)); }
public ActionResult Index(ChangePassword chng) { GInfraEntities db = new GInfraEntities(); if ((chng.OldPassword == "" || chng.OldPassword == null) && (chng.NewPassword == "" || chng.NewPassword == null) && (chng.ConfirmPassword == "" || chng.ConfirmPassword == null)) { ViewBag.ErrorMsg = "Please Fill All the fields"; } else { if (chng.NewPassword == chng.ConfirmPassword) { string loginid = Session["LoginId"].ToString(); string userid = db.MasterPasswords.Where(x => x.UserID == loginid && x.UserPassword == chng.OldPassword).OrderByDescending(z => z.UserID).Take(1).Select(b => b.UserID).DefaultIfEmpty("-").SingleOrDefault().ToString(); if (userid != "-") { MasterPassword updatedCustomer = (from c in db.MasterPasswords where c.UserID == loginid select c).FirstOrDefault(); updatedCustomer.UserPassword = chng.ConfirmPassword; int insertedRecords = db.SaveChanges(); if (insertedRecords == 1) { ViewBag.ErrorMsg = "Your password has been changed sucecssfully "; ModelState.Clear(); } else { ViewBag.ErrorMsg = "Something wrong"; } } else { ViewBag.ErrorMsg = "Old Password is Incorrect"; } } else { ViewBag.ErrorMsg = "Your Confirm Password Does not match"; } } return(View()); }
public ActionResult ChangeStatus(string id, string status) { bool stat = false; if (status == "true") { stat = true; } MasterPassword banner = db.MasterPasswords.Where(x => x.UserID == id).FirstOrDefault(); banner.isactive = stat; db.Entry(banner).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public HttpResponseMessage Post([FromBody] BellNotificationAttendanceRequest request) { BellNotificationAttendance BellNotificationAttendance = new BellNotificationAttendance(); try { if (request.id != null && request.id > 0) { var appversion = GInfraEntities.Notifications.Where(e => e.Id == request.id && e.isactive == true).ToList(); if (appversion.Count > 0) { foreach (var item in appversion) { item.isactive = false; GInfraEntities.SaveChanges(); } BellNotificationAttendance.Status = true; BellNotificationAttendance.Message = "Delete Successfully"; return(Request.CreateResponse(HttpStatusCode.OK, BellNotificationAttendance)); } else { BellNotificationAttendance.Status = false; BellNotificationAttendance.Message = "No Records Found"; return(Request.CreateResponse(HttpStatusCode.OK, BellNotificationAttendance)); } } else { BellNotificationAttendance.Status = false; BellNotificationAttendance.Message = "No Records Found"; return(Request.CreateResponse(HttpStatusCode.OK, BellNotificationAttendance)); } } catch (Exception ex) { BellNotificationAttendance.Status = false; BellNotificationAttendance.Message = "" + ex.Message + ""; return(Request.CreateResponse(HttpStatusCode.InternalServerError, BellNotificationAttendance)); } }
public JsonResult SavePolygon(string polygonJSON, int SiteName, string officelat, string officelong) { ObjectParameter resultvalue = new ObjectParameter("ERROR", typeof(int)); SiteMaster updatedCustomer = (from c in db.SiteMasters where c.Id == SiteName select c).FirstOrDefault(); updatedCustomer.lattitude = officelat; updatedCustomer.longitute = officelong; int insertedRecords = db.SaveChanges(); db.Sp_InsertPolygon(polygonJSON, Convert.ToInt32(SiteName), resultvalue); return(Json(JsonRequestBehavior.AllowGet)); }
public ActionResult Edit([Bind(Include = "Id,BUCode,BUDescription,Workinghours,GracePeriod")] SiteMaster siteMaster) { string LoginId = Session["LoginId"].ToString(); if (LoginId == "" || LoginId == null) { return(RedirectToAction("LogOut", "LoginPortal")); } SiteMaster site = db.SiteMasters.Find(siteMaster.Id); site.Workinghours = siteMaster.Workinghours; site.GracePeriod = siteMaster.GracePeriod; if (ModelState.IsValid) { db.Entry(site).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(siteMaster)); }
public ActionResult ChangeStatus(string id, string status) { string LoginId = Session["LoginId"].ToString(); if (LoginId == "" || LoginId == null) { return(RedirectToAction("LogOut", "LoginPortal")); } bool stat = false; if (status == "true") { stat = true; } MasterPassword banner = db.MasterPasswords.Where(x => x.UserID == id).FirstOrDefault(); banner.Super = stat; db.Entry(banner).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public bool ImportData() { var result = false; try { string path = Server.MapPath("~/UploadFiles") + "\\attendance.xlsx"; FileInfo file = new FileInfo(path); //var package = new ExcelPackage(new System.IO.FileInfo(path)); //int startColumn = 1; //int startRow = 2; //ExcelWorksheet workSheet = package.Workbook.Worksheets[0]; //object data = null; GInfraEntities db = new GInfraEntities(); using (ExcelPackage package = new ExcelPackage(file)) { ExcelWorksheet workSheet = package.Workbook.Worksheets["attendance"]; int totalRows = workSheet.Dimension.Rows; for (int i = 3; i <= totalRows; i++) { BiometricAttendance biometric = new BiometricAttendance(); BiometricAttendance biometricCheck = new BiometricAttendance(); string EmployeeId = workSheet.Cells[i, 2].Value.ToString(); DateTime StartDate = Convert.ToDateTime(workSheet.Cells[i, 3].Value); biometricCheck = db.BiometricAttendances.Where(x => x.EmployeeId == EmployeeId && x.StartDate == StartDate).FirstOrDefault(); if (biometricCheck == null) { biometric.EmployeeId = workSheet.Cells[i, 2].Value.ToString(); biometric.StartDate = Convert.ToDateTime(workSheet.Cells[i, 3].Value); if (workSheet.Cells[i, 4].Value == null) { biometric.PunchInDate = null; } else { biometric.PunchInDate = Convert.ToDateTime(workSheet.Cells[i, 4].Value); } if (workSheet.Cells[i, 5].Value == null) { biometric.PunchInTime = null; } else { DateTime temp = Convert.ToDateTime(workSheet.Cells[i, 5].Value); biometric.PunchInTime = temp.TimeOfDay; } if (workSheet.Cells[i, 6].Value == null) { biometric.PunchOutDate = null; } else { biometric.PunchOutDate = Convert.ToDateTime(workSheet.Cells[i, 6].Value); } if (workSheet.Cells[i, 7].Value == null) { biometric.PunchOutTime = null; } else { DateTime temp = Convert.ToDateTime(workSheet.Cells[i, 7].Value); biometric.PunchOutTime = temp.TimeOfDay; } if (workSheet.Cells[i, 8].Value == null) { biometric.CustRegularized = null; } else { biometric.CustRegularized = workSheet.Cells[i, 8].Value.ToString(); } db.BiometricAttendances.Add(biometric); db.SaveChanges(); } else { if (workSheet.Cells[i, 4].Value == null) { biometricCheck.PunchInDate = null; } else { DateTime temp = Convert.ToDateTime(workSheet.Cells[i, 4].Value); if (biometricCheck.PunchInDate != null) { if (temp <= biometricCheck.PunchInDate) { biometricCheck.PunchInDate = temp; } } else { biometricCheck.PunchInDate = temp; } } if (workSheet.Cells[i, 5].Value == null) { biometricCheck.PunchInTime = null; } else { DateTime temp = Convert.ToDateTime(workSheet.Cells[i, 5].Value); TimeSpan t = temp.TimeOfDay; if (biometricCheck.PunchInTime != null) { if (t <= biometricCheck.PunchInTime) { biometricCheck.PunchInTime = temp.TimeOfDay; } } else { biometricCheck.PunchInTime = temp.TimeOfDay; } } if (workSheet.Cells[i, 6].Value == null) { biometricCheck.PunchOutDate = null; } else { DateTime temp = Convert.ToDateTime(workSheet.Cells[i, 6].Value); if (biometricCheck.PunchOutDate != null) { if (temp >= biometricCheck.PunchOutDate) { biometricCheck.PunchOutDate = temp; } } else { biometricCheck.PunchOutDate = temp; } } if (workSheet.Cells[i, 7].Value == null) { biometricCheck.PunchOutTime = null; } else { DateTime temp = Convert.ToDateTime(workSheet.Cells[i, 7].Value); TimeSpan t = temp.TimeOfDay; if (biometricCheck.PunchOutTime != null) { if (t >= biometricCheck.PunchOutTime) { biometricCheck.PunchOutTime = temp.TimeOfDay; } } else { biometricCheck.PunchOutTime = temp.TimeOfDay; } } if (workSheet.Cells[i, 8].Value == null) { biometric.CustRegularized = null; } else { biometric.CustRegularized = workSheet.Cells[i, 8].Value.ToString(); } db.SaveChanges(); } } } } catch (Exception) { } return(result); }
public ActionResult List(HttpPostedFileBase fileupload, HttpPostedFileBase Backfileupload, string Description, string title, string fromdate, string todate, string[] branch) { string LoginId = Session["LoginId"].ToString(); if (Description == null || Description == "") { Description = "-"; } if (LoginId == "" || LoginId == null) { return(RedirectToAction("LogOut", "LoginPortal")); } if (branch == null) { ViewBag.BranchList = ToSelectList((from A in db.SiteMasters select new DropDownModel { Id = A.Id.ToString(), Value = A.BUDescription }).ToList()); List <HR_Announcement> list = new List <HR_Announcement>(); list = db.HR_Announcement.OrderByDescending(x => x.id).ToList(); foreach (var item in list) { String BranchName = ""; string[] BranchIdList = item.BranchId.Split(','); foreach (string id in BranchIdList) { int Id = Convert.ToInt32(id); SiteMaster siteMaster = db.SiteMasters.Where(x => x.Id == Id).FirstOrDefault(); BranchName += siteMaster.BUDescription + ","; } BranchName = BranchName.Remove(BranchName.Length - 1, 1); item.BranchId = BranchName; } ViewBag.BranchError = "Please Select atleast one branch"; return(View(list)); } bool status = false; ViewBag.BranchError = ""; string BranchId = ""; foreach (string id in branch) { if (id == "0") { status = true; } } if (status == true) { List <SiteMaster> list = db.SiteMasters.ToList(); foreach (var lis in list) { BranchId += lis.Id + ","; } } else { foreach (string id in branch) { BranchId += id + ","; } } BranchId = BranchId.Remove(BranchId.Length - 1, 1); var Timestamp = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds(); if (fileupload != null) { int year = DateTime.Now.Year; DateTime Fromdate = DateTime.Today; DateTime Todate = new DateTime(year, 12, 31); if (fromdate != null && fromdate != "") { Fromdate = Convert.ToDateTime(fromdate); } if (todate != null && todate != "") { Todate = Convert.ToDateTime(todate); } string fileName = Path.GetFileName(fileupload.FileName); if (Path.GetExtension(fileName) == ".gif" || Path.GetExtension(fileName) == ".jpg" || Path.GetExtension(fileName) == ".png" || Path.GetExtension(fileName) == ".jpeg") { int fileSize = fileupload.ContentLength; if (fileSize > (4 * 1024 * 1024)) { ViewBag.Error = "Maxixmum File Size Allowed is 4 MB"; ViewBag.BranchList = ToSelectList((from A in db.SiteMasters select new DropDownModel { Id = A.Id.ToString(), Value = A.BUDescription }).ToList()); List <HR_Announcement> list = new List <HR_Announcement>(); list = db.HR_Announcement.OrderByDescending(x => x.id).ToList(); foreach (var item in list) { String BranchName = ""; string[] BranchIdList = item.BranchId.Split(','); foreach (string id in BranchIdList) { int Id = Convert.ToInt32(id); SiteMaster siteMaster = db.SiteMasters.Where(x => x.Id == Id).FirstOrDefault(); BranchName += siteMaster.BUDescription + ","; } BranchName = BranchName.Remove(BranchName.Length - 1, 1); item.BranchId = BranchName; } return(View(list)); } else { int Size = fileSize / 1000; fileupload.SaveAs(Server.MapPath("~/BannerData/" + Timestamp + "Banner" + Path.GetExtension(fileName))); HR_Announcement banner = new HR_Announcement(); banner.Image = "/BannerData/" + +Timestamp + "Banner" + Path.GetExtension(fileName); banner.isactive = true; banner.Title = title; banner.Description = Description; banner.FromDate = Fromdate; banner.ToDate = Todate; banner.BranchId = BranchId; db.HR_Announcement.Add(banner); db.SaveChanges(); BackgroundJob.Enqueue(() => SFTPDataController.SendHrannoucement()); ViewBag.Error = ""; } } else { ViewBag.Error = "Only JPG, PNG & GIF file formats are supported"; ViewBag.BranchList = ToSelectList((from A in db.SiteMasters select new DropDownModel { Id = A.Id.ToString(), Value = A.BUDescription }).ToList()); List <HR_Announcement> list = new List <HR_Announcement>(); list = db.HR_Announcement.OrderByDescending(x => x.id).ToList(); foreach (var item in list) { String BranchName = ""; string[] BranchIdList = item.BranchId.Split(','); foreach (string id in BranchIdList) { int Id = Convert.ToInt32(id); SiteMaster siteMaster = db.SiteMasters.Where(x => x.Id == Id).FirstOrDefault(); BranchName += siteMaster.BUDescription + ","; } BranchName = BranchName.Remove(BranchName.Length - 1, 1); item.BranchId = BranchName; } return(View(list)); } } else { int year = DateTime.Now.Year; DateTime Fromdate = DateTime.Today; DateTime Todate = new DateTime(year, 12, 31); if (fromdate != null && fromdate != "") { Fromdate = Convert.ToDateTime(fromdate); } if (todate != null && todate != "") { Todate = Convert.ToDateTime(todate); } HR_Announcement banner = new HR_Announcement(); banner.Image = "-"; banner.isactive = true; banner.Title = title; banner.Description = Description; banner.FromDate = Fromdate; banner.ToDate = Todate; banner.BranchId = BranchId; db.HR_Announcement.Add(banner); db.SaveChanges(); ViewBag.Error = ""; } return(RedirectToAction("List")); }
public ActionResult BannerUpload(HttpPostedFileBase fileupload, HttpPostedFileBase Backfileupload, string Description, string title, string fromdate, string todate) { string LoginId = Session["LoginId"].ToString(); if (LoginId == "" || LoginId == null) { return(RedirectToAction("LogOut", "LoginPortal")); } if (Description == null || Description == "") { Description = "-"; } var Timestamp = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds(); if (fileupload != null) { int year = DateTime.Now.Year; DateTime Fromdate = DateTime.Today; DateTime Todate = new DateTime(year, 12, 31); if (fromdate != null && fromdate != "") { Fromdate = Convert.ToDateTime(fromdate); } if (todate != null && todate != "") { Todate = Convert.ToDateTime(todate); } string fileName = Path.GetFileName(fileupload.FileName); string fileName1 = ""; if (Path.GetExtension(fileName) == ".gif" || Path.GetExtension(fileName) == ".jpg" || Path.GetExtension(fileName) == ".png" || Path.GetExtension(fileName) == ".mp4" || Path.GetExtension(fileName) == ".jpeg") { int fileSize = fileupload.ContentLength; if (Path.GetExtension(fileName) == ".gif") { if (fileSize > (4 * 1024 * 1024)) { ViewBag.Error = "Maxixmum File Size for GIF extension is 4 MB"; } else { int Size = fileSize / 1000; fileupload.SaveAs(Server.MapPath("~/BannerData/" + Timestamp + "Banner" + Path.GetExtension(fileName))); Banner_image banner = new Banner_image(); banner.imageUrl = "/BannerData/" + +Timestamp + "Banner" + Path.GetExtension(fileName); banner.BackgroundImage = "-"; banner.isactive = true; banner.Title = title; banner.Description = Description; banner.Extension = Path.GetExtension(fileName); banner.Fromdate = Fromdate; banner.Todate = Todate; db.Banner_image.Add(banner); db.SaveChanges(); ViewBag.Error = ""; } } else if (Path.GetExtension(fileName) == ".jpg" || Path.GetExtension(fileName) == ".jpeg" || Path.GetExtension(fileName) == ".png") { if (fileSize > (2 * 1024 * 1024)) { ViewBag.Error = "Maxixmum File Size for JPG & PNG extension is 2 MB"; } else { int Size = fileSize / 1000; fileupload.SaveAs(Server.MapPath("~/BannerData/" + Timestamp + "Banner" + Path.GetExtension(fileName))); Banner_image banner = new Banner_image(); banner.imageUrl = "/BannerData/" + +Timestamp + "Banner" + Path.GetExtension(fileName); banner.BackgroundImage = "-"; banner.isactive = true; banner.Title = title; banner.Description = Description; banner.Extension = Path.GetExtension(fileName); banner.Fromdate = Fromdate; banner.Todate = Todate; db.Banner_image.Add(banner); db.SaveChanges(); ViewBag.Error = ""; } } else if (Path.GetExtension(fileName) == ".mp4") { if (fileSize > (25 * 1024 * 1024)) { ViewBag.Error = "Maxixmum File Size for MP4 extension is 25 MB"; } else { int Size = fileSize / 1000; if (Backfileupload != null) { fileName1 = Path.GetFileName(Backfileupload.FileName); if (Path.GetExtension(fileName1) == ".png" || Path.GetExtension(fileName1) == ".jpg" || Path.GetExtension(fileName1) == ".gif" || Path.GetExtension(fileName1) == ".jpeg") { fileupload.SaveAs(Server.MapPath("~/BannerData/" + Timestamp + "Banner" + Path.GetExtension(fileName))); Backfileupload.SaveAs(Server.MapPath("~/BannerData/" + Timestamp + "Background" + Path.GetExtension(fileName1))); ViewBag.BackGroundImageError = ""; } else { ViewBag.BackGroundImageError = "Background Image only support PNG, JPG & GIF format "; List <Banner_image> banner11 = new List <Banner_image>(); banner11 = db.Banner_image.ToList(); return(View(banner11)); } } else { ViewBag.BackGroundImageError = "Background Image Compuslory In Video Upload Case"; List <Banner_image> banner11 = new List <Banner_image>(); banner11 = db.Banner_image.ToList(); return(View(banner11)); } Banner_image banner = new Banner_image(); banner.imageUrl = "/BannerData/" + +Timestamp + "Banner" + Path.GetExtension(fileName); if (fileName1 != "" && fileName1 != null) { banner.BackgroundImage = "/BannerData/" + +Timestamp + "Background" + Path.GetExtension(fileName1); } else { banner.BackgroundImage = "-"; } banner.isactive = true; banner.Title = title; banner.Description = Description; banner.Extension = Path.GetExtension(fileName); banner.Fromdate = Fromdate; banner.Todate = Todate; db.Banner_image.Add(banner); db.SaveChanges(); ViewBag.Error = ""; } } } else { ViewBag.Error = "Only JPG, PNG, GIF and MP4 file formats are supported"; } } List <Banner_image> banners = new List <Banner_image>(); banners = db.Banner_image.ToList(); return(View(banners)); }