예제 #1
0
    protected void ExistsIDCustomValidator_ServerValidate(object source, ServerValidateEventArgs args)
    {
        args.IsValid = false;

        if (string.IsNullOrEmpty(CategoryItemIdHiddenField.Value))
        {
            CategoryItem theData = CategoryItemBLL.GetCategoryItemById(IDTextBox.Text, CategoryIdHiddenField.Value);
            if (theData == null)
            {
                args.IsValid = true;
            }
        }
        else
        {
            args.IsValid = true;
        }
    }
예제 #2
0
    protected void CategoryItemGridView_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        string categoryItemId = e.CommandArgument.ToString();

        if (e.CommandName.Equals("DeleteData"))
        {
            try
            {
                CategoryItemBLL.DeleteCategoryItem(categoryItemId, CategoryIdHiddenField.Value);
                SystemMessages.DisplaySystemMessage(Resources.Categories.MessageDeletedItem);
                CategoryItemGridView.DataBind();
            }
            catch (Exception exc)
            {
                SystemMessages.DisplaySystemErrorMessage(exc.Message);
            }
        }
        else if (e.CommandName.Equals("EditData"))
        {
            CategoryItem theData = null;
            try
            {
                theData = CategoryItemBLL.GetCategoryItemById(categoryItemId, CategoryIdHiddenField.Value);
            }
            catch (Exception exc)
            {
                SystemMessages.DisplaySystemErrorMessage(exc.Message);
            }

            if (theData != null)
            {
                IDTextBox.Text                  = theData.ItemID;
                IDTextBox.ReadOnly              = true;
                NameTextBox.Text                = theData.ItemName;
                pnlEditData.Visible             = true;
                CategoryItemIdHiddenField.Value = theData.ItemID;
            }
        }
    }
예제 #3
0
    protected void SaveButton_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid)
        {
            return;
        }

        if (string.IsNullOrEmpty(CategoryItemIdHiddenField.Value))
        {
            try
            {
                CategoryItemBLL.InsertCategoryItem(IDTextBox.Text.Trim(), CategoryIdHiddenField.Value, NameTextBox.Text.Trim());
                SystemMessages.DisplaySystemMessage(Resources.Categories.MessageCreatedItem);
            }
            catch (Exception exc)
            {
                SystemMessages.DisplaySystemErrorMessage(exc.Message);
                return;
            }
        }
        else
        {
            try
            {
                CategoryItemBLL.UpdateCategoryItem(IDTextBox.Text.Trim(), CategoryIdHiddenField.Value, NameTextBox.Text.Trim());
                SystemMessages.DisplaySystemMessage(Resources.Categories.MessageUpdatedItem);
            }
            catch (Exception exc)
            {
                SystemMessages.DisplaySystemErrorMessage(exc.Message);
                return;
            }
        }

        CategoryItemIdHiddenField.Value = "";
        pnlEditData.Visible             = false;
        CategoryItemGridView.DataBind();
    }