void loadData(string item) { cat = CategoryList.GetCategory(item); if (cat != null) { this.txtCode.Text = cat.CategoryID; this.txtDesc.Text = cat.CategoryName; } }
public static Category GetCategory(string categoryID) { DataRow iDr = null; iDr = XMLCategory.Select(categoryID); Category cat = null; if (iDr != null) { cat = new Category(); cat.CategoryID = iDr[0] != DBNull.Value ? iDr[0].ToString() : string.Empty; ; cat.CategoryName = iDr[1] != DBNull.Value ? iDr[1].ToString() : string.Empty; } return cat; }
private void IsAlreadyExist() { cat = CategoryList.GetCategory(this.txtCode.Text); if (cat != null) { strAction = "update"; } else { strAction = "insert"; } }
public static void InsertCategory(Category cat) { XMLCategory.Insert(cat.CategoryID, cat.CategoryName); }
public static void UpdateCategory(Category cat) { XMLCategory.Update(cat.CategoryID, cat.CategoryName); }
public void SaveOrUpdateAction() { cat = new Category(); cat.CategoryID = this.txtCode.Text; cat.CategoryName = this.txtDesc.Text; if (strAction.Equals("insert")) { try { CategoryList.InsertCategory(cat); bResult = true; strExp = "Record " + cat.CategoryID.Trim() + " successfully insert to datasource"; } catch (Exception exp) { bResult = false; strExp = "Record " + cat.CategoryID.Trim() + " failed insert to datasource\n Message : " + exp.Message; } } else { try { CategoryList.UpdateCategory(cat); bResult = true; strExp = "Record " + cat.CategoryID.Trim() + " successfully update to datasource"; } catch (Exception exp) { bResult = false; strExp = "Record " + cat.CategoryID.Trim() + " failed update to datasource\n Message : " + exp.Message; } } populate(); }