Пример #1
0
 private void metroButton1_Click(object sender, EventArgs e)
 {
     if (MetroFramework.MetroMessageBox.Show(this, "Bạn có chắc chắn muốn chuyển lớp?", "Cảnh báo!",
                                             MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
     {
         Lop lop   = db.Lops.Where(l => l.TenLop == cbLop.Text).FirstOrDefault() as Lop;
         int MaLop = lop.MaLop;
         try
         {
             SinhVienIns.SuaSinhVien(svien.MasV, svien.HoTen, svien.GioiTinh, svien.NoiSinh, svien.QueQuan, MaLop);
             MetroFramework.MetroMessageBox.Show(this, "Chuyển Lớp thành công!", "Thông báo!",
                                                 MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.Close();
             insert();
         }
         catch (Exception ex)
         {
             MetroFramework.MetroMessageBox.Show(this, ex.Message, "Lỗi!",
                                                 MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Пример #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         SinhVien svSua = GetInputForm();
         SinhVien.SuaSinhVien(svSua);
         CapNhatDanhSachSinhVien();
         SetInputForm(new SinhVien()
         {
             MaSV     = "",
             TenSV    = "",
             DiaChi   = "",
             NgaySinh = new DateTime(2000, 1, 1),
             SDT      = ""
         });
         txtMaSV.ReadOnly = false;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #3
0
        private void metroButton1_Click(object sender, EventArgs e)
        {
            string HoTen    = txtHoTen.Text;
            string NoiSinh  = txtNoiSinh.Text;
            string QueQuan  = txtQueQuan.Text;
            bool   GioiTinh = cbGioiTinh.Checked;
            Lop    lop      = db.Lops.Where(l => l.TenLop == cbLop.Text).FirstOrDefault() as Lop;
            int    MaLop    = lop.MaLop;

            if (HoTen.Equals(""))
            {
                MetroFramework.MetroMessageBox.Show(this, "Vui lòng nhập họ tên!", "Thông báo!",
                                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (NoiSinh.Equals(""))
            {
                MetroFramework.MetroMessageBox.Show(this, "Vui lòng nhập nơi sinh!", "Thông báo!",
                                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (QueQuan.Equals(""))
            {
                MetroFramework.MetroMessageBox.Show(this, "Vui lòng nhập quê quán!", "Thông báo!",
                                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            try
            {
                if (SVien == null)
                {
                    // Them
                    SinhVien sv = new SinhVien()
                    {
                        HoTen    = HoTen,
                        GioiTinh = GioiTinh,
                        NoiSinh  = NoiSinh,
                        QueQuan  = QueQuan,
                        MaLop    = MaLop
                    };
                    SinhVienIns.ThemSinhVien(sv);
                    MetroFramework.MetroMessageBox.Show(this, "Thêm thành công!", "Thông báo!",
                                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    // Sua
                    SinhVienIns.SuaSinhVien(SVien.MasV, HoTen, GioiTinh, NoiSinh, QueQuan, MaLop);
                    MetroFramework.MetroMessageBox.Show(this, "Sửa thành công!", "Thông báo!",
                                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                this.Close();
                insert();
            }
            catch (Exception ex)
            {
                MetroFramework.MetroMessageBox.Show(this, ex.Message, "Lỗi!",
                                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }