public IActionResult UserDetailMaintenance(string Event)
        {
            var             Event_       = Event == null ? "_partsUserInfo" : Event;
            var             UserName     = User.Identity.Name;
            vewOperatorAlls dataOperator = new vewOperatorAlls();

            dataOperator = _sptoDbContext.vewOperatorAll.FirstOrDefault(x => x.OperatorID == UserName);

            ViewBag.NameEng  = dataOperator.NameEng;
            ViewBag.JobTitle = dataOperator.JobTitle;


            ViewBag.NameEngUserDetail  = dataOperator.NameEng;
            ViewBag.JobTitleUserDetail = dataOperator.JobTitle;
            var varsd = "http://10.29.1.12/RAJPTrainingControlSystem/PIC/" + UserName + ".jpg";

            ViewBag.imgProfileUserDetail = varsd;
            ViewBag.imgProfile           = varsd;

            ViewBag.Event = Event_;
            string IPAddress = "";

            ViewBag.IPAddress = IPAddress;
            return(View());
        }
        public JsonResult GetUpdateUserdetail(vewOperatorAlls dataDetail, List <vewOperatorLicense> dataLicenses,
                                              string OpNo)
        {
            var _Result      = "OK";
            var _DataResult  = "";
            var _ResultLabel = true;

            try
            {
                var           dataOperator = new vewOperatorAlls();
                mgrSQLcommand ObjRun       = new mgrSQLcommand(_configuration);
                string[]      Result       = ObjRun.GetUpdUserdetail(dataDetail, dataLicenses, OpNo, GetIp());
                _ResultLabel = Convert.ToBoolean(Result[0]);
                _Result      = Result[1];
                _DataResult  = _Result != "OK" ? _Result : "";
            }
            catch (Exception e)
            {
                _ResultLabel = false;
                _Result      = "Error";
                _DataResult  = e.Message;
            }

            var jsonResult = Json(new
                                  { strResult = _Result, dataLabel = _DataResult, strboolbel = _ResultLabel, data = "" });

            return(jsonResult);
        }
        public JsonResult GetDataUserdetail(string opno)
        {
            var                       _Result      = "OK";
            var                       _DataResult  = "";
            var                       _ResultLabel = true;
            vewOperatorAlls           dataOperator = new vewOperatorAlls();
            List <vewOperatorLicense> dataLicenses = new List <vewOperatorLicense>();

            var data_ = _sptoDbContext.vewOperatorAll.FirstOrDefault(x => x.OperatorID == opno);

            dataOperator = data_;
            mgrSQLcommand ObjRun = new mgrSQLcommand(_configuration);

            dataLicenses = ObjRun.GetUserLicense(opno);

            _Result     = dataOperator != null ? "OK" : "error";
            _DataResult = _Result != "OK" ? "Data not found" : "";



            ViewBag.NameEngUserDetail  = dataOperator.NameEng;
            ViewBag.JobTitleUserDetail = dataOperator.JobTitle;
            var varsd = "http://10.29.1.12/RAJPTrainingControlSystem/PIC/" + opno + ".jpg";

            ViewBag.imgProfileUserDetail = varsd;
            var jsonResult = Json(new
            {
                strResult   = _Result, dataLabel = _DataResult, strboolbel = _ResultLabel, data = dataOperator,
                dataLicense = dataLicenses, DataProfile = varsd
            });

            return(jsonResult);
        }
Пример #4
0
        public IActionResult Index()
        {
            var             UserName     = User.Identity.Name;
            vewOperatorAlls dataOperator = new vewOperatorAlls();

            dataOperator     = _sptoDbContext.vewOperatorAll.FirstOrDefault(x => x.OperatorID == UserName);
            ViewBag.NameEng  = dataOperator.NameEng;
            ViewBag.JobTitle = dataOperator.JobTitle;
            var varsd = "http://10.29.1.12/RAJPTrainingControlSystem/PIC/" + UserName + ".jpg";

            ViewBag.imgProfile = varsd;
            return(View());
        }
