protected void gvCatagoriesYad2_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (!e.CommandName.Equals("AddNew"))
            {
                return;
            }

            GridViewRow row = gvCatagoriesYad2.FooterRow;
            TextBox     tb  = (TextBox)row.FindControl("txtNewCategoryName");

            //study program name cannot ne empty
            if (tb.Text == "")
            {
                Master.MessageCenter.DisplayErrorMessage(Yad2Strings.GetText(@"CategoryNameRequired"));
                return;
            }
            //study program name must be unique
            if (core.DAL.CategoryYad2.FetchByName(tb.Text) != null)
            {
                Master.MessageCenter.DisplayErrorMessage(Yad2Strings.GetText(@"MessageSaveFailedNameAlreadyExists"));
                return;
            }
            //Insert new User status
            CategoryYad2 category = new CategoryYad2();

            category.CategoryYad2Name = tb.Text;
            category.Save();

            // refresh the grid view data
            LoadItems();
        }
        protected void gvCatagoriesYad2_RowUpdate(object sender, GridViewUpdateEventArgs e)
        {
            int         index      = e.RowIndex;
            GridViewRow row        = gvCatagoriesYad2.Rows[index];
            Int64       CategoryId = Int64.Parse(gvCatagoriesYad2.DataKeys[index].Value.ToString());
            TextBox     tb         = (TextBox)row.Cells[0].FindControl("txtCategoryName");

            //study program name cannot ne empty
            if (tb.Text == "")
            {
                Master.MessageCenter.DisplayErrorMessage(Yad2Strings.GetText(@"CategoryNameRequired"));
                return;
            }
            //category name must be unique
            CategoryYad2 category = CategoryYad2.FetchByName(tb.Text);

            if (category != null && category.CategoryYad2Id != CategoryId)
            {
                Master.MessageCenter.DisplayErrorMessage(Yad2Strings.GetText(@"MessageSaveFailedNameAlreadyExists"));
                return;
            }

            category = CategoryYad2.FetchByID(CategoryId);
            category.CategoryYad2Name = tb.Text;
            category.Save();

            gvCatagoriesYad2.EditIndex = -1;

            // refresh the grid view data
            LoadItems();
        }
        protected void gvCatagoriesYad2_RowDelete(object sender, GridViewDeleteEventArgs e)
        {
            int   index      = e.RowIndex;
            Int64 CategoryId = Int64.Parse(gvCatagoriesYad2.DataKeys[index].Value.ToString());

            //check if this service is in use
            Query productCategory = new Query(ProductYad2Category.TableSchema)
                                    .Where(ProductYad2Category.Columns.CategoryYad2Id, CategoryId);

            if (productCategory.GetCount() > 0)
            {
                Master.MessageCenter.DisplayErrorMessage(Yad2Strings.GetText(@"MessageDeleteFailedInUse"));
                return;
            }
            CategoryYad2.Delete(CategoryId);

            // refresh the grid view data
            LoadItems();
        }