예제 #1
0
        void Save()
        {
            DialogResult dlr = MessageBox.Show("Lưu tất cả thay đổi?",
                                               "Save", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            if (dlr == DialogResult.Yes)
            {
                db.SaveChanges();
            }
        }
예제 #2
0
        private void btn_sua_Click(object sender, EventArgs e)
        {
            var n = nv.nhanviens.FirstOrDefault(x => x.ma == txt_manv.Text);

            n.ma  = txt_manv.Text;
            n.ten = txt_hoten.Text;

            Boolean gioiTinh = false;

            if (cmb_gioitinh.Text == "Nam")
            {
                gioiTinh = true;
            }
            n.gioitinh = gioiTinh;

            n.ngaysinh = DateTime.Parse(dtk_ngaysinh.Text);
            n.soCMT    = txt_cmtnd.Text;

            try
            {
                MemoryStream str1 = new MemoryStream();
                ptb_anh.Image.Save(str1, System.Drawing.Imaging.ImageFormat.Jpeg);

                byte[] pic = str1.ToArray();
                n.anh = pic;
            }
            catch
            {
                n.anh = null;
            }
            n.dienthoai       = txt_sdt.Text;
            n.email           = txt_email.Text;
            n.quoctich        = txt_quoctich.Text;
            n.tongiao         = txt_tongiao.Text;
            n.trinhdongoaingu = txt_ngoaingu.Text;
            n.dantoc          = txt_dantoc.Text;
            n.ngaycap         = DateTime.Parse(dtp_ngaycap.Text);
            n.noicap          = txt_noicap.Text;

            Boolean tinhtrang = false;

            if (cmb_tinhtranghonnhan.Text == "Đã kết hôn")
            {
                tinhtrang = true;
            }
            n.tinhtranghonnhan = tinhtrang;
            n.noisinh          = txt_noisinh.Text;
            n.quequan          = txt_quequan.Text;
            n.noiohiennay      = txt_tamtru.Text;
            n.hokhauthuongtru  = txt_thuongtru.Text;
            n.phongbanma       = txt_maphongban.Text;
            n.chucvuma         = txt_chucvu.Text;
            nv.SaveChanges();

            from2 fr = new from2();

            fr.Show(this);
            Hide();
            fr.load();
        }
예제 #3
0
        private void btn_xoa_Click(object sender, EventArgs e)
        {
            QLNhanSuEntities db = new QLNhanSuEntities();

            if (dgv_dsnv.SelectedRows.Count == 0)
            {
                MessageBox.Show("Cần chọn dữ liệu để xóa!", "Thông báo");
                return;
            }
            DialogResult = MessageBox.Show("Bạn có chắc muốn xóa!", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
            if (DialogResult == DialogResult.OK)
            {
                string id = dgv_dsnv.CurrentRow.Cells[0].Value.ToString();



                nhanvien nv = db.nhanviens.Single(s => s.ma == id);
                nv.status = 0;
                db.SaveChanges();
                load();
            }
        }