예제 #1
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            try
            {
                NguoiTimViec service = db.NguoiTimViecs.Find(int.Parse(txtMaNguoiTimViec.Text));
                service.HoTen       = txtHoTen.Text;
                service.NgaySinh    = dtpkNgaySinh.Value;
                service.GioiTinh    = txtGioiTinh.Text;
                service.DiaChi      = txtDiaChi.Text;
                service.DienThoai   = txtDienThoai.Text;
                service.HinhAnh     = txtHinhAnh.Text;
                service.TrinhDo     = txtTrinhDo.Text;
                service.ChuyenNganh = txtChuyenNganh.Text;
                service.BangCap     = txtBangCap.Text;

                //if (open.CheckFileExists)
                //{
                //    string directory = AppDomain.CurrentDomain.BaseDirectory;
                //    File.Copy(open.FileName, directory + service.MaDichVu + open.SafeFileName);
                //    service.HinhAnh = open.SafeFileName;
                //}
                db.SaveChanges();
                MessageBox.Show("Cập nhật thành công");
                LoadDtgv();
            }
            catch (Exception)
            {
                MessageBox.Show("Cập nhật không thành công. Vui lòng kiểm tra lại");
            }
        }
예제 #2
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            var confirmResult = MessageBox.Show("Bạn có chắc chắn muốn xóa",
                                                "Xác nhận!!",
                                                MessageBoxButtons.YesNo);

            if (confirmResult == DialogResult.Yes)
            {
                try
                {
                    NguoiTimViec service = db.NguoiTimViecs.Find(int.Parse(txtMaNguoiTimViec.Text));
                    db.NguoiTimViecs.Remove(service);
                    db.SaveChanges();
                    MessageBox.Show("Xóa thành công");
                    LoadDtgv();
                }
                catch (Exception)
                {
                    MessageBox.Show("Tồn tại Máy tính trong danh mục này");
                }
            }
        }
예제 #3
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            //if (!MyRegular.CheckRequired(txtTen.Text, "Bắt buộc nhập vào tên danh mục"))
            //    return;
            //else
            NguoiTimViec service = new NguoiTimViec();

            service.HoTen       = txtHoTen.Text;
            service.NgaySinh    = dtpkNgaySinh.Value;
            service.GioiTinh    = txtGioiTinh.Text;
            service.DiaChi      = txtDiaChi.Text;
            service.DienThoai   = txtDienThoai.Text;
            service.HinhAnh     = txtHinhAnh.Text;
            service.TrinhDo     = txtTrinhDo.Text;
            service.ChuyenNganh = txtChuyenNganh.Text;
            service.BangCap     = txtBangCap.Text;

            try
            {
                db.NguoiTimViecs.Add(service);
                db.SaveChanges();
                //if (open.CheckFileExists)
                //{
                //    string directory = AppDomain.CurrentDomain.BaseDirectory;
                //    File.Copy(open.FileName, directory + service.MaDichVu + open.SafeFileName);
                //    service.HinhAnh = open.SafeFileName;
                //}
                db.SaveChanges();
                MessageBox.Show("Thêm mới thành công");
                LoadDtgv();
            }
            catch (Exception)
            {
                MessageBox.Show("Thêm mới không thành công. Vui lòng kiểm tra lại");
            }
        }