private void btnSave_Click(object sender, EventArgs e)
 {
     Shared.Category cat = new Shared.Category();
     cat.catName = txtName.Text;
     cat.catDesc = txtDescription.Text;
     res         = db.AddCategory(cat);
     if (res.success)
     {
         MetroSetMessageBox.Show(this, res.message, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         MetroSetMessageBox.Show(this, res.message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        private void gv_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == gv.NewRowIndex || e.RowIndex < 0)
            {
                return;
            }

            Shared.Category category = new Shared.Category();
            category.ID      = Convert.ToInt32(gv.Rows[e.RowIndex].Cells["ID"].Value);
            category.catName = Convert.ToString(gv.Rows[e.RowIndex].Cells["catName"].Value);
            category.catDesc = Convert.ToString(gv.Rows[e.RowIndex].Cells["catDesc"].Value);
            res = db.UpdateCategory(category);
            if (res.success)
            {
                MetroSetMessageBox.Show(this, res.message, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                getCategory();
            }
            else
            {
                MetroSetMessageBox.Show(this, res.message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }