/// <summary>
 /// Handles the saving of supply category
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSaveSupCat_Click(object sender, EventArgs e)
 {
     if (txtSupCat.Text != "")
     {
         SupplyCategory supCat = new SupplyCategory();
         if (_supCatId == 0)
             supCat.AddNew();
         else
             supCat.LoadByPrimaryKey(_supCatId);
         supCat.Name = txtSupCat.Text;
         supCat.Code = txtSupCode.Text;
         supCat.ParentId = ((cboSupCat.Visible) ? Convert.ToInt32(cboSupCat.SelectedValue) : 0);
         supCat.Save();
         PopulateSupplyCatTree();
     }
 }
        /// <summary>
        /// Handles the treeSupCategory focused node changed and updates the form accordingly
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void treeSupCategory_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        {
            SupplyCategory supCat = new SupplyCategory();
            string value = treeSupCategory.Selection[0].GetValue("ID").ToString();
            int categoryId = Convert.ToInt32(value.Substring(1));

            supCat.LoadByPrimaryKey(categoryId);
            if (supCat.ParentId != 0)
            {
                cboSupCat.Visible = true;

                lblSupCat.Text = "Sub Category";
                cboSupCat.SelectedValue = Convert.ToInt32(supCat.ParentId);
            }
            else
            {
                cboSupCat.Visible = false;
                lblSupCat.Text = "Main Category";
            }
            txtSupCat.Text = supCat.Name;
            txtSupCode.Text = supCat.Code;
            _supCatId = supCat.ID;
            btnSave.Text = "Update";
        }