public ActionResult SearchUser(int idWorkzone, string nome = "")
        {
            ModelState.Clear();
            tblWorkzone workzone;

            workzone = _workzone.GetWorkzoneById(idWorkzone);

            /* SELECIONA FUNCIONÁRIOS ADICIONADOS NESSA WZ*/
            IEnumerable <tblFuncionarios> employeeAdded;

            employeeAdded = _workzone.setUpEmployees(idWorkzone);
            IEnumerable <tblFuncionarios> funcFiltrados;

            funcFiltrados = _employee.GetEmployeeByName(nome, idWorkzone);

            ViewBag.Name                        = nome;
            ViewData["Funcionarios"]            = funcFiltrados;
            ViewData["FuncionariosAdicionados"] = employeeAdded;

            FuncListModel Func = new FuncListModel();

            Func.idWorkzone        = idWorkzone;
            Func.funcionariosAdded = employeeAdded;
            Func.funcionarios      = funcFiltrados;
            UpdateModel(Func);

            //return RedirectToAction("Details", new { id = workzone.IdWorkzone, nome = nome });

            return(PartialView("_Lista", Func));
        }
        //GET: workzone/Details/5
        //[AccessHelper(Menu = MenuHelper.VisualizacaoCadastro, Screen = ScreensHelper.PostodeTrabalho, Feature = FeaturesHelper.Editar)]
        public ActionResult Details(int id, string nome = "")
        {
            FuncListModel Func = new FuncListModel();

            Func.idWorkzone = id;
            var x = ViewBag.Name;

            ModelState.Clear();
            ViewData.Clear();
            UpdateModel(ViewData);
            /*  MONTANDO SELECT LIST BU, CC E LINHA*/
            setBUCCLINHA(id);
            /*FINALIZANDO SELECT LISTA BU, CC E LINHA*/

            SetImage();

            tblWorkzone workzone;

            workzone = _workzone.GetWorkzoneById(id);
            /*SELECIONA FUNCIONÁRIOS EXISTENTES*/
            IEnumerable <tblFuncionarios> employee;

            if (nome.Length > 0)
            {
                employee = _employee.GetEmployeeByName(nome, id);
            }
            else
            {
                employee = _employee.GetEmployees();
            }
            Func.funcionarios        = employee;
            ViewData["Funcionarios"] = employee;

            /* SELECIONA FUNCIONÁRIOS ADICIONADOS NESSA WZ*/
            IEnumerable <tblFuncionarios> employeeAdded;

            employeeAdded          = _workzone.setUpEmployees(id);
            Func.funcionariosAdded = employeeAdded;

            ViewData["FuncionariosAdicionados"] = employeeAdded;

            if (workzone == null)
            {
                return(View("Index"));
            }

            return(View("Edit", workzone));
        }
Exemplo n.º 3
0
        public FuncListModel GetFuncMenu(string email, string passw)
        {
            FuncListModel resp = new FuncListModel();

            try
            {
                resp.func = new List <FuncModel>();

                string query = string.Format(
                    @"select C.seq,D.code, D.name_thai AS func_name, 
                        D.route_path, D.icon_name, D.func_type, D.func_ref_sub
                        from [dbo].[SYS_ACCOUNT] A
                        INNER JOIN [dbo].[SYS_PERMISSION_GROUP] B
                        ON A.account_id = B.account_id
                        INNER JOIN [dbo].[SYS_PERMISSION_FUNCTION] C
                        ON B.group_code = C.group_code
                        INNER JOIN [dbo].[SYS_FUNCTION] D
                        ON C.func_code = D.code
                        WHERE A.email='{0}'AND A.password='******'
                        ORDER BY b.group_code,c.seq ASC", email, passw);

                using (MSSql mssql = new MSSql(DBConnectionType.RBAC, _EnvironmentModel))
                {
                    var dt = mssql.GetDataTableFromQueryStr(query);

                    if (dt.Rows.Count > 0)
                    {
                        foreach (DataRow dr in dt.Rows)
                        {
                            string func_type = dr["func_type"].ToString();

                            if (func_type == "Main" || func_type == "MainSub")
                            {
                                FuncModel func_model = new FuncModel()
                                {
                                    seq      = Convert.ToInt32(dr["seq"]),
                                    key      = dr["code"].ToString(),
                                    icon     = dr["icon_name"].ToString(),
                                    path     = func_type == "MainSub" ? null : dr["route_path"].ToString(),
                                    sub_item = new List <SubFuncModel>(),
                                };
                                resp.func.Add(func_model);
                            }
                            if (func_type == "Divider")
                            {
                                FuncModel func_model = new FuncModel()
                                {
                                    seq     = Convert.ToInt32(dr["seq"]),
                                    divider = true,
                                };
                                resp.func.Add(func_model);
                            }
                        }
                        foreach (DataRow dr in dt.Rows)
                        {
                            string func_type = dr["func_type"].ToString();

                            if (func_type == "SubMenu")
                            {
                                SubFuncModel sub_item = new SubFuncModel()
                                {
                                    seq  = Convert.ToInt32(dr["seq"]),
                                    key  = dr["code"].ToString(),
                                    icon = dr["icon_name"].ToString(),
                                    path = dr["route_path"].ToString(),
                                };
                                int indexFunc = resp.func.FindIndex(e => e.key != null && e.key == dr["func_ref_sub"].ToString());
                                resp.func[indexFunc].sub_item.Add(sub_item);
                            }
                        }
                        return(resp);
                    }
                }
            }
            catch (Exception ex)
            {
                _ILogs.LogError("Function Application: ", ex.Message.ToString(), ex.StackTrace);
            }
            return(null);
        }