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 btnUpdate_Click(object sender, EventArgs e)
    {
        try
        {
            SimplicityWebEstateAgentEntities estateAgentDB = new SimplicityWebEstateAgentEntities();
            int categoryId = int.Parse(Request[WebConstants.Request.CATEGORY_ID]);
            EstateAgentEntityModel.RefCategory category = estateAgentDB.RefCategories.SingleOrDefault(categ => categ.Sequence == categoryId);

            category.DateLastAmended = System.DateTime.Now;
            category.LastAmendedBy = loggedInUserId;
            category.CategoryDesc = txtCategoryDescription.Text;

            estateAgentDB.SaveChanges();
            Response.Redirect("CategoriesList.aspx");
        }
        catch
        {
            SetErrorMessage(WebConstants.Messages.Error.CONNECTION_ERROR);
        }
    }