public JsonResult GetComponentsByProject(int projectId) { var _entity = new WCMSEntities(); var list = _entity.ProjectBomList.Where(a => a.ProjectMasterId == projectId).ToList(); var component = new List <tblComponentRequisition>(); foreach (var items in list) { var com = _entity.tblComponentRequisition.FirstOrDefault(x => x.ComponentId == items.ComponentId); var tblComponentRequisition = new tblComponentRequisition(); if (com != null) { tblComponentRequisition.ComponentId = com.ComponentId; tblComponentRequisition.ComponentName = com.ComponentName; tblComponentRequisition.ReqQuantity = com.ReqQuantity - com.UsedQuantity; } else { tblComponentRequisition.ComponentId = items.ComponentId; tblComponentRequisition.ComponentName = items.ComponentName; tblComponentRequisition.ReqQuantity = 0; } component.Add(tblComponentRequisition); } return(Json(component, JsonRequestBehavior.AllowGet)); }
public ActionResult LogIn(LoginModel login) { if (ModelState.IsValid) //validating the user inputs { bool isExist = false; using (var _entity = new WCMSEntities()) // { isExist = _entity.tblLogin.Any(x => x.UserName.Trim().ToLower() == login.UserName.Trim().ToLower() && x.Password == login.Password); //validating the user name in tblLogin table whether the user name is exist or not if (isExist) { LoginModel loginCredentials = _entity.tblLogin.Where(x => x.UserName.Trim().ToLower() == login.UserName.Trim().ToLower()).Select(x => new LoginModel { UserName = x.UserName, RoleName = x.tblRoles.Roles, UserRoleId = (int?)x.RoleId, PackLineId = (int?)x.LineId, UserId = x.Id, UserLineId = x.LineId, EmployeeName = x.EmployeeName }).FirstOrDefault(); // Get the login user details and bind it to LoginModels class List <MenuModel> menus = _entity.tblSubMenu.Where(x => x.RoleId == loginCredentials.UserRoleId && x.IsMenue == true).Select(x => new MenuModel { MainMenuId = x.tblMainMenu.Id, MainMenuName = x.tblMainMenu.MainMenu, SubMenuId = x.Id, SubMenuName = x.SubMenu, ControllerName = x.Controller, ActionName = x.Action, RoleId = x.RoleId //RoleName = x.RoleName }).ToList(); //Get the Menu details List <MenuModel> permissions = _entity.tblSubMenu.Where(x => x.RoleId == loginCredentials.UserRoleId || x.RoleId == 0).Select(x => new MenuModel { MainMenuId = x.tblMainMenu.Id, MainMenuName = x.tblMainMenu.MainMenu, SubMenuId = x.Id, SubMenuName = x.SubMenu, ControllerName = x.Controller, ActionName = x.Action, RoleId = x.RoleId //RoleName = x.RoleName }).ToList(); //Get the Menu details FormsAuthentication.SetAuthCookie(loginCredentials.UserName, false); // set the formauthentication cookie System.Web.HttpContext.Current.Session["WCMSLoginUserName"] = login.UserName; DateTime startDate = DateTime.Today; DateTime endDate = startDate.AddDays(1).AddTicks(-1); var getLiness = _entity.tblAssemblyLineSetup.Where(x => x.AssemblyLineId == loginCredentials.UserLineId && x.AddedDate >= startDate && x.AddedDate <= endDate).ToList(); var getLines = getLiness.OrderByDescending(a => a.AddedDate).FirstOrDefault(); var projectId = getLines != null ? getLines.ProjectId : 0; var projectName = getLines != null ? getLines.ProjectName : ""; var lineId = getLines != null ? getLines.AssemblyLineId : loginCredentials.UserLineId; Session["LoginCredentials"] = loginCredentials; // Session["MenuMaster"] = menus; // Session["permissions"] = permissions; // Session["UserName"] = loginCredentials.UserName; Session["EmpName"] = loginCredentials.EmployeeName; // Session["ProjectId"] = _entity.tblAssemblyLineSetup.Where(x => x.AssemblyLineId == _loginCredentials.UserLineId) .Select(a => a.ProjectId); //System.Web.HttpContext.Current.Session["WCMSLoginUserId"] = _loginCredentials.UserId; System.Web.HttpContext.Current.Session["WCMSUserRoleId"] = loginCredentials.UserRoleId; System.Web.HttpContext.Current.Session["WCMSUserRoleName"] = loginCredentials.RoleName; System.Web.HttpContext.Current.Session["WCMSUserId"] = loginCredentials.UserId; System.Web.HttpContext.Current.Session["WCMSProjectId"] = projectId; System.Web.HttpContext.Current.Session["WCMSProjectName"] = projectName; System.Web.HttpContext.Current.Session["WCMSLineId"] = lineId; System.Web.HttpContext.Current.Session["WCMSPackLineId"] = loginCredentials.PackLineId; var loginRoleName = loginCredentials.RoleName.ToLower(); var loginRoleId = loginCredentials.UserRoleId; var workerHomePage = permissions.FirstOrDefault(a => a.RoleId == loginRoleId); if (loginRoleId == 21) { if (workerHomePage != null) { return(RedirectToAction("" + workerHomePage.ActionName + "", "" + workerHomePage.ControllerName + "")); } } //if (projectId == 0 && loginRoleId != 1 && loginRoleId != 9 && loginRoleId != 4 && loginRoleId != 10 && loginRoleId != 5 && loginRoleId != 6 && loginRoleId != 7 && loginRoleId != 15 && loginRoleId != 16 && loginRoleId != 17 && loginRoleId != 18 && loginRoleId != 19 && loginRoleId != 20) if (projectId == 0 && loginRoleId == 12) { ViewBag.ErrorMsg = "No Active Project !! Please Add a Project!"; return(View()); } if (projectId == 0 && loginCredentials.UserRoleId == 9) { return(RedirectToAction("UserDashboard", "Home")); } if (projectId == 0 && loginCredentials.UserRoleId == 1) { return(RedirectToAction("Dashboard", "Home")); } if ((projectId == 0 || projectId != 0) && loginRoleId != 12) { if (workerHomePage != null) { return(RedirectToAction("" + workerHomePage.ActionName + "", "" + workerHomePage.ControllerName + "")); } } if ((projectId != 0) && loginRoleId == 12) { if (workerHomePage != null) { return(RedirectToAction("" + workerHomePage.ActionName + "", "" + workerHomePage.ControllerName + "")); } } //if (projectId == 0 && (!loginRoleName.StartsWith("admin") && !loginRoleName.StartsWith("line"))) //{ // ViewBag.ErrorMsg = "No Active Project !! Please add a project!"; // return View(); //} //if (loginCredentials.UserName != "admin") //{ // return RedirectToAction("UserDashboard", "Home"); //} //else //{ // return RedirectToAction("Dashboard", "Home"); //} } else { ViewBag.ErrorMsg = "Please enter the valid credentials!"; return(View()); } } } return(View()); //return RedirectToAction("Index", "Home"); }
public JsonResult InsertCkdMmiStationInformation(tblCkdMmiMaster mmItabltestComponent, List <tblCkdRework> reworkList) { WCMSEntities entities = new WCMSEntities(); var startDate = DateTime.Today; var endDate = startDate.AddDays(1).AddTicks(-1); var userId = (long)_dictionary[2].Id; var projectId = (long)_dictionary[3].Id; long lineId = (long)_dictionary[4].Id; var result = new Result(); try { var isBarCodeExists = _ckdService.GetCkdMmiMasterInfo(new tblCkdMmiMaster { BarCode = mmItabltestComponent.BarCode }) .Any(); if (isBarCodeExists) { mmItabltestComponent.AddedBy = userId; mmItabltestComponent.AddedDate = DateTime.Now; mmItabltestComponent.UpdatedBy = userId; mmItabltestComponent.UpdatedDate = DateTime.Now; result = _ckdService.UpdateCkdMmiInfo(mmItabltestComponent); if (result.IsSuccess == true && mmItabltestComponent.Passed.ToUpper() == "N") { var Reresult = new Result(); var rework = new tblCkdRework(); foreach (tblCkdRework item in reworkList) { rework.LineId = lineId; rework.ProjectId = userId; //projectId; rework.BarCode = item.BarCode; rework.Issues = item.Issues; rework.FailedStation = item.FailedStation; rework.Type = item.Type; rework.Model = item.Model; rework.LotNumber = item.LotNumber; rework.Supplier = item.Supplier; rework.Code = item.Code; rework.Status = "P"; rework.AddedBy = userId; rework.AddedDate = DateTime.Now; Reresult = _ckdService.InsertCkdRework(rework); } } } else { mmItabltestComponent.LineId = lineId; mmItabltestComponent.AddedBy = userId; mmItabltestComponent.AddedDate = DateTime.Now; mmItabltestComponent.UpdatedBy = userId; mmItabltestComponent.UpdatedDate = DateTime.Now; result = _ckdService.InsertCkdMmiComponentInfo(mmItabltestComponent); if (result.IsSuccess == true && mmItabltestComponent.Passed.ToUpper() == "N") { var Reresult = new Result(); tblCkdRework rework = new tblCkdRework(); foreach (tblCkdRework item in reworkList) { rework.LineId = lineId; rework.ProjectId = userId; //projectId; rework.BarCode = item.BarCode; rework.Issues = item.Issues; rework.FailedStation = item.FailedStation; rework.Type = item.Type; rework.Model = item.Model; rework.LotNumber = item.LotNumber; rework.Supplier = item.Supplier; rework.Code = item.Code; rework.Status = "P"; rework.AddedBy = userId; rework.AddedDate = DateTime.Now; Reresult = _ckdService.InsertCkdRework(rework); } } } } catch (Exception ex) { //throw ex; result.Message = ex.ToString(); } return(Json(result)); }