/// <summary> /// Поиск в таблице дисциплин, если не найдено добавляем /// </summary> /// <param name="Name">Полное наименование</param> /// <param name="ShortName">Краткое наименование</param> /// <param name="DiscipTypeId">1 - учебные дисциплины, 2 - Практика, 3 - дипломная нагрузка</param> /// <returns></returns> public Int64 GetStudDisciplineByName(string Name, string ShortName, Int64 DiscipTypeId) { var disciplines = SqlData.GetDataSource <STUDDISCIPLINE>(ServerHelper.ConnectionHelper.GetConnection(), "SPU_STUDDISCIPLINE_SEL", null); var discipline = disciplines.Rows. Cast <ISTUDDISCIPLINE>(). Where(r => r.STUDDISCIPLINE_DIPLOMANAME.Trim() == Name). Select(r => r.STUDDISCIPLINE_ID); Int64 id = 0; if (discipline.Count() == 0) { var newDiscip = disciplines.CreateNewRow <STUDDISCIPLINE>(); newDiscip.STUDDISCIPLINE_NAME = Name; newDiscip.STUDDISCIPLINE_SHORTNAME = Name; newDiscip.STUDDISCIPLINE_STATE = true; newDiscip.STUDDISCIPTYPE_ID = DiscipTypeId; newDiscip.STUDDISCIPLINE_DIPLOMANAME = Name; disciplines.AddRow(newDiscip); disciplines.SqlData.SaveAll(); id = newDiscip.STUDDISCIPLINE_ID; } else { id = discipline.First(); } return(id); }
public Int64?GetStudDiscComponentByName(string Name, string Code) { var StudDiscComponents = SqlData.GetDataSource <STUDDISCCOMPONENT>(ServerHelper.ConnectionHelper.GetConnection(), "SPU_STUDDISCCOMPONENT_SEL", null);; var StudDiscComponent = StudDiscComponents.Rows. Cast <RefDataStores.WTP.ISTUDDISCCOMPONENT>(). Where(r => r.STUDDISCCOMPONENT_NAME == Name). Where(r => r.STUDDISCCOMPONENT_CODE == Code). Select(r => r.STUDDISCCOMPONENT_ID); Int64?ID = 0; if (StudDiscComponent.Count() == 0) { var newStudDiscComponent = StudDiscComponents.CreateNewRow <STUDDISCCOMPONENT>(); newStudDiscComponent.STUDDISCCOMPONENT_NAME = Name; newStudDiscComponent.STUDDISCCOMPONENT_CODE = Code; //StudDiscComponents.Add<RefDataStores.WTP.ISTUDDISCCOMPONENT>(newStudDiscComponent); //StudDiscComponents.Save(); //ID = newStudDiscComponent.STUDDISCCOMPONENT_ID; StudDiscComponents.AddRow(newStudDiscComponent); StudDiscComponents.SqlData.SaveAll(); ID = newStudDiscComponent.STUDDISCCOMPONENT_ID; } else { ID = StudDiscComponent.First(); } return(ID); }
private void button2_Click(object sender, EventArgs e) { var disciplines = SqlData.GetDataSource <STUDDISCIPLINE>(ServerHelper.ConnectionHelper.GetConnection(), "SPU_STUDDISCIPLINE_SEL", null); //var disciplines = DBManager.GetDataSourse<ISTUDDISCIPLINE>(); var newDiscip = disciplines.CreateNewRow <STUDDISCIPLINE>(); newDiscip.STUDDISCIPLINE_NAME = "kfghjcgjtjc"; newDiscip.STUDDISCIPLINE_SHORTNAME = "yguykghgh"; newDiscip.STUDDISCIPLINE_STATE = true; newDiscip.STUDDISCIPTYPE_ID = 1; newDiscip.STUDDISCIPLINE_DIPLOMANAME = "hjkgfgfjhf"; disciplines.AddRow(newDiscip); disciplines.SqlData.SaveAll(); }
public AddDisciplineForm() { InitializeComponent(); ServerHelper.ConnectionHelper.SetConnection(new SqlConnection(@"Data Source=localhost; Initial Catalog=WTP; Integrated Security=True")); var disciplines = SqlData.GetDataSource <STUDDISCIPLINE>(ServerHelper.ConnectionHelper.GetConnection(), "SPU_STUDDISCIPLINE_SEL", null).Rows. Cast <ISTUDDISCIPLINE>(); disciplineChoice.Properties.DataSource = disciplines; disciplineChoice.Properties.DisplayMember = "STUDDISCIPLINE_NAME"; disciplineChoice.Properties.ValueMember = "STUDDISCIPLINE_ID"; ServerHelper.ConnectionHelper.SetConnection(new SqlConnection(@"Data Source=localhost; Initial Catalog=WTP; Integrated Security=True")); var components = DBManager.GetDataSourse <ISTUDDISCCOMPONENT>().Rows. Cast <ISTUDDISCCOMPONENT>(); componentChoice.Properties.DataSource = components; componentChoice.Properties.DisplayMember = "STUDDISCCOMPONENT_NAME"; componentChoice.Properties.ValueMember = "STUDDISCCOMPONENT_ID"; }