Example #1
0
        private void InitcboMenuParent()
        {
            cMenu  oMenu         = new cMenu();
            string strMessage    = string.Empty,
                   strCriteria   = string.Empty,
                   strMenuParent = string.Empty;

            strMenuParent = cboMenuParent.SelectedValue;
            int       i;
            DataSet   ds = new DataSet();
            DataTable dt = new DataTable();

            strCriteria = " and [Status]='Y' Order by MenuOrder";
            if (oMenu.SP_MENU_SEL(strCriteria, ref ds, ref strMessage))
            {
                dt = ds.Tables[0];
                cboMenuParent.Items.Clear();
                cboMenuParent.Items.Add(new ListItem("---- เลือกทั้งหมด ----", ""));
                for (i = 0; i <= dt.Rows.Count - 1; i++)
                {
                    cboMenuParent.Items.Add(new ListItem(dt.Rows[i]["MenuName"].ToString(), dt.Rows[i]["MenuID"].ToString()));
                }
                if (cboMenuParent.Items.FindByValue(strMenuParent) != null)
                {
                    cboMenuParent.SelectedIndex = -1;
                    cboMenuParent.Items.FindByValue(strMenuParent).Selected = true;
                }
            }
        }
Example #2
0
        private void setData()
        {
            cMenu   oMenu = new cMenu();
            DataSet ds = new DataSet();
            string  strMessage = string.Empty, strCriteria = string.Empty;

            try
            {
                strCriteria = " and MenuID = '" + ViewState["MenuID"].ToString() + "' ";
                if (!oMenu.SP_MENU_SEL(strCriteria, ref ds, ref strMessage))
                {
                    lblError.Text = strMessage;
                }
                else
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        #region get Data

                        hddMenuID.Value           = ds.Tables[0].Rows[0]["MenuID"].ToString();
                        txtMenuName.Text          = ds.Tables[0].Rows[0]["MenuName"].ToString();
                        hddMenuName.Value         = ds.Tables[0].Rows[0]["MenuName"].ToString();
                        txtMenuNavigationUrl.Text = ds.Tables[0].Rows[0]["MenuNavigationUrl"].ToString();
                        txtMenuImageUrl.Text      = ds.Tables[0].Rows[0]["MenuImageUrl"].ToString();
                        if (cboMenuTarget.Items.FindByValue(ds.Tables[0].Rows[0]["MenuTarget"].ToString()) != null)
                        {
                            cboMenuTarget.SelectedIndex = -1;
                            cboMenuTarget.Items.FindByValue(ds.Tables[0].Rows[0]["MenuTarget"].ToString()).Selected = true;
                        }
                        InitcboMenuParent();
                        if (cboMenuParent.Items.FindByValue(ds.Tables[0].Rows[0]["MenuParent"].ToString()) != null)
                        {
                            cboMenuParent.SelectedIndex = -1;
                            cboMenuParent.Items.FindByValue(ds.Tables[0].Rows[0]["MenuParent"].ToString()).Selected = true;
                        }
                        txtMenuOrder.Value    = ds.Tables[0].Rows[0]["MenuOrder"].ToString();
                        chkCanView.Checked    = ds.Tables[0].Rows[0]["CanView"].ToString() == "Y" ? true : false;
                        chkCanInsert.Checked  = ds.Tables[0].Rows[0]["CanInsert"].ToString() == "Y" ? true : false;
                        chkCanEdit.Checked    = ds.Tables[0].Rows[0]["CanEdit"].ToString() == "Y" ? true : false;
                        chkCanDelete.Checked  = ds.Tables[0].Rows[0]["CanDelete"].ToString() == "Y" ? true : false;
                        chkCanApprove.Checked = ds.Tables[0].Rows[0]["CanApprove"].ToString() == "Y" ? true : false;
                        chkCanExtra.Checked   = ds.Tables[0].Rows[0]["CanExtra"].ToString() == "Y" ? true : false;
                        chkStatus.Checked     = ds.Tables[0].Rows[0]["Status"].ToString() == "Y" ? true : false;
                        txtRemark.Text        = ds.Tables[0].Rows[0]["Remark"].ToString();

                        txtUpdatedBy.Text   = ds.Tables[0].Rows[0]["UpdatedBy"].ToString();;
                        txtUpdatedDate.Text = ds.Tables[0].Rows[0]["UpdatedDate"].ToString() != "" ? cCommon.CheckDate(ds.Tables[0].Rows[0]["UpdatedDate"].ToString()) : "";

                        #endregion
                    }
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
        }
        static void Main(string[] args)
        {
            Console.BackgroundColor = ConsoleColor.DarkBlue;
            Console.ForegroundColor = ConsoleColor.White;
            Console.Clear();

            cMenu menu = new cMenu();

            menu.mostrar();
        }
