Example #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!valName.Validate())
            {
                return;
            }
            var nameGroup = txtGroup.Text;

            if (txtMax.Text == "")
            {
                txtMax.Text = "0";
            }
            var maxNumber = Convert.ToInt32(txtMax.Text);
            var idClass   = Convert.ToInt32(cmbClass.EditValue);

            if (isExist(nameGroup))
            {
                XtraMessageBox.Show("توجد مجموعة بهذا الإسم", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (dt.Rows.Count == 0)
            {
                XtraMessageBox.Show("يجب علي الأقل إختيار معاد واحد", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            tblGroup g = new tblGroup()
            {
                nameGroup = nameGroup,
                maxNumber = maxNumber,
                idClass   = idClass
            };

            db.tblGroups.Add(g);

            foreach (DataRow dr in dt.Rows)
            {
                string      day  = dr["اليوم"].ToString();
                string      hour = dr["الساعة"].ToString();
                tblRelation r    = new tblRelation()
                {
                    idGroup = g.idGroup,
                    Day     = day,
                    Time    = hour,
                };
                db.tblRelations.Add(r);
            }

            db.SaveChanges();
            XtraMessageBox.Show("تمت إضافة المجموعة بنجاح", "إضافة", MessageBoxButtons.OK, MessageBoxIcon.Information);
            ClrBoxs();
        }
Example #2
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         var         day  = cmbDays.Text;
         var         hour = teTime.Text;
         tblRelation r    = new tblRelation()
         {
             idGroup = idGroup,
             Day     = day,
             Time    = hour,
         };
         db.tblRelations.Add(r);
         db.SaveChanges();
         XtraMessageBox.Show("تم إضافة المعاد", "إضافة", MessageBoxButtons.OK, MessageBoxIcon.Information);
         groupControl2.Visible = false;
         groupControl1.Enabled = false;
         cmbGroup_EditValueChanged(sender, e);
     }
     catch
     {
         XtraMessageBox.Show("برجاء ملء جميع الحقول", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }