示例#1
0
        protected void uiGridViewCats_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "EditCat")
            {
                ItemCategories objData = new ItemCategories();
                objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));

                uiTextBoxName.Text = objData.Name;
                uiTextBoxDesc.Text = objData.Description;

                uiPanelAllCats.Visible = false;
                uiPanelEditCat.Visible = true;
                CurrentCat = objData;

                BindCats();
            }
            else if (e.CommandName == "DeleteCat")
            {
                try
                {
                    ItemCategories objData = new ItemCategories();
                    objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));
                    objData.MarkAsDeleted();
                    objData.Save();
                    CurrentCat = null;
                    BindCats();
                }
                catch (Exception ex)
                {
                    uipanelError.Visible = true;
                }
            }
        }
示例#2
0
        protected void uiLinkButtonOK_Click(object sender, EventArgs e)
        {
            ItemCategories cat = new ItemCategories ();
            if (CurrentCat == null)
                cat.AddNew();
            else
                cat = CurrentCat;

            cat.Name = uiTextBoxName.Text;
            cat.Description = uiTextBoxDesc.Text;
            cat.Save();
            ClearFields();
            CurrentCat = null;
            uiPanelEditCat.Visible = false;
            uiPanelAllCats.Visible = true;
            BindCats();
        }