Example #4
0
        public List <cMenu> GetListMenu(int idtable)
        {
            List <cMenu> listMenu = new List <cMenu>();
            string       query    = "EXEC GetListOrder @idtable";
            DataSet      ds       = db.ExecuteQueryDS(query, CommandType.Text, new object[] { idtable });
            DataTable    dt       = new DataTable();

            dt = ds.Tables[0];

            foreach (DataRow item in dt.Rows)
            {
                cMenu menu = new cMenu(item);
                listMenu.Add(menu);
            }
            return(listMenu);
        }
Example #5
0
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string      strMessage = string.Empty;
            string      strCheck   = string.Empty;
            string      strScript  = string.Empty;
            HiddenField hddMenuID  = (HiddenField)GridView1.Rows[e.RowIndex].FindControl("hddMenuID");
            cMenu       oMenu      = new cMenu();

            try
            {
                if (!oMenu.SP_MENU_DEL(hddMenuID.Value.ToString(), ref strMessage))
                {
                    if (strMessage.Contains("REFERENCE constraint"))
                    {
                        MsgBox("ไม่สามารถลบข้อมูลได้เนื่องจากมีการนำไปใช้ในระบบแล้ว");
                    }
                    else
                    {
                        lblError.Text = strMessage;
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("REFERENCE constraint"))
                {
                    MsgBox("ไม่สามารถลบข้อมูลได้เนื่องจากมีการนำไปใช้ในระบบแล้ว");
                }
                else
                {
                    lblError.Text = ex.Message.ToString();
                }
            }
            finally
            {
                oMenu.Dispose();
            }
            BindGridView(0);
        }
Example #6
0
        public void llenarMenu()
        {
            DataTable dtMenuItems = new DataTable();

            obMenu      = new cMenu();
            dtMenuItems = obMenu.LlenarDoctosUsuarios(Session["id_tipo_usuario"].ToString());

            foreach (DataRow drMenuItem in dtMenuItems.Rows)
            {
                if (drMenuItem["id_menu"].Equals(drMenuItem["PadreId"]))
                {
                    MenuItem mnuMenuItem = new MenuItem();

                    mnuMenuItem.Value = drMenuItem["id_menu"].ToString();
                    mnuMenuItem.Text  = drMenuItem["descripcion"].ToString();

                    //mnuMenuItem.NavigateUrl = drMenuItem["Url"].ToString();
                    MenuP.Items.Add(mnuMenuItem);

                    agregarMenuItem(mnuMenuItem, dtMenuItems);
                }
            }
        }
