private void AddBdGroupInfoFind(object GroupInfoParametr) { string[] GroupInfoParametrString = (string[])GroupInfoParametr; using (ContextGroupInfo db = new ContextGroupInfo()) { int paramGroupId = Convert.ToInt32(GroupInfoParametrString[0]); var tt = db.GroupInfos.Where(p => p.group_id == paramGroupId); if (tt == null || tt.Count() == 0) { addInfoBd(GroupInfoParametrString); } else { GroupInfoo gu = db.GroupInfos.Where(p => p.group_id == paramGroupId).FirstOrDefault(); gu.name = GroupInfoParametrString[1]; gu.screen_name = GroupInfoParametrString[2]; gu.is_closed = Convert.ToInt32(GroupInfoParametrString[3]); gu.type = GroupInfoParametrString[4]; gu.is_admin = Convert.ToInt32(GroupInfoParametrString[5]); gu.admin_level = Convert.ToInt32(GroupInfoParametrString[6]); gu.is_member = Convert.ToInt32(GroupInfoParametrString[7]); gu.members_count = Convert.ToInt32(GroupInfoParametrString[8]); gu.photo_50 = GroupInfoParametrString[9]; gu.photo_100 = GroupInfoParametrString[10]; gu.photo_200 = GroupInfoParametrString[11]; db.SaveChanges(); } } }
private void addInfoBd(string[] GroupInfoParametr) { using (ContextGroupInfo db = new ContextGroupInfo()) { GroupInfoo GI = new GroupInfoo { group_id = Convert.ToInt32(GroupInfoParametr[0]), name = GroupInfoParametr[1], screen_name = GroupInfoParametr[2], is_closed = Convert.ToInt32(GroupInfoParametr[3]), type = GroupInfoParametr[4], is_admin = Convert.ToInt32(GroupInfoParametr[5]), admin_level = Convert.ToInt32(GroupInfoParametr[6]), is_member = Convert.ToInt32(GroupInfoParametr[7]), members_count = Convert.ToInt32(GroupInfoParametr[8]), photo_50 = GroupInfoParametr[9], photo_100 = GroupInfoParametr[10], photo_200 = GroupInfoParametr[11] }; db.GroupInfos.Add(GI); db.SaveChanges(); } }
private void ComboBoxLoadedTextGroup() { ID = new int[0]; ComboBoxString = new string[0]; using (ContextGroupInfo db = new ContextGroupInfo()) { //GroupInfoo gf = db.GroupInfos.Select(gf.Id, gf.name, gf.group_id) var GroupName = from c in db.GroupInfos select new { c.group_id, c.name, c.Id }; foreach (var c in GroupName) { Array.Resize(ref ID, ID.Length + 1); Array.Resize(ref ComboBoxString, ComboBoxString.Length + 1); ID[ID.Length - 1] = c.Id; ComboBoxString[ComboBoxString.Length - 1] = c.name + " | " + c.group_id; } } comboBox1.Items.Clear(); comboBox1.Items.AddRange(ComboBoxString); }