Ejemplo n.º 1
0
        public void display()
        {
            this.clMaNhom.DataPropertyName     = nameof(Nhom.MaNhom);
            this.clTenNhom.DataPropertyName    = nameof(Nhom.TenNhom);
            this.clNhomTruong.DataPropertyName = nameof(Nhom.NhomTruong);
            cbxListCongViec.DataSource         = CongViecControllers.getListCongViecfromDB();
            cbxListCongViec.DisplayMember      = "TenCongViec";


            List <Nhom>   lstNhom = NhomControllers.getListNhomfromDB();
            BindingSource src     = new BindingSource();

            src.DataSource           = lstNhom;
            dataGridView1.DataSource = src;
            if (qh == 0)
            {
                btnThemNhom.Visible = false;
                btnSuaNhom.Visible  = false;
                btnXoaNhom.Visible  = false;
            }
            else if (qh == 1)
            {
            }

            dataGridView1.Columns[3].Visible = false;
            dataGridView1.Columns[4].Visible = false;
            dataGridView1.Columns[5].Visible = false;
            dataGridView1.Columns[6].Visible = false;
        }
Ejemplo n.º 2
0
        private void btnXoaNhom_Click(object sender, EventArgs e)
        {
            if (this.dataGridView1.CurrentCell.Value == null)
            {
                return;
            }
            CongViec      cv    = lcv[cbxListCongViec.SelectedIndex];
            List <string> lstcv = cv.ListNhomPhuTrach.Split(',').ToList();

            foreach (var item in lstcv)
            {
                if (dataGridView1.CurrentRow.Cells[0].Value.ToString().Trim() == item.Trim())
                {
                    lstcv.Remove(item);
                    break;
                }
            }
            if (lstcv[0] != null)
            {
                cv.ListNhomPhuTrach = lstcv[0];
            }
            else
            {
                cv.ListNhomPhuTrach = "";
            }
            for (int i = 1; i < lstcv.Count; i++)
            {
                cv.ListNhomPhuTrach = cv.ListNhomPhuTrach + "," + lstcv[i];
            }
            CongViecControllers.updateCongViec(cv);
            List <NhanVien> listnv = NhanVienControllers.getListNhanVienfromDB();

            foreach (var item in listnv)
            {
                if (item.Nhom.Trim() == dataGridView1.CurrentRow.Cells[0].Value.ToString().Trim())
                {
                    NhanVienControllers.DeleteNhanVien(item);
                }
            }
            NhomControllers.DeleteNhom(dataGridView1.CurrentRow.Cells[0].Value.ToString().Trim());
            BindingSource src = new BindingSource();

            src.DataSource = NhomControllers.getListNhomfromDB();
            this.dataGridView1.DataSource = src;
        }
Ejemplo n.º 3
0
        private void btnSuaNhom_Click(object sender, EventArgs e)
        {
            if (this.txtNhom.Text.Trim().Length <= 0)
            {
                this.errorProvider1.SetError(this.txtNhom, "nhap ten ma nhom");
                return;
            }
            else
            {
                this.errorProvider1.Clear();
            }

            if (this.txtTenNhom.Text.Trim().Length <= 0)
            {
                this.errorProvider1.SetError(this.txtTenNhom, "nhap ten nhom");
                return;
            }
            else
            {
                this.errorProvider1.Clear();
            }
            if (this.txtNhomTruong.Text.Trim().Length <= 0)
            {
                this.errorProvider1.SetError(this.txtNhomTruong, "nhap ma nhan vien nhom truong");
                return;
            }
            else
            {
                this.errorProvider1.Clear();
            }
            Nhom nh = new Nhom();

            nh.MaNhom     = txtNhom.Text.Trim();
            nh.TenNhom    = txtTenNhom.Text.Trim();
            nh.NhomTruong = txtNhomTruong.Text.Trim();

            NhomControllers.updateNhom(nh);
            BindingSource source = new BindingSource();

            source.DataSource             = NhomControllers.getListNhomfromDB();
            this.dataGridView1.DataSource = source;
        }
