public bool AddClass(TheoryClass pClass) { if (string.IsNullOrEmpty(pClass.TheoryClassID)) return false; if (string.IsNullOrEmpty(pClass.TheoryClassRoom)) pClass.TheoryClassRoom = ""; if (string.IsNullOrEmpty(pClass.Date)) pClass.Date = ""; try { cqmdb.TheoryClass.AddObject(pClass); cqmdb.SaveChanges(); return true; } catch (Exception ex) { throw ex; } }
/// <summary> /// 创建新的 TheoryClass 对象。 /// </summary> /// <param name="theoryClassID">TheoryClassID 属性的初始值。</param> public static TheoryClass CreateTheoryClass(global::System.String theoryClassID) { TheoryClass theoryClass = new TheoryClass(); theoryClass.TheoryClassID = theoryClassID; return theoryClass; }
private void btnOK_Click(object sender, EventArgs e) { if (rdbLab.Checked) { LabClass classinfo = new LabClass() { LabClassID = txtClassID.Text, LabClassRoom = txtClassRoom.Text, Date = txtDate.Text, TheoryClassID=cmbTheroyClass.ClassID }; LabClassBLL bclass = new LabClassBLL(); try { if (bclass.AddClass(classinfo)) MessageBox.Show("��ӳɹ�"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else if(rdbTheroy.Checked) { TheoryClass classinfo = new TheoryClass() { TheoryClassID = txtClassID.Text, TheoryClassRoom = txtClassRoom.Text, Date = txtDate.Text }; TheoryClassBLL bclass = new TheoryClassBLL(); try { if (bclass.AddClass(classinfo)) MessageBox.Show("��ӳɹ�"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { LabClass classinfo = new LabClass() { LabClassID = txtClassID.Text, LabClassRoom = txtClassRoom.Text, Date = txtDate.Text }; LabClassBLL bclass = new LabClassBLL(); try { if (bclass.AddClass(classinfo)) MessageBox.Show("��ӳɹ�"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
/// <summary> /// 用于向 TheoryClass EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet<T> 属性的 .Add 方法。 /// </summary> public void AddToTheoryClass(TheoryClass theoryClass) { base.AddObject("TheoryClass", theoryClass); }