Example #7
0
        private void BindGridView(int nPageNo)
        {
            cMenu   oMenu        = new cMenu();
            DataSet ds           = new DataSet();
            string  strMessage   = string.Empty;
            string  strCriteria  = string.Empty;
            string  strMenuName  = string.Empty;
            string  stMenuParent = string.Empty;
            string  strUrl       = string.Empty;

            strMenuName  = txtMenuName.Text.Replace("'", "''").Trim();
            strUrl       = txtUrl.Text.Replace("'", "''").Trim();
            stMenuParent = cboMenuParent.SelectedValue;

            if (!strMenuName.Equals(""))
            {
                strCriteria = strCriteria + "  And  (MenuName like '%" + strMenuName + "%') ";
            }

            if (!strUrl.Equals(""))
            {
                strCriteria = strCriteria + "  And  (MenuNavigationUrl like '%" + strUrl + "%') ";
            }

            if (!stMenuParent.Equals(""))
            {
                strCriteria = strCriteria + "  And  (MenuParent = '" + stMenuParent + "') ";
            }


            if (RadioActive.Checked)
            {
                strCriteria = strCriteria + "  And  ([Status] ='Y') ";
            }
            else if (RadioCancel.Checked)
            {
                strCriteria = strCriteria + "  And  ([Status] ='N') ";
            }

            try
            {
                if (!oMenu.SP_MENU_SEL(strCriteria, ref ds, ref strMessage))
                {
                    lblError.Text = strMessage;
                }
                else
                {
                    try
                    {
                        GridView1.PageIndex           = nPageNo;
                        txthTotalRecord.Value         = ds.Tables[0].Rows.Count.ToString();
                        ds.Tables[0].DefaultView.Sort = ViewState["sort"] + " " + ViewState["direction"];
                        GridView1.DataSource          = ds.Tables[0];
                        GridView1.DataBind();
                    }
                    catch
                    {
                        GridView1.PageIndex           = 0;
                        txthTotalRecord.Value         = ds.Tables[0].Rows.Count.ToString();
                        ds.Tables[0].DefaultView.Sort = ViewState["sort"] + " " + ViewState["direction"];
                        GridView1.DataSource          = ds.Tables[0];
                        GridView1.DataBind();
                    }
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
            finally
            {
                oMenu.Dispose();
                ds.Dispose();
                if (GridView1.Rows.Count > 0)
                {
                    GridView1.TopPagerRow.Visible = true;
                }
            }
        }
Example #8
0
 // Add submenu item
 public void AddItem(ref cMenuItem item)
 {
     if (SubMenu == null)	{
         SubMenu = new cMenu(Id, false);
         SubMenu.ParentPage = this.ParentPage;
     }
     SubMenu.AddItem(ref item);
 }
Example #9
0
 public void win(Player.RangerType playerWhoWon)
 {
     Application.LoadLevel("Win Scene");
     currentMenu = cMenu.WIN;
     winnerType  = playerWhoWon;
 }
Example #10
0
 public void Menu_Rendering(ref cMenu Menu)
 {
     // Change menu items here
 }
Example #11
0
        public decimal GetRightsForMetaobject(cMenu.Metaobjects.Linq.CMetaobject Metaobject)
        {
            var UserRecords = this._securityRecords.Where(R => R.MetaobjectKey == Metaobject.Key && R.UserKey == this._key).ToList();
            var GroupRecords = this._securityRecords.Where(R => R.MetaobjectKey == Metaobject.Key && R.UserKey != this._key).ToList();

            if (UserRecords.Count == 0 && GroupRecords.Count == 0)
                return 0;
            if (UserRecords.Count != 0)
                return UserRecords[0].Rights;
            if (GroupRecords.Count != 0)
                return GroupRecords[0].Rights;

            return 0;
        }
Example #12
0
        private bool saveData()
        {
            bool   blnResult  = false;
            bool   blnDup     = false;
            string strMessage = string.Empty;
            //Tab 1
            string
                pMenuID            = string.Empty,
                pMenuName          = string.Empty,
                pMenuNavigationUrl = string.Empty,
                pMenuImageUrl      = string.Empty,
                pMenuTarget        = string.Empty,
                pMenuParent        = string.Empty,
                pMenuOrder         = string.Empty,
                pCanView           = string.Empty,
                pCanInsert         = string.Empty,
                pCanEdit           = string.Empty,
                pCanDelete         = string.Empty,
                pCanApprove        = string.Empty,
                pCanExtra          = string.Empty,
                pStatus            = string.Empty,
                strRemark          = string.Empty,
                strCreatedBy       = string.Empty,
                strUpdatedBy       = string.Empty;
            string  strScript      = string.Empty;
            cMenu   oMenu          = new cMenu();
            DataSet ds             = new DataSet();

            try
            {
                #region set Data
                pMenuID            = hddMenuID.Value.ToString();
                pMenuName          = txtMenuName.Text;
                pMenuNavigationUrl = txtMenuNavigationUrl.Text;
                pMenuImageUrl      = txtMenuImageUrl.Text;
                pMenuTarget        = cboMenuTarget.SelectedValue;
                pMenuParent        = cboMenuParent.SelectedValue;
                pMenuOrder         = txtMenuOrder.Value.ToString();
                pCanView           = chkCanView.Checked ? "Y" : "N";
                pCanInsert         = chkCanInsert.Checked ? "Y" : "N";
                pCanEdit           = chkCanEdit.Checked ? "Y" : "N";
                pCanDelete         = chkCanDelete.Checked ? "Y" : "N";
                pCanApprove        = chkCanApprove.Checked ? "Y" : "N";
                pCanExtra          = chkCanExtra.Checked ? "Y" : "N";
                pStatus            = chkStatus.Checked ? "Y" : "N";
                strRemark          = txtRemark.Text;
                strCreatedBy       = Session["username"].ToString();
                strUpdatedBy       = Session["username"].ToString();
                #endregion
                if (ViewState["mode"].ToString().ToLower().Equals("edit"))
                {
                    #region edit

                    #region check dup
                    string strCheckDup = string.Empty;
                    strCheckDup = " and MenuName = '" + pMenuName + "'  and [MenuName] <> '" + hddMenuName.Value.ToString() + "' ";
                    if (!oMenu.SP_MENU_SEL(strCheckDup, ref ds, ref strMessage))
                    {
                        lblError.Text = strMessage;
                    }
                    else
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            strScript =
                                "alert(\"ไม่สามารถแก้ไขข้อมูลได้ เนื่องจาก" +
                                "\\nข้อมูล ชื่อเมนู : " + pMenuName.Trim() +
                                "\\nซ้ำ\");\n";
                            blnDup = true;
                        }
                    }
                    #endregion
                    if (!blnDup)
                    {
                        if (oMenu.SP_MENU_UPD(pMenuID, pMenuName, pMenuNavigationUrl, pMenuImageUrl, pMenuTarget, pMenuParent, pMenuOrder, pCanView,
                                              pCanInsert, pCanEdit, pCanDelete, pCanApprove, pCanExtra, pStatus, strRemark, strUpdatedBy, ref strMessage))
                        {
                            blnResult = true;
                        }
                        else
                        {
                            lblError.Text = strMessage.ToString();
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "chkdup", strScript, true);
                    }
                    #endregion
                }
                else
                {
                    #region check dup
                    string strCheckDup = string.Empty;
                    strCheckDup = " and [MenuName] = '" + pMenuName + "' ";
                    if (!oMenu.SP_MENU_SEL(strCheckDup, ref ds, ref strMessage))
                    {
                        lblError.Text = strMessage;
                    }
                    else
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            strScript =
                                "alert(\"ไม่สามารถเพิ่มข้อมูลได้ เนื่องจาก" +
                                "\\nข้อมูล เมนู : " + pMenuName.Trim() +
                                "\\nซ้ำ\");\n";
                            blnDup = true;
                        }
                    }
                    #endregion

                    #region insert
                    if (!blnDup)
                    {
                        if (oMenu.SP_MENU_INS(pMenuName, pMenuNavigationUrl, pMenuImageUrl, pMenuTarget, pMenuParent, pMenuOrder, pCanView,
                                              pCanInsert, pCanEdit, pCanDelete, pCanApprove, pCanExtra, pStatus, strRemark, strUpdatedBy, ref strMessage))
                        {
                            string strCode = " and [MenuName] = '" + pMenuName + "' ";
                            if (!oMenu.SP_MENU_SEL(strCheckDup, ref ds, ref strMessage))
                            {
                                lblError.Text = strMessage;
                            }
                            else
                            {
                                if (ds.Tables[0].Rows.Count > 0)
                                {
                                    ViewState["MenuID"] = ds.Tables[0].Rows[0]["MenuID"].ToString();
                                }
                            }
                            blnResult = true;
                        }
                        else
                        {
                            lblError.Text = strMessage.ToString();
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "close", strScript, true);
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
            finally
            {
                oMenu.Dispose();
            }
            return(blnResult);
        }