Example #1
0
        public void cvhoanthanh()
        {
            List <CongViec> lcv = CongViecControllers.getListCongViecfromDB();

            foreach (CongViec cv in lcv)
            {
                int      flag                   = 0;
                string[] lcongviennv            = cv.NoiDungCongViec.Trim().Split(',');
                List <CongViecNhanVien> lstcvnv = new List <CongViecNhanVien>();
                foreach (var item in lcongviennv)
                {
                    if (CongViecNhanVienControllers.CheckCongViecNhanVienHoanThanhfromDB(item) == false)
                    {
                        flag = 1;
                        break;
                    }
                    else
                    {
                        lstcvnv.Add(CongViecNhanVienControllers.getCongViecNhanVienfromDB(item));
                    }
                }
                if (flag == 0)
                {
                    cv.NgayHoanThanh = checkmaxtime(lstcvnv);
                }
                CongViecControllers.updateCongViec(cv);
            }
        }
Example #2
0
        public void dahoanthanh()
        {
            List <DuAn> lda = DuAnControllers.getListDuAnfromDB();

            foreach (DuAn da in lda)
            {
                int flag = 0;
                if (da.CongViecDuAn != null)
                {
                    string[]        lcongviecda = da.CongViecDuAn.Trim().Split(',');
                    List <CongViec> lstcv       = new List <CongViec>();
                    foreach (var item in lcongviecda)
                    {
                        if (CongViecControllers.CheckCongViecHoanThanhfromDB(item) == false)
                        {
                            flag = 1;
                            break;
                        }
                        else
                        {
                            lstcv.Add(CongViecControllers.getCongViecfromDB(item));
                        }
                    }
                    if (flag == 0)
                    {
                        da.NgayHoanThanh = checkmaxtime(lstcv);
                    }
                    DuAnControllers.updateDA(da);
                }
            }
        }
        public void display()
        {
            this.clMaCongViecNhanVien.DataPropertyName = nameof(CongViecNhanVien.MaCongViecNhanVien);
            this.clMaNhanVienPhuTrach.DataPropertyName = nameof(CongViecNhanVien.MaNhanVienPhuTrach);
            this.clTenCongViec.DataPropertyName        = nameof(CongViecNhanVien.TenCongViec);
            this.clMoTa.DataPropertyName            = nameof(CongViecNhanVien.MoTa);
            this.clTaiLieu.DataPropertyName         = nameof(CongViecNhanVien.TaiLieu);
            this.clLuongCongViec.DataPropertyName   = nameof(CongViecNhanVien.LuongCongViec);
            this.clDuKienHoanThanh.DataPropertyName = nameof(CongViec.DuKienHoanThanh);
            this.clNgayBatDau.DataPropertyName      = nameof(CongViec.NgayBatDau);
            this.clTienDo.DataPropertyName          = nameof(CongViec.TienDo);
            this.clNgayHoanThanh.DataPropertyName   = nameof(CongViec.NgayHoanThanh);

            cbxListCongViecnv.DataSource    = CongViecControllers.getListCongViecfromDB();
            cbxListCongViecnv.DisplayMember = "TenCongViec";
            List <CongViecNhanVien> lstCongViecNhanVien = CongViecNhanVienControllers.getListCongViecNhanVienfromDB();
            BindingSource           src = new BindingSource();

            src.DataSource = lstCongViecNhanVien;
            dataGridViewCongViecDangThucHien.DataSource = src;
            if (qh == 0)
            {
                btnThemCongViec.Visible = false;
                //btnSuaCongViec.Visible = false;
            }
            else if (qh == 1)
            {
            }
            dataGridViewCongViecDangThucHien.Columns[10].Visible = false;
            //dataGridViewCongViec.Columns[10].Visible = false;
        }
Example #4
0
        public void tinhTienDoDA()
        {
            List <DuAn> lstDuAn = DuAnControllers.getListDuAnfromDB();

            foreach (DuAn da in lstDuAn)
            {
                if (da.CongViecDuAn != null)
                {
                    string macongviec = da.CongViecDuAn;
                    macongviec = macongviec.Trim();
                    string[]        listtencongviec = macongviec.Split(',');
                    List <CongViec> lcv             = CongViecControllers.getListCongViecfromDB(listtencongviec);
                    int             td = 0;
                    int             k  = lcv.Count;
                    foreach (CongViec cv in lcv)
                    {
                        if (cv.TienDo == 100)
                        {
                            td += 1;
                        }
                    }
                    float ht = 100;
                    float h  = (float)td / k;
                    da.TienDo = (int)(h * ht);
                    DuAnControllers.updateDA(da);
                }
            }
        }