Пример #5
0
        public JsonResult Profile(string OPID)
        {
            var UserName = OPID;

            vewOperatorAlls dataOperator = new vewOperatorAlls();

            dataOperator = _sptoDbContext.vewOperatorAll.FirstOrDefault(x => x.OperatorID == UserName);
            var Name     = dataOperator.NameEng;
            var JobTitle = dataOperator.JobTitle;
            var varsd    = "http://10.29.1.12/RAJPTrainingControlSystem/PIC/" + UserName + ".jpg";

            var jsonResult = Json(new{ data = varsd, strName = Name, strJobTitle = JobTitle });

            return(jsonResult);
        }
        public async Task <IActionResult> UserInCharge(int?page, string opno)
        {
            ViewBag.opno = opno;

            if (ViewBag.opno == null)
            {
                opno = TempData["opno"].ToString();
            }

            const int padgeSize = 5;

            var queryuser = _sptoDbContext.sprOperatorShowListInChang.FromSql($"sprOperatorShowListInChang {opno}").ToList().ToPagedList(page ?? 1, padgeSize);
            //var tempval = TempData.Peek<TempReqChange>("datareqchange");


            // Get data list user request
            var queryvalue = await _sptoDbContext.TempReqChange.Where(x => x.ReqOperatorID == opno& x.SendReqFlag == false).ToListAsync();


            if (queryvalue.Count != 0)
            {
                ViewBag.Collection = queryvalue;
            }



            var             UserName     = User.Identity.Name;
            vewOperatorAlls dataOperator = new vewOperatorAlls();

            dataOperator = _sptoDbContext.vewOperatorAll.FirstOrDefault(x => x.OperatorID == UserName);

            ViewBag.NameEng  = dataOperator.NameEng;
            ViewBag.JobTitle = dataOperator.JobTitle;


            ViewBag.NameEngUserDetail  = dataOperator.NameEng;
            ViewBag.JobTitleUserDetail = dataOperator.JobTitle;
            var varsd = "http://10.29.1.12/RAJPTrainingControlSystem/PIC/" + UserName + ".jpg";

            ViewBag.imgProfileUserDetail = varsd;
            ViewBag.imgProfile           = varsd;



            return(View(queryuser));
        }
