예제 #1
0
        public bool AddClass(LabClass pClass)
        {
            if (string.IsNullOrEmpty(pClass.LabClassID))
                return false;
            if (string.IsNullOrEmpty(pClass.LabClassRoom))
                pClass.LabClassRoom = "";
            if (string.IsNullOrEmpty(pClass.Date))
                pClass.Date = "";

            try
            {
                cqmdb.LabClass.AddObject(pClass);
                cqmdb.SaveChanges();
                return true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        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>
 /// 创建新的 LabClass 对象。
 /// </summary>
 /// <param name="labClassID">LabClassID 属性的初始值。</param>
 public static LabClass CreateLabClass(global::System.String labClassID)
 {
     LabClass labClass = new LabClass();
     labClass.LabClassID = labClassID;
     return labClass;
 }
 /// <summary>
 /// 用于向 LabClass EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToLabClass(LabClass labClass)
 {
     base.AddObject("LabClass", labClass);
 }