Example #5
0
        public void tinhChiPhiDA()
        {
            List <DuAn> lstDuAn = DuAnControllers.getListDuAnfromDB();

            foreach (DuAn da in lstDuAn)
            {
                if (da.CongViecDuAn != null)
                {
                    string macongviec = da.CongViecDuAn.Trim();
                    macongviec = macongviec.Trim();
                    string[]        listtencongviec = macongviec.Split(',');
                    List <CongViec> lcv             = CongViecControllers.getListCongViecfromDB(listtencongviec);
                    int             cp = 0;
                    foreach (CongViec cv in lcv)
                    {
                        if (cv.ChiPhi != null)
                        {
                            cp += cv.ChiPhi.Value;
                        }
                    }
                    da.ChiPhiDuAn = cp;
                    DuAnControllers.updateDA(da);
                }
            }
        }
        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;
        }
        private void dataGridViewCongViecDangThucHien_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                txtMaNhanVien.Text           = dataGridViewCongViecDangThucHien.CurrentRow.Cells[1].Value.ToString();
                txtMaCongViecNhanVien.Text   = dataGridViewCongViecDangThucHien.CurrentRow.Cells[0].Value.ToString();
                txtTenCongViecNhanVien.Text  = dataGridViewCongViecDangThucHien.CurrentRow.Cells[2].Value.ToString();
                txtMoTaCongViecNhanVien.Text = dataGridViewCongViecDangThucHien.CurrentRow.Cells[3].Value.ToString();
                txtTaiLieu.Text                   = dataGridViewCongViecDangThucHien.CurrentRow.Cells[4].Value.ToString();
                txtLuongCongViec.Text             = dataGridViewCongViecDangThucHien.CurrentRow.Cells[5].Value.ToString();
                dateTimeDuKienHoanThanhCVNV.Value = DateTime.Parse(dataGridViewCongViecDangThucHien.CurrentRow.Cells[6].Value.ToString());
                dateTimeNgayBatDauCVNV.Value      = DateTime.Parse(dataGridViewCongViecDangThucHien.CurrentRow.Cells[7].Value.ToString());
                txtTienDoCongViecNhanVien.Text    = dataGridViewCongViecDangThucHien.CurrentRow.Cells[8].Value.ToString();
                dateTimeNgayKetThucCVNV.Value     = DateTime.Parse(dataGridViewCongViecDangThucHien.CurrentRow.Cells[9].Value.ToString());



                List <CongViec>         lcv   = CongViecControllers.getListCongViecfromDB();
                List <CongViecNhanVien> lcvnv = CongViecNhanVienControllers.getListCongViecNhanVienfromDB();
                int index = -1;
                for (int i = 0; i < lcv.Count; i++)
                {
                    if (lcv[i].NoiDungCongViec != null)
                    {
                        string[] check = lcv[i].NoiDungCongViec.Split(',');
                        foreach (var item2 in check)
                        {
                            if (item2.Trim() == lcvnv[dataGridViewCongViecDangThucHien.CurrentRow.Index].MaCongViecNhanVien.Trim())
                            {
                                index = i;
                            }
                        }
                        if (index != -1)
                        {
                            break;
                        }
                    }
                }
                if (index == -1)
                {
                    return;
                }
                cbxListCongViecnv.SelectedIndex = index;
            }
            catch
            {
                return;
            }
        }
        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;
        }
Example #9
0
        public void display()
        {
            this.clMaCongViec.DataPropertyName      = nameof(CongViec.MaCongViec);
            this.clTenCongViec.DataPropertyName     = nameof(CongViec.TenCongViec);
            this.clNoiDungCongViec.DataPropertyName = nameof(CongViec.NoiDungCongViec);
            this.clNhomPhuTrach.DataPropertyName    = nameof(CongViec.ListNhomPhuTrach);
            this.clChiPhi.DataPropertyName          = nameof(CongViec.ChiPhi);
            this.clDuKienHoanThanh.DataPropertyName = nameof(CongViec.DuKienHoanThanh);
            this.clNgayBatDau.DataPropertyName      = nameof(CongViec.NgayBatDau);
            this.clTienDo.DataPropertyName          = nameof(CongViec.TienDo);
            this.clNgayHoanThanh.DataPropertyName   = nameof(CongViec.NgayHoanThanh);
            cbxListDuAn.DataSource    = DuAnControllers.getListDuAnfromDB();
            cbxListDuAn.DisplayMember = "TenDuAn";

            List <CongViec> lstCongViec = CongViecControllers.getListCongViecfromDB();

            for (int i = 0; i <= lstCongViec.Count - 1; i++)
            {
                CongViecControllers.updateChiPhi(lstCongViec[i]);
                CongViecControllers.updateTienDo(lstCongViec[i]);
            }
            BindingSource src = new BindingSource();

            src.DataSource = lstCongViec;
            dataGridViewCongViec.DataSource = src;
            if (qh == 0)
            {
                btnThemCongViec.Visible = false;
                btnSuaCongViec.Visible  = false;
            }
            else if (qh == 1)
            {
            }
            dataGridViewCongViec.Columns[9].Visible  = false;
            dataGridViewCongViec.Columns[10].Visible = false;
        }
