/// <summary> /// Регистрация группы товаров в БД /// </summary> public void RegisterGroup() { dsParserTableAdapters.tGroupsTableAdapter ta = new dsParserTableAdapters.tGroupsTableAdapter(); dsParser.tGroupsDataTable tbl = ta.GetDataByUrl(Url.Trim()); dsParser.tGroupsRow row; if (tbl.Rows.Count > 0) { row = (dsParser.tGroupsRow)tbl.Rows[0]; } else { row = tbl.NewtGroupsRow(); row.Url = Url; } row.Name = Name; if (row.RowState == System.Data.DataRowState.Detached) { tbl.Rows.Add(row); } ta.Update(tbl); }
/// <summary> /// Создание класса группы из БД по идентификатору /// </summary> /// <param name="__id"></param> public Group(int __id) : this() { dsParserTableAdapters.tGroupsTableAdapter ta = new dsParserTableAdapters.tGroupsTableAdapter(); dsParser.tGroupsDataTable tbl = ta.GetDataById(__id); if (tbl.Rows.Count > 0) { dsParser.tGroupsRow row = (dsParser.tGroupsRow)tbl.Rows[0]; _id = row.Id; Parent = new Group(row.ParentId); Name = row.Name; Url = row.Url; } }