Beispiel #1
0
        public void UpdateList(Models.MenuLinkList list)
        {
            var existingList = GetListById(list.Id);

            if (existingList != null)
            {
                existingList.Attach(list);
            }
            else
            {
                existingList = list;
            }

            AddOrUpdate(existingList);
            UnitOfWork.Commit();

            var ids = new List <string>();

            foreach (var link in existingList.MenuLinks)
            {
                if (!list.MenuLinks.Any(l => l.Id == link.Id))
                {
                    ids.Add(link.Id);
                }
            }

            foreach (var id in ids)
            {
                var link = MenuLinks.First(m => m.Id == id);
                Remove(link);
            }

            UnitOfWork.Commit();
        }
Beispiel #2
0
    public MenuLinks ReceiveHtml()
    {
        MenuLinks menuLinks = new MenuLinks();

        menuLinks.MenuLinksID     = (txtMenuLinksID.Value != "") ? Convert.ToInt32(txtMenuLinksID.Value) : 0;
        menuLinks.MenuLinksName   = (txtMenuLinksName.Text != "") ? txtMenuLinksName.Text.Trim() : "";
        menuLinks.MenuLinksOrder  = 0;
        menuLinks.MenuLinksParent = (ddlMenuLinks.SelectedValue != "") ? Convert.ToInt32(ddlMenuLinks.SelectedValue) : 0;
        menuLinks.MenuLinksUrl    = (txtMenuLinksUrl.Text != "") ? txtMenuLinksUrl.Text.Trim() : "";
        menuLinks.MenuLinksHelp   = txtRadHelp.Text;
        menuLinks.MenuLinksIcon   = (txtimage4_3.Text != "") ? txtimage4_3.Text : hddIcon.Value;
        menuLinks.FileName        = (txtFileName.Text != "") ? txtFileName.Text : hddFile.Value;

        menuLinks.Status   = rdbStatus.Checked;
        menuLinks.IsView   = rdbIsView.Checked;
        menuLinks.IsFlash  = chkFlash.Checked;
        menuLinks.Target   = ddlTarget.SelectedValue;
        menuLinks.Position = (txtPosition.Text != "") ? txtPosition.Text.Trim() : "";
        menuLinks.Width    = Convert.ToInt32(txtWidth.Text);
        menuLinks.Height   = Convert.ToInt32(txtHeight.Text);

        menuLinks.Hit      = (hddHit.Value != "") ? Convert.ToInt32(hddHit.Value) : 0;
        menuLinks.Language = Language.language;
        return(menuLinks);
    }
        public virtual object Clone()
        {
            var result = MemberwiseClone() as MenuLinkList;

            result.MenuLinks = MenuLinks?.Select(x => x.Clone()).OfType <MenuLink>().ToList();

            return(result);
        }
Beispiel #4
0
    protected void ddlMenuLinks_SelectedIndexChanged(object sender, EventArgs e)
    {
        MenuLinksBSO menuLinksBSO  = new MenuLinksBSO();
        MenuLinks    menuLinksRows = menuLinksBSO.GetMenuLinksById(Convert.ToInt32(ddlMenuLinks.SelectedValue));

        if (menuLinksRows != null)
        {
            txtPosition.Text = menuLinksRows.Position;
            txtWidth.Text    = menuLinksRows.Width.ToString();
            txtHeight.Text   = menuLinksRows.Height.ToString();
        }
    }
Beispiel #5
0
    protected void Edit()
    {
        MenuLinksBSO menuLinksBSO = new MenuLinksBSO();
        MenuLinks    menuLinks    = ReceiveHtml();

        try
        {
            menuLinksBSO.EditMenuLinks(menuLinks);
            clientview.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Cập nhật thành công !</div>";
            initControl(menuLinks.MenuLinksID);
        }
        catch (Exception ex)
        {
            clientview.Text = ex.Message.ToString();
        }
    }