Example #10
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;
        }
Example #11
0
        private void btnSuaCongViec_Click(object sender, EventArgs e)
        {
            if (this.txtTenCongViec.Text.Trim().Length <= 0 || this.txtMaCongViec.Text.Trim().Length <= 0 || this.dateTimeDuKienHoanThanh.Value > DateTime.Now || this.dateTimeBatDauCongViec.Value > DateTime.Now || this.dateTimeDuKienHoanThanh.Value > DateTime.Now)
            {
                if (this.txtMaCongViec.Text.Trim().Length <= 0)
                {
                    this.errorProvider1.SetError(this.txtMaCongViec, "Ma cong viec khong duoc trong");
                    return;
                }
                else if (CongViecControllers.getMaCongViecfromDB(this.txtMaCongViec.Text.Trim()) != "")
                {
                    this.errorProvider1.SetError(this.txtMaCongViec, "Ma cong viec da ton tai");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }
                if (this.txtTenCongViec.Text.Trim().Length <= 0)
                {
                    this.errorProvider1.SetError(this.txtTenCongViec, "nhap ten cong viec");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }
                if (this.dateTimeBatDauCongViec.Value <= DateTime.Now)
                {
                    this.errorProvider1.SetError(this.dateTimeBatDauCongViec, "nhap ngay bat dau");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }
                if (this.dateTimeDuKienHoanThanh.Value <= DateTime.Now)
                {
                    this.errorProvider1.SetError(this.dateTimeDuKienHoanThanh, "nhap ngay du kien hoan thanh");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }
            }

            var lcv = CongViecControllers.getListCongViecfromDB();

            CongViec cv = new CongViec();

            cv.MaCongViec      = txtMaCongViec.Text.Trim();
            cv.TenCongViec     = txtTenCongViec.Text.Trim();
            cv.NoiDungCongViec = rtxtNoiDungCongViec.Text.Trim();
            //cv.ListNhomPhuTrach = cbbNhom.SelectedItem.ToString();
            cv.NgayBatDau      = DateTime.Parse(dateTimeBatDauCongViec.Value.ToString());
            cv.DuKienHoanThanh = DateTime.Parse(dateTimeDuKienHoanThanh.Value.ToString());
            cv.NgayHoanThanh   = lcv[dataGridViewCongViec.CurrentRow.Index].NgayHoanThanh;
            cv.TienDo          = lcv[dataGridViewCongViec.CurrentRow.Index].TienDo;
            cv.ChiPhi          = lcv[dataGridViewCongViec.CurrentRow.Index].ChiPhi;



            CongViecControllers.updateCongViec(cv);
            BindingSource source = new BindingSource();

            source.DataSource = CongViecControllers.getListCongViecfromDB();
            this.dataGridViewCongViec.DataSource = source;
        }