Ejemplo n.º 4
0
        private void btnXoaCongViec_Click(object sender, EventArgs e)
        {
            if (this.dataGridViewCongViec.CurrentCell.Value == null)
            {
                return;
            }
            DuAn da = lda[cbxListDuAn.SelectedIndex];

            string[]      lcongviec = da.CongViecDuAn.Split(',');
            List <string> lstringcv = lcongviec.ToList();

            foreach (var item in lstringcv)
            {
                if (dataGridViewCongViec.CurrentRow.Cells[0].Value.ToString().Trim() == item.Trim())
                {
                    lstringcv.Remove(item);
                    break;
                }
            }
            if (lstringcv.Count != 0)
            {
                da.CongViecDuAn = lstringcv[0].Trim();
                for (int i = 1; i < lstringcv.Count; i++)
                {
                    da.CongViecDuAn = da.CongViecDuAn + "," + lstringcv[i].Trim();
                }
                DuAnControllers.updateDA(da);
            }
            else
            {
                da.CongViecDuAn = "";
                DuAnControllers.updateDA(da);
            }
            CongViec cv = CongViecControllers.getCongViecfromDB(this.dataGridViewCongViec.CurrentRow.Cells[0].Value.ToString().Trim());

            if (cv.NoiDungCongViec.ToString().Trim() != "")
            {
                List <string> listcongviecnv = cv.NoiDungCongViec.Split(',').ToList();
                // listcongviecnv[listcongviecnv.Count - 1].Trim();
                foreach (var item in listcongviecnv)
                {
                    CongViecNhanVienControllers.DeleteCVNV(item);
                }
            }
            if (cv.ListNhomPhuTrach != null)
            {
                List <string> listnhom = cv.ListNhomPhuTrach.Split(',').ToList();
                listnhom[listnhom.Count - 1].Trim();
                foreach (var item in listnhom)
                {
                    List <NhanVien> listnv = NhanVienControllers.getListNhanVienfromDB();
                    foreach (var item2 in listnv)
                    {
                        if (item2.Nhom.Trim() == item.Trim())
                        {
                            NhanVienControllers.DeleteNhanVien(item2);
                        }
                    }
                    NhomControllers.DeleteNhom(item);
                }
            }
            CongViecControllers.DeleteCongViec(this.dataGridViewCongViec.CurrentRow.Cells[0].Value.ToString().Trim());
            BindingSource src = new BindingSource();

            src.DataSource = CongViecControllers.getListCongViecfromDB();
            this.dataGridViewCongViec.DataSource = src;
        }
Ejemplo n.º 5
0
        private void dataGridViewDuAn_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            chlbCongViec.Items.Clear();
            tinhChiPhiDA();
            tinhTienDoDA();
            dahoanthanh();

            cbxNhom.DataSource = null;
            if (true)
            {
                if (this.dataGridViewDuAn.Columns[e.ColumnIndex].DataPropertyName != nameof(DuAn.MaDuAn))
                {
                    if (this.dataGridViewDuAn.CurrentRow.Cells[0].Value == null)
                    {
                        MessageBox.Show("Chua nhap Ma Du An");
                        return;
                    }
                }
                if (dataGridViewDuAn.CurrentRow.Cells[3].Value == null)
                {
                    txtChiPhiDuAn.Text = "0";
                }
                else
                {
                    txtChiPhiDuAn.Text = dataGridViewDuAn.CurrentRow.Cells[3].Value.ToString();
                }
                txtMaDuAn.Text                = dataGridViewDuAn.CurrentRow.Cells[0].Value.ToString();
                txtTenDuAn.Text               = dataGridViewDuAn.CurrentRow.Cells[1].Value.ToString();
                dateTimeBatDauDuAn.Value      = DateTime.Parse(dataGridViewDuAn.CurrentRow.Cells[7].Value.ToString());
                dateNgayDuKienHoanThanh.Value = DateTime.Parse(dataGridViewDuAn.CurrentRow.Cells[6].Value.ToString());
                if (dataGridViewDuAn.CurrentRow.Cells[9].Value == null)
                {
                    dateTimeNgayHoanThanh.Value = DateTime.Parse("01/01/2000 12:00:00 AM");
                }
                else
                {
                    dateTimeNgayHoanThanh.Value = DateTime.Parse(dataGridViewDuAn.CurrentRow.Cells[9].Value.ToString());
                }

                if (dataGridViewDuAn.CurrentRow.Cells[2].Value != null)
                {
                    rtxtMucTieu.Text = dataGridViewDuAn.CurrentRow.Cells[2].Value.ToString();
                }
                if (dataGridViewDuAn.CurrentRow.Cells[8].Value == null || int.Parse(dataGridViewDuAn.CurrentRow.Cells[8].Value.ToString()) == -2147483648)
                {
                    pgbTienDoDuAn.Value = 0;
                }
                else
                {
                    pgbTienDoDuAn.Value = int.Parse(dataGridViewDuAn.CurrentRow.Cells[8].Value.ToString());
                }
                //cho ma cong viec vao => list cong viec setitemchecked
                List <DuAn> da = DuAnControllers.getListDuAnfromDB();
                if (da[dataGridViewDuAn.CurrentRow.Index].CongViecDuAn == null)
                {
                    return;
                }

                string macongviec = da[dataGridViewDuAn.CurrentRow.Index].CongViecDuAn;
                macongviec = macongviec.Trim();
                string[]        listtencongviec = macongviec.Trim().Split(',');
                List <CongViec> lcv             = CongViecControllers.getListCongViecfromDB(listtencongviec);

                foreach (var item in listtencongviec)
                {
                    chlbCongViec.Items.Add(item.Trim());
                }
                foreach (var item in lcv)
                {
                    if (item.TienDo == 100)
                    {
                        for (int i = 0; i < chlbCongViec.Items.Count; i++)
                        {
                            if (chlbCongViec.Items[i].ToString() == item.MaCongViec.ToString().Trim())
                            {
                                chlbCongViec.SetItemChecked(i, true);
                            }
                        }
                    }
                }
                List <string> listnhom = new List <string>();

                foreach (var item in listtencongviec)
                {
                    if (NhomControllers.getListNhomfromDB(item) != null)
                    {
                        string[] lstnhom = NhomControllers.getListNhomfromDB(item).Split(',');
                        foreach (var nhom in lstnhom)
                        {
                            listnhom.Add(nhom);
                        }
                    }
                }
                cbxNhom.DataSource = listnhom;
            }
            else
            {
                return;
            }
        }