Пример #7
0
        public string[] GetUpdUserdetail(vewOperatorAlls _Data, List <vewOperatorLicense> _DataLicense, string OpNo, string strIpAddress)
        {
            mgrSQLConnect ObjRun = new mgrSQLConnect(_configuration);

            dt = new DataTable();
            string DataMgs, strFlag;
            var    results = true;

            strSQL = "";
            string[] Result;
            strFlag = "UPD";
            try
            {
                string DataLicense = "";
                foreach (vewOperatorLicense i in _DataLicense)
                {
                    DataLicense += ";" + i.License;
                }


                strSQL += "Exec [sprOperator]";
                strSQL += "'" + strFlag + "',";                                              //flag
                strSQL += "'" + _Data.OperatorID + "',";
                strSQL += "'" + _Data.Password + "',";
                strSQL += "'" + _Data.NameEng + "',";
                strSQL += "N'" + _Data.NameThai + "',";
                strSQL += "'" + _Data.SectionCode + "',";
                strSQL += "'" + _Data.OperatorGroup + "',";
                strSQL += "'" + _Data.Position + "',";
                strSQL += "'" + _Data.JobTitle + "',";
                strSQL += "'" + _Data.Email1 + "',";
                strSQL += "'" + _Data.Email2 + "',";
                strSQL += "'" + _Data.RFID + "',";
                strSQL += "'" + _Data.Authority + "',";
                strSQL += "'" + _Data.Active + "',";
                strSQL += "'" + OpNo + "',";
                strSQL += "'" + strIpAddress + "';";



                strSQL += "   Exec [sprOperatorLicense]";
                strSQL += "'" + _Data.OperatorID + "'";
                strSQL += ",'" + DataLicense.Substring(1) + "'";
                strSQL += ",'" + OpNo + "'";
                strSQL += ",'" + strIpAddress + "';";



                dt = ObjRun.GetDatatables(strSQL);
                if (dt.Rows.Count > 0)
                {
                    Result = new[] { dt.Rows[0][0].ToString(), dt.Rows[0][1].ToString() };
                }
                else
                {
                    results = false;
                    Result  = new[] { results.ToString(), "Error " };
                }
            }
            catch (Exception e)
            {
                DataMgs = e.Message + ":" + strSQL;
                results = false;
                Result  = new[] { results.ToString(), DataMgs };
            }
            return(Result);
        }
        public async Task <IActionResult> Login(string OperatorID, string Password, vewOperatorAlls model, string returnUrl = null)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            if (!string.IsNullOrEmpty(OperatorID) && string.IsNullOrEmpty(Password))
            {
                return(RedirectToAction("Login"));
            }

            //Check the user name and password
            //Here can be implemented checking logic from the database
            ClaimsIdentity identity        = null;
            var            isAuthenticated = false;
            string         authority       = null;
            var            active          = false;
            var            querylogin      = await _sptoDbContext.vewOperatorAll
                                             .Where(x => x.OperatorID == OperatorID && x.Password == Password)
                                             .Select(c => new { c.OperatorID, c.Active, c.Authority }).FirstOrDefaultAsync();


            if (querylogin != null)
            {
                //foreach (var item in querylogin)
                //{
                //    authority = item.Authority;
                //    active = item.Active;
                //}

                authority = querylogin.Authority;
                active    = querylogin.Active;

                if (active == false)
                {
                    return(RedirectToAction("Login"));
                }

                switch (authority)
                {
                case "9":
                    //Create the identity for the Admin
                    identity = new ClaimsIdentity(new[]
                    {
                        new Claim(ClaimTypes.Name, model.OperatorID),

                        new Claim(ClaimTypes.Role, "Admin"),
                    }, CookieAuthenticationDefaults.AuthenticationScheme);

                    isAuthenticated = true;
                    break;

                case "7":
                    //Create the identity for the Training
                    identity = new ClaimsIdentity(new[]
                    {
                        new Claim(ClaimTypes.Name, model.OperatorID),
                        new Claim(ClaimTypes.Role, "Training")
                    }, CookieAuthenticationDefaults.AuthenticationScheme);

                    isAuthenticated = true;
                    break;

                case "0":
                    //Create the identity for the user
                    identity = new ClaimsIdentity(new[]
                    {
                        new Claim(ClaimTypes.Name, model.OperatorID),
                        new Claim(ClaimTypes.Role, "User")
                    }, CookieAuthenticationDefaults.AuthenticationScheme);

                    isAuthenticated = true;
                    break;
                }
            }
            else
            {
                ModelState.AddModelError("", "Invalid Operator No. or Password");
                return(View());
            }



            if (!isAuthenticated)
            {
                return(View());
            }
            var principal = new ClaimsPrincipal(identity);

            var login = HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal);

            return(RedirectToLocal(returnUrl));
            //return RedirectToAction("Index", "Home");
        }
        public async Task <IActionResult> EditUserInCharge(int?pageaddition, string opnoedit)
        {
            //if (opnoedit == null)
            //{
            //    return NotFound();
            //}

            //var sectadditionid = HttpContext.Request.Form["sectListAdditional"].ToString();



            var Getuser = await _sptoDbContext.vewOperatorAll.FirstOrDefaultAsync(x => x.OperatorID == opnoedit);

            if (Getuser != null)
            {
                ViewBag.opnoreq = Getuser.OperatorID;
                ViewBag.namereq = Getuser.NameEng;
            }


            //Get Current Organize
            var queryOrganize = await _sptoDbContext.vewOperatorAll.Where(x => x.OperatorID == opnoedit)
                                .Select(c => new
            {
                division     = c.Division,
                department   = c.Department,
                section      = c.Section,
                shift        = c.GroupName,
                statusresign = (c.Active ? "Active" : "Not Active")
            })
                                .ToListAsync();

            foreach (var item in queryOrganize)
            {
                ViewBag.CategoryDivision   = item.division;
                ViewBag.CategoryDepartment = item.department;
                ViewBag.CategorySection    = item.section;
                ViewBag.CategoryShift      = item.shift;
                ViewBag.CategoryResign     = item.statusresign;
            }



            //Get Current License to Dropdown
            var queryLicense = await _sptoDbContext.vewOperatorLicense.Where(x => x.OperatorID == opnoedit)
                               .Select(c => new { c.OperatorID, c.License }).ToListAsync();

            ViewBag.CategoryLicense = new MultiSelectList(queryLicense.AsEnumerable(), "OperatorID", "License");



            List <SelectListItem> categoryResign = new List <SelectListItem>()
            {
                new SelectListItem
                {
                    Text = "Active", Value = "True"
                },
                new SelectListItem
                {
                    Text = "Not Active", Value = "False"
                }
            };

            ViewBag.ResignMaster = categoryResign;

            //Binding for select dropdownlist shift
            var shiftmaster = await _sptoDbContext.vewOperatorGroupMaster
                              .Select(c => new { c.OperatorGroup, c.GroupName }).ToListAsync();

            ViewBag.CategoryShiftmaster = new SelectList(shiftmaster.AsEnumerable(), "OperatorGroup", "GroupName");


            //Binding for select dropdownlist Division


            var catagoryDivlist = await _sptoDbContext.vewDivisionMaster
                                  .Select(v => new
            {
                DivisionID   = v.row_num,
                Divisionname = v.DivisionName
            }).ToListAsync();



            // ------- Inserting Select Item in Division List -------

            ViewBag.listofCatagoryDiv = new SelectList(catagoryDivlist, "DivisionID", "Divisionname");


            //Binding for select dropdownlist License
            var licensecatagory = await _sptoDbContext.vewLicenseMaster
                                  .Select(v => new { License = v.License.ToString().Trim(), v.LicenseID }).ToListAsync();

            ViewBag.licensecatagory = new MultiSelectList(licensecatagory.AsEnumerable(), "License", "License");


            const int padgeSizeAddition = 5;
            var       listadditional    = await _sptoDbContext.vewOperatorAdditionalDep
                                          .Where(x => x.OperatorID == opnoedit)
                                          .Select(s => new additionalist()
            {
                Division    = s.Division,
                Department  = s.Department,
                Section     = s.Section,
                SectionCode = s.SectionCode
            }).ToPagedListAsync(pageaddition ?? 1, padgeSizeAddition);

            ViewBag.opnoedit          = opnoedit;
            ViewBag.AdditionalCurrent = listadditional;


            // Div. Additional
            var divlistAdditional = await _sptoDbContext.vewDivisionMaster
                                    .Select(v => new
            {
                DivisionID   = v.row_num,
                Divisionname = v.DivisionName
            }).ToListAsync();



            // ------- Inserting Select Item in Division List -------

            ViewBag.listofDivAdditional = new SelectList(divlistAdditional, "DivisionID", "Divisionname");



            var             userName     = User.Identity.Name;
            vewOperatorAlls dataOperator = new vewOperatorAlls();

            dataOperator = _sptoDbContext.vewOperatorAll.FirstOrDefault(x => x.OperatorID == userName);

            ViewBag.NameEng  = dataOperator.NameEng;
            ViewBag.JobTitle = dataOperator.JobTitle;


            ViewBag.NameEngUserDetail  = dataOperator.NameEng;
            ViewBag.JobTitleUserDetail = dataOperator.JobTitle;
            var varsd = "http://10.29.1.12/RAJPTrainingControlSystem/PIC/" + userName + ".jpg";

            ViewBag.imgProfileUserDetail = varsd;
            ViewBag.imgProfile           = varsd;



            return(View());
        }