Exemple #1
0
    protected void btnEdit_Click(object sender, EventArgs e)
    {
        try
        {
            if (Page.IsValid)
            {
                int    id  = -1;
                string _id = Request.QueryString["id"].ToString();
                int.TryParse(_id, out id);
                int userId = CurrentEnvironment.LoggedUser.Id;

                GIIS.DataLayer.Menu o = GIIS.DataLayer.Menu.GetMenuById(id);

                o.ParentId     = int.Parse(txtParentId.Text);
                o.Title        = txtTitle.Text.Replace("'", @"''");
                o.NavigateUrl  = txtNavigateUrl.Text.Replace("'", @"''");
                o.IsActive     = bool.Parse(rblIsActive.SelectedValue);
                o.DisplayOrder = int.Parse(txtDisplayOrder.Text);

                int i = GIIS.DataLayer.Menu.Update(o);

                if (i > 0)
                {
                    lblSuccess.Visible = true;
                    lblWarning.Visible = false;
                    lblError.Visible   = false;
                    gvMenu.DataBind();
                    ClearControls(this);
                }
                else
                {
                    lblSuccess.Visible = false;
                    lblWarning.Visible = true;
                    lblError.Visible   = false;
                }
            }
        }
        catch (Exception ex)
        {
            lblSuccess.Visible = false;
            lblWarning.Visible = false;
            lblError.Visible   = true;
        }
    }
Exemple #2
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        try
        {
            if (Page.IsValid)
            {
                int userId = CurrentEnvironment.LoggedUser.Id;

                GIIS.DataLayer.Menu o = new GIIS.DataLayer.Menu();

                o.ParentId     = int.Parse(txtParentId.Text);
                o.Title        = txtTitle.Text.Replace("'", @"''");
                o.NavigateUrl  = txtNavigateUrl.Text.Replace("'", @"''");
                o.IsActive     = bool.Parse(rblIsActive.SelectedValue);
                o.DisplayOrder = int.Parse(txtDisplayOrder.Text);

                int i = GIIS.DataLayer.Menu.Insert(o);

                if (i > 0)
                {
                    lblSuccess.Visible = true;
                    lblWarning.Visible = false;
                    lblError.Visible   = false;
                    gvMenu.DataBind();
                    ClearControls(this);
                }
                else
                {
                    lblSuccess.Visible = false;
                    lblWarning.Visible = true;
                    lblError.Visible   = false;
                }
            }
        }
        catch (Exception ex)
        {
            lblSuccess.Visible = false;
            lblWarning.Visible = false;
            lblError.Visible   = true;
        }
    }