Ejemplo n.º 6
0
        private void btnThemNhom_Click(object sender, EventArgs e)
        {
            if (this.txtNhom.Text.Trim().Length <= 0)
            {
                this.errorProvider1.SetError(this.txtNhom, "nhap ten ma nhom");
                return;
            }
            else
            {
                this.errorProvider1.Clear();
            }
            if (NhomControllers.getNhomfromDB(this.txtNhom.Text.Trim()) != "")
            {
                this.errorProvider1.SetError(this.txtNhom, "Ma nhom da ton tai");
                return;
            }
            this.errorProvider1.Clear();
            if (this.txtTenNhom.Text.Trim().Length <= 0)
            {
                this.errorProvider1.SetError(this.txtTenNhom, "nhap ten nhom");
                return;
            }
            else
            {
                this.errorProvider1.Clear();
            }
            if (this.txtNhomTruong.Text.Trim().Length <= 0)
            {
                this.errorProvider1.SetError(this.txtNhomTruong, "nhap ma nhan vien nhom truong");
                return;
            }
            else
            {
                this.errorProvider1.Clear();
            }
            if (NhanVienControllers.getNhanVienfromDB(this.txtNhomTruong.Text.Trim()) == null)
            {
                this.errorProvider1.SetError(this.txtNhom, "khong tim thay nhom truong");
                return;
            }
            this.errorProvider1.Clear();
            Nhom nh = new Nhom();

            nh.MaNhom     = txtNhom.Text.Trim();
            nh.TenNhom    = txtTenNhom.Text.Trim();
            nh.NhomTruong = txtNhomTruong.Text.Trim();

            NhomControllers.AddNhom(nh);
            BindingSource source = new BindingSource();

            source.DataSource             = NhomControllers.getListNhomfromDB();
            this.dataGridView1.DataSource = source;
            CongViec cv = CongViecControllers.getCongViecfromDB(lcv[(cbxListCongViec.SelectedIndex)].MaCongViec.Trim());

            if (cv.ListNhomPhuTrach == "" || cv.ListNhomPhuTrach == null)
            {
                cv.ListNhomPhuTrach = txtNhom.Text.Trim();
            }
            else
            {
                cv.ListNhomPhuTrach = cv.ListNhomPhuTrach.Trim() + "," + txtNhom.Text.Trim();
            }
            CongViecControllers.updateCongViec(cv);
        }