protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            SimplicityWebEstateAgentEntities estateAgentDB = new SimplicityWebEstateAgentEntities();
            EstateAgentEntityModel.RefCategory category = new RefCategory();

            category.CompanySequence = loggedInUserCoId;
            category.CreatedBy = loggedInUserId;
            category.DateCreated = System.DateTime.Now;
            category.LastAmendedBy = loggedInUserId;
            category.DateLastAmended = System.DateTime.Now;
            category.CategoryDesc = txtCategoryDescription.Text;
            category.FlgDeleted = false;

            IEnumerable<EstateAgentEntityModel.RefCategory> categories = (from categ in estateAgentDB.RefCategories where categ.CompanySequence == loggedInUserCoId select categ);
            category.RowIndex = (categories.Count() + 1);

            estateAgentDB.RefCategories.AddObject(category);
            estateAgentDB.SaveChanges();
            Response.Redirect("CategoriesList.aspx");
        }
        catch (Exception exc)
        {
            SetErrorMessage(WebConstants.Messages.Error.CONNECTION_ERROR);
        }
    }
 protected void DeleteCategory(int category_id)
 {
     category = getCategory(category_id);
     if (category == null)
     {
         SetErrorMessage(WebConstants.Messages.Error.INVALID_ID);
     }
     else
     {
         try
         {
             category.FlgDeleted = true;
             estateAgentDB.SaveChanges();
             SetInfoMessage(WebConstants.Messages.Information.RECORD_DELETED);
             GridView1.DataBind();
         }
         catch
         {
             SetErrorMessage(WebConstants.Messages.Error.CONNECTION_ERROR);
         }
     }
 }
 /// <summary>
 /// Create a new RefCategory object.
 /// </summary>
 /// <param name="sequence">Initial value of the Sequence property.</param>
 public static RefCategory CreateRefCategory(global::System.Int32 sequence)
 {
     RefCategory refCategory = new RefCategory();
     refCategory.Sequence = sequence;
     return refCategory;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the RefCategories EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToRefCategories(RefCategory refCategory)
 {
     base.AddObject("RefCategories", refCategory);
 }