Example #12
0
        private void btnThemCongViec_Click(object sender, EventArgs e)
        {
            if (this.txtTenCongViec.Text.Trim().Length <= 0 || this.txtMaCongViec.Text.Trim().Length <= 0 || this.dateTimeDuKienHoanThanh.Value > DateTime.Now || this.dateTimeBatDauCongViec.Value > DateTime.Now || this.dateTimeDuKienHoanThanh.Value > DateTime.Now)
            {
                if (this.txtMaCongViec.Text.Trim().Length <= 0)
                {
                    this.errorProvider1.SetError(this.txtMaCongViec, "Ma cong viec khong duoc trong");
                    return;
                }
                else if (CongViecControllers.getMaCongViecfromDB(this.txtMaCongViec.Text.Trim()) != "")
                {
                    this.errorProvider1.SetError(this.txtMaCongViec, "Ma cong viec da ton tai");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }
                if (this.txtTenCongViec.Text.Trim().Length <= 0)
                {
                    this.errorProvider1.SetError(this.txtTenCongViec, "nhap ten cong viec");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }
                if (this.dateTimeBatDauCongViec.Value <= DateTime.Now)
                {
                    this.errorProvider1.SetError(this.dateTimeBatDauCongViec, "nhap ngay bat dau");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }
                if (this.dateTimeDuKienHoanThanh.Value <= DateTime.Now)
                {
                    this.errorProvider1.SetError(this.dateTimeDuKienHoanThanh, "nhap ngay du kien hoan thanh");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }
            }
            CongViec cv = new CongViec();

            cv.MaCongViec      = txtMaCongViec.Text.Trim();
            cv.TenCongViec     = txtTenCongViec.Text.Trim();
            cv.NoiDungCongViec = rtxtNoiDungCongViec.Text.Trim();
            //cv.ListNhomPhuTrach = cbbNhom.SelectedItem.ToString();
            cv.NgayBatDau      = DateTime.Parse(dateTimeBatDauCongViec.Value.ToString());
            cv.DuKienHoanThanh = DateTime.Parse(dateTimeDuKienHoanThanh.Value.ToString());
            cv.NgayHoanThanh   = DateTime.Parse("01/01/2000 12:00:00 AM");
            cv.TienDo          = 0;
            cv.ChiPhi          = 0;
            DuAn da = DuAnControllers.getDuAnfromDB(lda[(cbxListDuAn.SelectedIndex)].MaDuAn.Trim());

            if (da.CongViecDuAn == null)
            {
                da.CongViecDuAn = txtMaCongViec.Text.Trim();
            }
            else
            {
                da.CongViecDuAn = da.CongViecDuAn.Trim() + "," + txtMaCongViec.Text.Trim();
            }
            DuAnControllers.updateDA(da);


            CongViecControllers.AddCongViec(cv);
            BindingSource source = new BindingSource();

            source.DataSource = CongViecControllers.getListCongViecfromDB();
            this.dataGridViewCongViec.DataSource = source;
        }
