示例#1
0
        private void btnDone_Click(object sender, EventArgs e)
        {
            try
            {
                Teacher temp = new Teacher();
                int id = int.Parse(txtCode.Text);
                temp = ObTeacher(id);

                temp.Tea_Name = txtBoxName.Text;
                temp.Tea_DateOfBirth = dateArea.Value;
                temp.Tea_HomeTown = txtHometown.Text;
                temp.Tea_Address = txtAddress.Text;
                temp.Tea_PhoneNumber = txtPhone.Text;
                temp.Tea_Address = txtAddress.Text;
                temp.Tea_Religion = txtRegilion.Text;
                temp.Tea_Ethnic = txtEthnic.Text;

                if (aTeacherBO.Update(temp))
                {
                    frmTsk_UpadteTeacher_Load(sender, e);
                    MessageBox.Show("Thành Công", "Thành Công", MessageBoxButtons.OK,MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Thất Bại", "Thất Bại", MessageBoxButtons.OK,MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Thất Bại", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#2
0
		public void SetValue(Teacher aTeacher)
		{
			this.TeacherCode = aTeacher.Tea_Code;
			this.TeacherName = aTeacher.Tea_Name;
			this.TeacherOfBirth = aTeacher.Tea_DateOfBirth;
			this.TeacherAddress = aTeacher.Tea_Address;
			this.TeacherPhoneNumber = aTeacher.Tea_PhoneNumber;
			this.TeacherReligion = aTeacher.Tea_Religion;
			this.TeacherEthnic = aTeacher.Tea_Ethnic;

		}
示例#3
0
文件: TeacherBO.cs 项目: ntlzz93/Temp
 // Insert
 public bool Insert(Teacher aTeacher)
 {
     try
     {
         db.Teachers.InsertOnSubmit(aTeacher);
         db.SubmitChanges();
         return true;
     }
     catch (Exception ex)
     {
         return false;
         throw new Exception("TeacherBO.Insert" + ex.ToString());
     }
 }
示例#4
0
 // LoiNT
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         aTeacher = new Teacher();
         aTeacher.Tea_Name = txtName.Text;
         aTeacher.Tea_Address = txtAddress.Text;
         aTeacher.Tea_DateOfBirth = dtdate.Value;
         aTeacher.Tea_Ethnic = txtEthnic.Text;
         aTeacher.Tea_Religion = txtReligion.Text;
         aTeacher.Tea_PhoneNumber = txtPhone.Text;
         aTeacher.Tea_HomeTown = txtHometown.Text;
         // Check phone number and name to don't repeat record
         Teacher checkphone = aTeacherBO.Select_ByPhoneNumber(txtPhone.Text).FirstOrDefault();
         Teacher checkname = aTeacherBO.Select_ByName(txtName.Text).FirstOrDefault();
         if (txtName.Text != "" && txtPhone.Text != "" && txtAddress.Text != "" && txtHometown.Text != "")
         {
             if (checkphone == null || checkname == null)
             {
                 if (aTeacherBO.Insert(aTeacher))
                 {
                     MessageBox.Show("Thành Công", "Thành Công", MessageBoxButtons.OK);
                 }
                 else
                 {
                     MessageBox.Show("Thất Bại", "Thất Bại", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
             else
             {
                 MessageBox.Show("Giáo Viên Đã Tồn Tại", "Thất Bại", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             MessageBox.Show("Bạn chưa điền đầy đủ thông tin yêu cầu", "Thất Bại", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#5
0
 private Teacher ObTeacher(int id)
 {
     Teacher tempTeacher = new Teacher();
     foreach (var obj in db.Teachers)
     {
         if (obj.Tea_Code == id)
         {
             tempTeacher = obj;
         }
     }
     return tempTeacher;
 }
示例#6
0
文件: TeacherBO.cs 项目: ntlzz93/Temp
 // Update
 public bool Update(Teacher aTeacher)
 {
     try
     {
         var editObj = db.Teachers.Where(b=>b.Tea_Code == aTeacher.Tea_Code).FirstOrDefault();
         editObj.Tea_Name = aTeacher.Tea_Name;
         editObj.Tea_Address = aTeacher.Tea_Address;
         editObj.Tea_DateOfBirth = aTeacher.Tea_DateOfBirth;
         editObj.Tea_Ethnic = aTeacher.Tea_Ethnic;
         editObj.Tea_HomeTown = aTeacher.Tea_HomeTown;
         editObj.Tea_PhoneNumber = aTeacher.Tea_PhoneNumber;
         editObj.Tea_Religion = aTeacher.Tea_Religion;
         db.SubmitChanges();
         return true;
     }
     catch (Exception ex)
     {
         return false;
         throw new Exception("TeacherBO.Update" + ex.ToString());
     }
 }
示例#7
0
 partial void DeleteTeacher(Teacher instance);
示例#8
0
 partial void UpdateTeacher(Teacher instance);
示例#9
0
 partial void InsertTeacher(Teacher instance);