Beispiel #6
0
    protected void Add()
    {
        MenuLinksBSO menuLinksBSO = new MenuLinksBSO();
        MenuLinks    menuLinks    = ReceiveHtml();

        try
        {
            int id = menuLinksBSO.AddMenuLinks(menuLinks);
            clientview.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Thêm mới thành công !</div>";
            initControl(id);
        }
        catch (Exception ex)
        {
            clientview.Text = ex.Message.ToString();
        }
    }
Beispiel #7
0
    protected void btn_add_Click_more(object sender, EventArgs e)
    {
        MenuLinksBSO menuLinksBSO = new MenuLinksBSO();
        MenuLinks    menuLinks    = ReceiveHtml();

        try
        {
            int id = menuLinksBSO.AddMenuLinks(menuLinks);
            clientview.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Thêm mới thành công !</div>";
            BindDropDownList();
            AspNetCache.Reset();
        }
        catch (Exception ex)
        {
            clientview.Text = ex.Message.ToString();
        }
    }
Beispiel #8
0
        public int CreateMenuLinks(MenuLinks menuLinks)
        {
            int i;

            using (SqlConnection connection = GetConnection())
            {
                SqlCommand command = new SqlCommand("_MenuLinksInsert", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@Type", 0);
                command.Parameters.AddWithValue("@MenuLinksID", 1);
                command.Parameters.AddWithValue("@MenuLinksName", menuLinks.MenuLinksName);
                command.Parameters.AddWithValue("@MenuLinksParent", menuLinks.MenuLinksParent);
                command.Parameters.AddWithValue("@MenuLinksUrl", menuLinks.MenuLinksUrl);
                command.Parameters.AddWithValue("@MenuLinksOrder", menuLinks.MenuLinksOrder);
                command.Parameters.AddWithValue("@MenuLinksHelp", menuLinks.MenuLinksHelp);
                command.Parameters.AddWithValue("@MenuLinksIcon", menuLinks.MenuLinksIcon);
                command.Parameters.AddWithValue("@Status", menuLinks.Status);
                command.Parameters.AddWithValue("@IsView", menuLinks.IsView);
                command.Parameters.AddWithValue("@Target", menuLinks.Target);
                command.Parameters.AddWithValue("@IsFlash", menuLinks.IsFlash);
                command.Parameters.AddWithValue("@FileName", menuLinks.FileName);
                command.Parameters.AddWithValue("@Position", menuLinks.Position);
                command.Parameters.AddWithValue("@Width", menuLinks.Width);
                command.Parameters.AddWithValue("@Height", menuLinks.Height);
                command.Parameters.AddWithValue("@Hit", menuLinks.Hit);
                command.Parameters.AddWithValue("@Language", menuLinks.Language);

                SqlParameter parameter = new SqlParameter("@ReturnId", SqlDbType.Int);
                parameter.Direction = ParameterDirection.ReturnValue;
                command.Parameters.Add(parameter);
                connection.Open();
                if (command.ExecuteNonQuery() <= 0)
                {
                    throw new DataAccessException("Khong them duoc san pham");
                }
                else
                {
                    i = (int)parameter.Value;
                    command.Dispose();
                }
            }
            return(i);
        }
Beispiel #9
0
        public int UpdateMenuLinks(MenuLinks menuLinks)
        {
            int i;

            using (SqlConnection connection = GetConnection())
            {
                SqlCommand command = new SqlCommand("_MenuLinksUpdate", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@Type", 1);
                command.Parameters.AddWithValue("@MenuLinksID", menuLinks.MenuLinksID);
                command.Parameters.AddWithValue("@MenuLinksName", menuLinks.MenuLinksName);
                command.Parameters.AddWithValue("@MenuLinksParent", menuLinks.MenuLinksParent);
                command.Parameters.AddWithValue("@MenuLinksUrl", menuLinks.MenuLinksUrl);
                command.Parameters.AddWithValue("@MenuLinksOrder", menuLinks.MenuLinksOrder);
                command.Parameters.AddWithValue("@MenuLinksHelp", menuLinks.MenuLinksHelp);
                command.Parameters.AddWithValue("@MenuLinksIcon", menuLinks.MenuLinksIcon);
                command.Parameters.AddWithValue("@Status", menuLinks.Status);
                command.Parameters.AddWithValue("@IsView", menuLinks.IsView);
                command.Parameters.AddWithValue("@Target", menuLinks.Target);
                command.Parameters.AddWithValue("@IsFlash", menuLinks.IsFlash);
                command.Parameters.AddWithValue("@FileName", menuLinks.FileName);
                command.Parameters.AddWithValue("@Position", menuLinks.Position);
                command.Parameters.AddWithValue("@Width", menuLinks.Width);
                command.Parameters.AddWithValue("@Height", menuLinks.Height);
                command.Parameters.AddWithValue("@Hit", menuLinks.Hit);
                command.Parameters.AddWithValue("@Language", menuLinks.Language);
                connection.Open();
                i = command.ExecuteNonQuery();
                if (i <= 0)
                {
                    throw new DataAccessException("lỗi không thể cập nhật");
                }
                else
                {
                    return(i);
                }
            }
        }
Beispiel #10
0
 public MenuLinks GetMenuLinksById(int ID)
 {
     using (SqlConnection connection = GetConnection())
     {
         SqlCommand command = new SqlCommand("_MenuLinksGetById", connection);
         command.CommandType = CommandType.StoredProcedure;
         command.Parameters.AddWithValue("@MenuLinksID", ID);
         connection.Open();
         MenuLinks menuLinks = null;
         using (SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection))
         {
             if (reader.Read())
             {
                 menuLinks = MenuLinksReader(reader);
             }
             else
             {
                 throw new DataAccessException("Lỗi : Không tìm thấy giá trị .. ");
             }
         }
         return(menuLinks);
     }
 }
Beispiel #11
0
        private MenuLinks MenuLinksReader(SqlDataReader reader)
        {
            MenuLinks menuLinks = new MenuLinks();

            menuLinks.MenuLinksID     = (int)reader["MenuLinksID"];
            menuLinks.MenuLinksName   = (string)reader["MenuLinksName"];
            menuLinks.MenuLinksOrder  = (int)reader["MenuLinksOrder"];
            menuLinks.MenuLinksParent = (int)reader["MenuLinksParent"];
            menuLinks.MenuLinksUrl    = (string)reader["MenuLinksUrl"];
            menuLinks.MenuLinksHelp   = (string)reader["MenuLinksHelp"];
            menuLinks.MenuLinksIcon   = (string)reader["MenuLinksIcon"];
            menuLinks.Status          = (bool)reader["Status"];
            menuLinks.IsView          = (bool)reader["IsView"];
            menuLinks.Target          = (string)reader["Target"];
            menuLinks.IsFlash         = (bool)reader["IsFlash"];
            menuLinks.FileName        = (string)reader["FileName"];
            menuLinks.Position        = (string)reader["Position"];
            menuLinks.Width           = (int)reader["Width"];
            menuLinks.Height          = (int)reader["Height"];
            menuLinks.Hit             = (int)reader["Hit"];
            menuLinks.Language        = (string)reader["Language"];
            return(menuLinks);
        }
Beispiel #12
0
        public int EditMenuLinks(MenuLinks _menuLinks)
        {
            MenuLinksDAO menuLinksDAO = new MenuLinksDAO();

            return(menuLinksDAO.UpdateMenuLinks(_menuLinks));
        }
Beispiel #13
0
        public int AddMenuLinks(MenuLinks _menuLinks)
        {
            MenuLinksDAO menuLinksDAO = new MenuLinksDAO();

            return(menuLinksDAO.CreateMenuLinks(_menuLinks));
        }
Beispiel #14
0
    protected void initControl(int ID)
    {
        if (ID > 0)
        {
            txtMenuLinksID.Value = Convert.ToString(ID);
            btn_add.Visible      = false;
            btn_edit.Visible     = true;

            btn_add1.Visible  = false;
            btn_add2.Visible  = false;
            btn_edit1.Visible = true;
            try
            {
                MenuLinksBSO menuLinksBSO = new MenuLinksBSO();

                MenuLinks menuLinksRows = menuLinksBSO.GetMenuLinksById(ID);
                ddlMenuLinks.SelectedValue = menuLinksRows.MenuLinksParent.ToString();
                txtMenuLinksName.Text      = menuLinksRows.MenuLinksName;
                txtMenuLinksUrl.Text       = menuLinksRows.MenuLinksUrl;
                txtRadHelp.Text            = menuLinksRows.MenuLinksHelp;
                hddIcon.Value    = menuLinksRows.MenuLinksIcon;
                hddFile.Value    = menuLinksRows.FileName;
                txtimage4_3.Text = menuLinksRows.MenuLinksIcon;
                txtFileName.Text = menuLinksRows.FileName;

                rdbStatus.Checked       = menuLinksRows.Status;
                rdbIsView.Checked       = menuLinksRows.IsView;
                chkFlash.Checked        = menuLinksRows.IsFlash;
                txtPosition.Text        = menuLinksRows.Position;
                ddlTarget.SelectedValue = menuLinksRows.Target.ToString();
                txtWidth.Text           = menuLinksRows.Width.ToString();
                txtHeight.Text          = menuLinksRows.Height.ToString();
                hddHit.Value            = menuLinksRows.Hit.ToString();

                if (menuLinksRows.IsFlash)
                {
                    txtFileName.Visible   = true;
                    panelFilename.Visible = true;
                }
                else
                {
                    txtFileName.Visible   = false;
                    panelFilename.Visible = false;
                }

                if (menuLinksRows.MenuLinksIcon != "")
                {
                    img_thumb.Text = "<img src='" + menuLinksRows.MenuLinksIcon + "' width='48px'>";
                }
                if (menuLinksRows.IsFlash && menuLinksRows.FileName != "")
                {
                    ltlFileName.Text = "<a href='" + menuLinksRows.FileName + "' target = '_blank'>File Flash</a>";
                }
            }
            catch (Exception ex)
            {
                clientview.Text = ex.Message.ToString();
            }
        }
        else
        {
            ddlMenuLinks.SelectedIndex = 0;
            btn_add.Visible            = true;
            btn_edit.Visible           = false;

            btn_add1.Visible  = true;
            btn_add2.Visible  = true;
            btn_edit1.Visible = false;

            chkFlash.Checked      = false;
            txtFileName.Visible   = false;
            panelFilename.Visible = false;
        }
    }
Beispiel #15
0
 public void Iterate(IEnumerable <XElement> element, MenuLinks menuSub, bool isAdmin, List <MenuRole> roles, string grouptk)
 {
     menuSub.listChild = new List <MenuLinks>();
     foreach (var item in element)
     {
         // kiem tra phan quyen user
         var lstRole = (from n in roles
                        where n.machucnang == (item.Attribute("id") == null ? "" : item.Attribute("id").Value)
                        select n).ToList();
         if ((lstRole.Count > 0 && lstRole.Count == 1) || isAdmin || grouptk == "1")
         {
             MenuLinks mnLink = new MenuLinks()
             {
                 id         = item.Attribute("id") == null ? "" : item.Attribute("id").Value,
                 title      = item.Attribute("title") == null ? "" : item.Attribute("title").Value,
                 controller = item.Attribute("controller") == null ? "" : item.Attribute("controller").Value,
                 action     = item.Attribute("action") == null ? "" : item.Attribute("action").Value,
                 ImageUrl   = item.Attribute("ImageUrl") == null ? "" : item.Attribute("ImageUrl").Value,
                 url        = item.Attribute("url") == null ? "" : item.Attribute("url").Value
             };
             if (item.Elements().Count() > 0)
             {
                 Iterate(item.Elements(), mnLink, isAdmin, roles, grouptk);
             }
             menuSub.listChild.Add(mnLink);
         }
         else if ((item.Attribute("id").Value.ToString() == "1" || item.Attribute("id").Value.ToString() == "2" || item.Attribute("id").Value.ToString() == "3" ||
                   item.Attribute("id").Value.ToString() == "4" || item.Attribute("id").Value.ToString() == "5" || item.Attribute("id").Value.ToString() == "6") &&
                  (grouptk == "2" || grouptk == "4" || grouptk == "3"))
         {
             MenuLinks mnLink = new MenuLinks()
             {
                 id         = item.Attribute("id") == null ? "" : item.Attribute("id").Value,
                 title      = item.Attribute("title") == null ? "" : item.Attribute("title").Value,
                 controller = item.Attribute("controller") == null ? "" : item.Attribute("controller").Value,
                 action     = item.Attribute("action") == null ? "" : item.Attribute("action").Value,
                 ImageUrl   = item.Attribute("ImageUrl") == null ? "" : item.Attribute("ImageUrl").Value,
                 url        = item.Attribute("url") == null ? "" : item.Attribute("url").Value
             };
             if (item.Elements().Count() > 0)
             {
                 Iterate(item.Elements(), mnLink, isAdmin, roles, grouptk);
             }
             menuSub.listChild.Add(mnLink);
         }
         else if ((item.Attribute("id").Value.ToString() == "1" || item.Attribute("id").Value.ToString() == "2" || item.Attribute("id").Value.ToString() == "5" || item.Attribute("id").Value.ToString() == "6") &&
                  (grouptk == "0" || grouptk == ""))
         {
             MenuLinks mnLink = new MenuLinks()
             {
                 id         = item.Attribute("id") == null ? "" : item.Attribute("id").Value,
                 title      = item.Attribute("title") == null ? "" : item.Attribute("title").Value,
                 controller = item.Attribute("controller") == null ? "" : item.Attribute("controller").Value,
                 action     = item.Attribute("action") == null ? "" : item.Attribute("action").Value,
                 ImageUrl   = item.Attribute("ImageUrl") == null ? "" : item.Attribute("ImageUrl").Value,
                 url        = item.Attribute("url") == null ? "" : item.Attribute("url").Value
             };
             if (item.Elements().Count() > 0)
             {
                 Iterate(item.Elements(), mnLink, isAdmin, roles, grouptk);
             }
             menuSub.listChild.Add(mnLink);
         }
     }
 }
Beispiel #16
0
        public List <MenuLinks> ReadMenuConfig(List <MenuRole> roles, bool isAdmin, string grouptk, string phongban_congtruong)
        {
            try
            {
                List <MenuLinks> lstResult = new List <MenuLinks>();
                if (_isFileExist)
                {
                    XElement doc  = XElement.Load(_strPath);
                    var      list = doc.Elements();
                    foreach (var item in list)
                    {
                        var lstRole = (from n in roles
                                       where n.machucnang == (item.Attribute("id") == null ? "" : item.Attribute("id").Value)
                                       select n).ToList();
                        if ((lstRole.Count > 0 && lstRole.Count == 1) || isAdmin)//if ((lstRole.Count > 0 && lstRole.Count == 1) || isAdmin)
                        {
                            MenuLinks mnLink = new MenuLinks()
                            {
                                id         = item.Attribute("id") == null ? "" : item.Attribute("id").Value,
                                title      = item.Attribute("title") == null ? "" : item.Attribute("title").Value,
                                controller = item.Attribute("controller") == null ? "" : item.Attribute("controller").Value,
                                action     = item.Attribute("action") == null ? "" : item.Attribute("action").Value,
                                ImageUrl   = item.Attribute("ImageUrl") == null ? "" : item.Attribute("ImageUrl").Value,
                                url        = item.Attribute("url") == null ? "" : item.Attribute("url").Value
                            };
                            if (item.Elements().Count() > 0)
                            {
                                Iterate(item.Elements(), mnLink, isAdmin, roles, grouptk);
                            }
                            lstResult.Add(mnLink);
                        }

                        else if (grouptk == "1")// Thấy hết tất cả dử liệu của tất cả phòng ban
                        {
                            string    aaa    = item.Attribute("id").Value.ToString();
                            MenuLinks mnLink = new MenuLinks()
                            {
                                id         = item.Attribute("id") == null ? "" : item.Attribute("id").Value,
                                title      = item.Attribute("title") == null ? "" : item.Attribute("title").Value,
                                controller = item.Attribute("controller") == null ? "" : item.Attribute("controller").Value,
                                action     = item.Attribute("action") == null ? "" : item.Attribute("action").Value,
                                ImageUrl   = item.Attribute("ImageUrl") == null ? "" : item.Attribute("ImageUrl").Value,
                                url        = item.Attribute("url") == null ? "" : item.Attribute("url").Value
                            };
                            if (item.Elements().Count() > 0)
                            {
                                Iterate(item.Elements(), mnLink, isAdmin, roles, grouptk);
                            }
                            lstResult.Add(mnLink);
                        }
                        else if (grouptk == "2" || grouptk == "4" || grouptk == "3")//Thấy được dữ liệu tất cả  phòng mình
                        {
                            if (item.Attribute("id").Value.ToString() == "1" || item.Attribute("id").Value.ToString() == "2" || item.Attribute("id").Value.ToString() == "3" ||
                                item.Attribute("id").Value.ToString() == "4" || item.Attribute("id").Value.ToString() == "5" || item.Attribute("id").Value.ToString() == "6")
                            {
                                string    aaa    = item.Attribute("id").Value.ToString();
                                MenuLinks mnLink = new MenuLinks()
                                {
                                    id         = item.Attribute("id") == null ? "" : item.Attribute("id").Value,
                                    title      = item.Attribute("title") == null ? "" : item.Attribute("title").Value,
                                    controller = item.Attribute("controller") == null ? "" : item.Attribute("controller").Value,
                                    action     = item.Attribute("action") == null ? "" : item.Attribute("action").Value,
                                    ImageUrl   = item.Attribute("ImageUrl") == null ? "" : item.Attribute("ImageUrl").Value,
                                    url        = item.Attribute("url") == null ? "" : item.Attribute("url").Value
                                };
                                if (item.Elements().Count() > 0)
                                {
                                    Iterate(item.Elements(), mnLink, isAdmin, roles, grouptk);
                                }
                                lstResult.Add(mnLink);
                            }
                        }

                        else if (grouptk == "" || grouptk == "0")//KPI của nhân viên chỉ thấy dữ liệu cấp phòng và dữ liệu của chính mình và là ns văn phòng
                        {
                            if (item.Attribute("id").Value.ToString() == "1" || item.Attribute("id").Value.ToString() == "2" || item.Attribute("id").Value.ToString() == "5" || item.Attribute("id").Value.ToString() == "6")
                            {
                                string    aaa    = item.Attribute("id").Value.ToString();
                                MenuLinks mnLink = new MenuLinks()
                                {
                                    id         = item.Attribute("id") == null ? "" : item.Attribute("id").Value,
                                    title      = item.Attribute("title") == null ? "" : item.Attribute("title").Value,
                                    controller = item.Attribute("controller") == null ? "" : item.Attribute("controller").Value,
                                    action     = item.Attribute("action") == null ? "" : item.Attribute("action").Value,
                                    ImageUrl   = item.Attribute("ImageUrl") == null ? "" : item.Attribute("ImageUrl").Value,
                                    url        = item.Attribute("url") == null ? "" : item.Attribute("url").Value
                                };
                                if (item.Elements().Count() > 0)
                                {
                                    Iterate(item.Elements(), mnLink, isAdmin, roles, grouptk);
                                }
                                lstResult.Add(mnLink);
                            }
                        }
                    }
                }
                return(lstResult);
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
            }
            return(null);
        }