public void AddRecord(string name, string category, string content) { dbInsectiaSet.itemRow NewRow = itemTable.NewitemRow(); NewRow.name = name; NewRow.content = content; dbInsectiaSet.categoryRow categoryRow = null; foreach (dbInsectiaSet.categoryRow row in categoryTable) { if (row.category == category) { categoryRow = row; } } if (categoryRow == null) { categoryRow = categoryTable.NewcategoryRow(); categoryRow.category = category; categoryTable.AddcategoryRow(categoryRow); Save(true); categoryTableAdapter.Fill(categoryTable); var q = from _category in categoryTable where _category.category == category select _category; foreach (dbInsectiaSet.categoryRow row in q) { categoryRow = row; } } NewRow.idCategory = categoryRow.id; itemTable.AdditemRow(NewRow); }
public void AddCategory(string Category) { dbInsectiaSet.categoryRow NewRow = categoryTable.NewcategoryRow(); NewRow.category = Category; categoryTable.AddcategoryRow(NewRow); Save(true); categoryTableAdapter.Fill(categoryTable); }
public void UpdateRecord(string OldName, string OldCategory, string NewName, string NewCategory, string Content) { dbInsectiaSet.itemRow itemRow = null; var queryItem = from _item in itemTable where _item.name == OldName && _item.categoryRow.category == OldCategory select _item; foreach (dbInsectiaSet.itemRow row in queryItem) { itemRow = row; } if (!string.IsNullOrEmpty(NewName)) { itemRow.name = NewName; } dbInsectiaSet.categoryRow categoryRow = null; if (!string.IsNullOrEmpty(NewCategory)) { var queryCategory = from _category in categoryTable where _category.category == NewCategory select _category; foreach (dbInsectiaSet.categoryRow row in queryCategory) { categoryRow = row; } if (categoryRow == null) { categoryRow = categoryTable.NewcategoryRow(); categoryRow.category = NewCategory; categoryTable.AddcategoryRow(categoryRow); Save(true); categoryTableAdapter.Fill(categoryTable); var q = from _category in categoryTable where _category.category == NewCategory select _category; foreach (dbInsectiaSet.categoryRow row in q) { categoryRow = row; } } itemRow.idCategory = categoryRow.id; } if (!string.IsNullOrEmpty(Content)) { itemRow.content = Content; } }