public Sua(string id) { InitializeComponent(); QLNhanSuEntities1 nv = new QLNhanSuEntities1(); nhanvien newnv = nv.nhanviens.Single(s => s.ma == id); string path = newnv.anh.ToString(); if (!string.IsNullOrWhiteSpace(path)) { MemoryStream ms = new MemoryStream((byte[])newnv.anh); ptb_anh.Image = Image.FromStream(ms); } else { ptb_anh.Image = null; } txt_manv.Text = newnv.ma; txt_hoten.Text = newnv.ten; dtk_ngaysinh.Text = newnv.ngaysinh.ToString(); if (newnv.gioitinh.Value == false) { cmb_gioitinh.Text = "Nữ"; } else { cmb_gioitinh.Text = "Nam"; } dtk_ngaysinh.Text = newnv.ngaysinh.ToString(); if (newnv.gioitinh.Value == false) { cmb_gioitinh.Text = "Nữ"; } else { cmb_gioitinh.Text = "Nam"; } txt_sdt.Text = newnv.dienthoai; txt_email.Text = newnv.email; txt_quoctich.Text = newnv.quoctich; txt_dantoc.Text = newnv.dantoc; txt_tongiao.Text = newnv.tongiao; if (newnv.tinhtranghonnhan == false) { cmb_tinhtranghonnhan.Text = "Chưa kết hôn"; } else { cmb_tinhtranghonnhan.Text = "Đã kết hôn"; } txt_cmtnd.Text = newnv.soCMT; dtp_ngaycap.Text = newnv.ngaycap.ToString(); txt_noicap.Text = newnv.noicap; txt_noisinh.Text = newnv.noisinh; txt_quequan.Text = newnv.quequan; txt_tamtru.Text = newnv.noiohiennay; txt_thuongtru.Text = newnv.hokhauthuongtru; txt_hocvan.Text = newnv.hocvanma; txt_chucvu.Text = newnv.chucvuma; txt_ngoaingu.Text = newnv.trinhdongoaingu; txt_maphongban.Text = newnv.phongbanma; //txt_mahd.Text = newnv.hopdonglaodongnhanvienma; //var tenhd = from s in nv.hopdonglaodongnhanviens where s.ma == newnv.hopdonglaodongnhanvienma select s.ten; //var luongcoban = from s in nv.hopdonglaodongnhanviens where s.ma == newnv.hopdonglaodongnhanvienma select s.luongthuviec; //var ngaybd = from s in nv.hopdonglaodongnhanviens where s.ma == newnv.hopdonglaodongnhanvienma select s.ngaybatdau; //var ngaykt = from s in nv.hopdonglaodongnhanviens where s.ma == newnv.hopdonglaodongnhanvienma select s.ngayketthuc; //txt_tenhd.Text = tenhd.FirstOrDefault(); //txt_luongcb.Text = luongcoban.FirstOrDefault().ToString(); //txt_ngaykt.Text = ngaykt.FirstOrDefault().ToString(); }
private void dgv_dsnv_CellContentClick(object sender, DataGridViewCellEventArgs e) { string path = dgv_dsnv.CurrentRow.Cells[5].Value.ToString(); if (!string.IsNullOrWhiteSpace(path)) { MemoryStream ms = new MemoryStream((byte[])dgv_dsnv.CurrentRow.Cells[5].Value); ptb_anh.Image = Image.FromStream(ms); } else { ptb_anh.Image = null; } string id = dgv_dsnv.CurrentRow.Cells[0].Value.ToString(); QLNhanSuEntities1 nv = new QLNhanSuEntities1(); nhanvien newnv = nv.nhanviens.Single(s => s.ma == id); txt_manv.Text = newnv.ma; txt_hoten.Text = newnv.ten; dtk_ngaysinh.Text = newnv.ngaysinh.ToString(); if (newnv.gioitinh.Value == false) { cmb_gioitinh.Text = "Nữ"; } else { cmb_gioitinh.Text = "Nam"; } txt_sdt.Text = newnv.dienthoai; txt_email.Text = newnv.email; txt_quoctich.Text = newnv.quoctich; txt_dantoc.Text = newnv.dantoc; txt_tongiao.Text = newnv.tongiao; if (newnv.tinhtranghonnhan == false) { cmb_tinhtranghonnhan.Text = "Chưa kết hôn"; } else { cmb_tinhtranghonnhan.Text = "Đã kết hôn"; } txt_cmtnd.Text = newnv.soCMT; dtp_ngaycap.Text = newnv.ngaycap.ToString(); txt_noicap.Text = newnv.noicap; txt_noisinh.Text = newnv.noisinh; txt_quequan.Text = newnv.quequan; txt_tamtru.Text = newnv.noiohiennay; txt_thuongtru.Text = newnv.hokhauthuongtru; txt_hocvan.Text = newnv.hocvanma; txt_chucvu.Text = newnv.chucvuma; txt_ngoaingu.Text = newnv.trinhdongoaingu; txt_maphongban.Text = newnv.phongbanma; txt_mahd.Text = newnv.hopdonglaodongnhanvienma; var tenhd = from s in nv.hopdonglaodongnhanviens where s.ma == newnv.hopdonglaodongnhanvienma select s.ten; var luongcoban = from s in nv.hopdonglaodongnhanviens where s.ma == newnv.hopdonglaodongnhanvienma select s.luongthuviec; var ngaybd = from s in nv.hopdonglaodongnhanviens where s.ma == newnv.hopdonglaodongnhanvienma select s.ngaybatdau; var ngaykt = from s in nv.hopdonglaodongnhanviens where s.ma == newnv.hopdonglaodongnhanvienma select s.ngayketthuc; txt_tenhd.Text = tenhd.FirstOrDefault(); txt_luongcb.Text = luongcoban.FirstOrDefault().ToString(); txt_ngaykt.Text = ngaykt.FirstOrDefault().ToString(); }