Example #13
0
        private void dataGridViewCongViec_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            List <CongViec> lstCongViec = CongViecControllers.getListCongViecfromDB();

            for (int i = 0; i <= lstCongViec.Count - 1; i++)
            {
                CongViecControllers.updateChiPhi(lstCongViec[i]);
                CongViecControllers.updateTienDo(lstCongViec[i]);
            }

            try
            {
                txtMaCongViec.Text       = dataGridViewCongViec.CurrentRow.Cells[0].Value.ToString();
                txtTenCongViec.Text      = dataGridViewCongViec.CurrentRow.Cells[1].Value.ToString();
                rtxtNoiDungCongViec.Text = dataGridViewCongViec.CurrentRow.Cells[2].Value.ToString();
                if (dataGridViewCongViec.CurrentRow.Cells[3].Value == null)
                {
                    cbbNhom.DataSource = null;
                    cbbNhom.Text       = "";
                }
                else
                {
                    cbbNhom.Text = dataGridViewCongViec.CurrentRow.Cells[3].Value.ToString();
                }
                txtChiPhi.Text = dataGridViewCongViec.CurrentRow.Cells[4].Value.ToString();
                dateTimeDuKienHoanThanh.Value = DateTime.Parse(dataGridViewCongViec.CurrentRow.Cells[5].Value.ToString());
                dateTimeBatDauCongViec.Value  = DateTime.Parse(dataGridViewCongViec.CurrentRow.Cells[6].Value.ToString());
                //cbbTienDo.Text =
                if (dataGridViewCongViec.CurrentRow.Cells[7].Value != null)
                {
                    progressBar1.Value = int.Parse(dataGridViewCongViec.CurrentRow.Cells[7].Value.ToString());
                }
                else
                {
                    progressBar1.Value = 0;
                }
                ///////////////
                dateTimeThoiGianHoanThanh.Value = DateTime.Parse(dataGridViewCongViec.CurrentRow.Cells[8].Value.ToString());
                var lcv = CongViecControllers.getListCongViecfromDB();
                lda = DuAnControllers.getListDuAnfromDB();
                int index = -1;
                for (int i = 0; i < lda.Count; i++)
                {
                    if (lda[i].CongViecDuAn != null)
                    {
                        string[] check = lda[i].CongViecDuAn.Split(',');
                        foreach (var item2 in check)
                        {
                            if (item2.Trim() == lcv[dataGridViewCongViec.CurrentRow.Index].MaCongViec.Trim())
                            {
                                index = i;
                            }
                        }
                        if (index != -1)
                        {
                            break;
                        }
                    }
                }
                if (index == -1)
                {
                    return;
                }
                cbxListDuAn.SelectedIndex = index;
            }
            catch
            {
                return;
            }
        }
        private void btnThemCongViec_Click(object sender, EventArgs e)
        {
            if (this.txtMaCongViecNhanVien.Text.Trim().Length <= 0 || this.txtMaNhanVien.Text.Trim().Length <= 0 || this.dateTimeDuKienHoanThanhCVNV.Value > DateTime.Now || this.dateTimeNgayBatDauCVNV.Value > DateTime.Now || this.dateTimeNgayKetThucCVNV.Value > DateTime.Now)
            {
                if (this.txtMaCongViecNhanVien.Text.Trim().Length <= 0)
                {
                    this.errorProvider1.SetError(this.txtMaCongViecNhanVien, "Ma cong viec khong duoc trong");
                    return;
                }
                else if (this.txtMaNhanVien.Text.Trim().Length <= 0)
                {
                    this.errorProvider1.SetError(this.txtMaNhanVien, "Ma nhan vien khong duoc de trong");
                    return;
                }
                this.errorProvider1.Clear();
                if (this.txtTenCongViecNhanVien.Text.Trim().Length <= 0)
                {
                    this.errorProvider1.SetError(this.txtTenCongViecNhanVien, "nhap ten cong viec");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }
                if (this.txtMoTaCongViecNhanVien.Text.Trim().Length <= 0)
                {
                    this.errorProvider1.SetError(this.txtMoTaCongViecNhanVien, "nhap mo ta cong viec");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }
                if (this.txtLuongCongViec.Text.Trim().Length <= 0)
                {
                    this.errorProvider1.SetError(this.txtLuongCongViec, "nhap luong cong viec");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }
                if (this.dateTimeNgayBatDauCVNV.Value <= DateTime.Now)
                {
                    this.errorProvider1.SetError(this.dateTimeNgayBatDauCVNV, "nhap ngay bat dau");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }
                if (this.dateTimeDuKienHoanThanhCVNV.Value <= DateTime.Now)
                {
                    this.errorProvider1.SetError(this.dateTimeDuKienHoanThanhCVNV, "nhap ngay du kien hoan thanh");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }
            }
            CongViecNhanVien cv = new CongViecNhanVien();

            cv.MaCongViecNhanVien = txtMaCongViecNhanVien.Text.Trim();
            cv.TenCongViec        = txtTenCongViecNhanVien.Text.Trim();
            cv.MaNhanVienPhuTrach = txtMaNhanVien.Text.Trim();
            cv.MoTa            = txtMoTaCongViecNhanVien.Text.Trim();
            cv.LuongCongViec   = int.Parse(txtLuongCongViec.Text.Trim());
            cv.TaiLieu         = txtTaiLieu.Text.Trim();
            cv.NgayBatDau      = DateTime.Parse(dateTimeNgayBatDauCVNV.Value.ToString());
            cv.DuKienHoanThanh = DateTime.Parse(dateTimeDuKienHoanThanhCVNV.Value.ToString());
            cv.NgayHoanThanh   = DateTime.Parse(dateTimeNgayKetThucCVNV.Value.ToString());
            ChiPhi cp = new ChiPhi();

            cp.ChiPhiCongViec    = cv.LuongCongViec;
            cp.MaCongViecChiTieu = cv.MaCongViecNhanVien;
            cp.CongViecChiTieu   = cv.TenCongViec;
            cp.ThucHien          = DateTime.Parse(dateTimeNgayKetThucCVNV.Value.ToString());
            ChiPhiControllers.AddChiPhi(cp);
            CongViec congviec = CongViecControllers.getCongViecfromDB(lcv[(cbxListCongViecnv.SelectedIndex)].MaCongViec.Trim());

            if (congviec.NoiDungCongViec.Trim() == "" || congviec.NoiDungCongViec == null)
            {
                congviec.NoiDungCongViec = txtMaCongViecNhanVien.Text.Trim();
            }
            else
            {
                congviec.NoiDungCongViec = congviec.NoiDungCongViec.Trim() + "," + txtMaCongViecNhanVien.Text.Trim();
            }
            CongViecControllers.updateCongViec(congviec);

            CongViecNhanVienControllers.AddCongViecNhanVien(cv);
            BindingSource source = new BindingSource();

            source.DataSource = CongViecNhanVienControllers.getListCongViecNhanVienfromDB();
            this.dataGridViewCongViecDangThucHien.DataSource = source;
        }
Example #15
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;
            }
        }
        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);
        }