LectionsModel CreateLection(int lectionId) { LectionsModel result = null; using (SqlCeConnection connection = new SqlCeConnection(connectionString)) { connection.Open(); using (SqlCeCommand cmd = connection.CreateCommand()) { cmd.CommandText = "SELECT LectionId, Name, OwnerId, LectionType, Description, LectionText FROM Lection WHERE LectionId=@id"; cmd.Parameters.AddWithValue("@id", lectionId); SqlCeDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { int id = Convert.ToInt32(dr["LectionId"]); string name = dr["Name"].ToString(); int ownerId = Convert.ToInt32(dr["OwnerId"]); string type = dr["LectionType"].ToString(); string descr = dr["Description"].ToString(); byte[] text = dr["LectionText"] as byte[]; result = new LectionsModel(id, name, ownerId, type, descr, text); } } } return(result); }
public LectionModel(int lectionId, int userId) { this.userId = userId; this.lectionId = lectionId; lection = CreateLection(lectionId); Test = CreateTest(lection.Name, userId); }
public LectionsModel GetLection() { if (lection != null && lection.Id == lectionId) { return(lection); } else { lection = CreateLection(lectionId); Test = CreateTest(lection.Name, userId); return(lection); } }
//вибір певної лекції з набору void Item_DoubleClick(object sender, EventArgs e) { LectionsModel mod = window.GetChoosenModel(sender) as LectionsModel; if (mod != null) { Window win = window as Window; Lection lection = new Lection(userId, mod.Id, model.Lections, win.Left, win.Top); lection.WindowState = win.WindowState; lection.ShowDialog(); } else { model.Lections = new List <LectionsModel>((window.GetGroupModel(sender) as LectionGroupModel).Items); } }