示例#1
0
 void loadData(string item)
 {
     cat = CategoryList.GetCategory(item);
     if (cat != null)
     {
         this.txtCode.Text = cat.CategoryID;
         this.txtDesc.Text = cat.CategoryName;
     }
 }
示例#2
0
 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;
 }
示例#3
0
        private void IsAlreadyExist()
        {
            cat = CategoryList.GetCategory(this.txtCode.Text);
            if (cat != null)
            {
                strAction = "update";
            }
            else
            {
                strAction = "insert";
            }

        }
示例#4
0
 public static void InsertCategory(Category cat)
 {
     XMLCategory.Insert(cat.CategoryID, cat.CategoryName);
 }
示例#5
0
 public static void UpdateCategory(Category cat)
 {
     XMLCategory.Update(cat.CategoryID, cat.CategoryName);
 }
示例#6
0
 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();
 }