Example #1
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();
            }
        }
Example #2
0
        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();
        }
Example #3
0
        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();
        }
Example #4
0
        private void btn_OK_Click(object sender, EventArgs e)
        {
            QLNhanSuEntities db = new QLNhanSuEntities();
            nhanvien         n  = new nhanvien();

            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;

            db.nhanviens.Add(n);
            db.SaveChanges();
            from2 fr = new from2();

            fr.Show();
            fr.load();
            Hide();
        }
Example #5
0
 private void dgv_phucap_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     string           id    = dgv_dsnv.CurrentRow.Cells[0].Value.ToString();
     QLNhanSuEntities nv    = new QLNhanSuEntities();
     nhanvien         newnv = nv.nhanviens.Single(s => s.ma == id);
 }