private void addbtn_Click(object sender, EventArgs e)
        {
            bool check = false;

            if (KiemTraErr(check) == true)
            {
                return;
            }

            ClassNhanVien nvien = NhanVienController.GetNV(this.cbbManv.Text.Trim());

            foreach (var cvg in nvien.listCVLam.ToList())
            {
                nvien.listCVLam.Remove(cvg);
            }
            foreach (var cvx in nvien.listCVXong.ToList())
            {
                nvien.listCVXong.Remove(cvx);
            }

            string displaycvGiao      = "";
            string displaycvHoanThanh = "";

            for (int i = 0; i < listBoxG.Items.Count; i++)
            {
                displaycvGiao = displaycvGiao + this.listBoxG.Items + " ";
                ClassCongViec cv = CongViecController.GetCV(this.listBoxG.Items[i].ToString());
                nvien.listCVLam.Add(cv);

                //nvien.MaDA = cv.listDA.ToList()[0].ToString() + " " + nvien.MaDA;
            }



            for (int j = 0; j < listBoxX.Items.Count; j++)
            {
                displaycvHoanThanh = displaycvHoanThanh + this.listBoxX.Items + " ";
                nvien.listCVXong.Add(CongViecController.GetCV(this.listBoxX.Items[j].ToString()));
            }

            string mada = "";

            foreach (var i in this.checkedListBox1.CheckedItems)
            {
                mada = mada + i.ToString() + " ";
            }
            nvien.MaDA = mada;
            if (NhanVienController.UpdateNvien(nvien) == false)
            {
                MessageBox.Show("Loi them cong viec", "Loi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            ShowData();

            ClearControls();
        }
Esempio n. 2
0
        private void addbtn_Click(object sender, EventArgs e)
        {
            //kiem man nhan vien da ton tai chua
            if (NhanVienController.GetNV(this.txtmanv.Text.Trim()) != null)
            {
                return;
            }

            bool check = false;

            if (KiemTraErr(check) == true)
            {
                return;
            }

            ClassNhanVien nv = new ClassNhanVien();

            nv.MaNV  = this.txtmanv.Text.Trim();
            nv.TenNV = this.txtTenNv.Text.Trim();
            if (this.checkFemale.Checked == true)
            {
                nv.GioiTinh = "Nu";
            }
            else
            {
                nv.GioiTinh = "Nam";
            }
            nv.SDT      = this.txtsdt.Text.Trim();
            nv.NgaySinh = this.Ngaysinhpicker.Value;
            nv.MaChucVu = this.cbbChucVu.Text.Trim();
            nv.Email    = this.txtemail.Text.Trim();
            nv.DiaChi   = this.txtDiachi.Text.Trim();

            //add xuong csdl
            if (NhanVienController.AddNV(nv) == false)
            {
                MessageBox.Show("Loi khi them nhan vien", "Loi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            ClearControls();

            ShowData();
        }