Пример #1
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);
                }
            }
        }
Пример #2
0
        public void display()
        {
            this.clMaDuAn.DataPropertyName          = nameof(DuAn.MaDuAn);
            this.clTenDuAn.DataPropertyName         = nameof(DuAn.TenDuAn);
            this.clMucTieuDuAn.DataPropertyName     = nameof(DuAn.MucTieuDuAn);
            this.clChiPhiDuAn.DataPropertyName      = nameof(DuAn.ChiPhiDuAn);
            this.clCongViecDuAn.DataPropertyName    = nameof(DuAn.CongViecDuAn);
            this.clNhomPhuTrach.DataPropertyName    = nameof(DuAn.NhomPhuTrach);
            this.clDuKienHoanThanh.DataPropertyName = nameof(DuAn.DuKienHoanThanh);
            this.clNgayBatDau.DataPropertyName      = nameof(DuAn.NgayBatDau);
            this.clTienDo.DataPropertyName          = nameof(DuAn.TienDo);
            this.clNgayHoanThanh.DataPropertyName   = nameof(DuAn.NgayHoanThanh);

            List <DuAn>   lstDuAn = DuAnControllers.getListDuAnfromDB();
            BindingSource src     = new BindingSource();

            src.DataSource = lstDuAn;
            dataGridViewDuAn.DataSource          = src;
            dataGridViewDuAn.Columns[10].Visible = false;
            dataGridViewDuAn.Columns[11].Visible = false;
            dataGridViewDuAn.Columns[4].Visible  = false;
            dataGridViewDuAn.Columns[5].Visible  = false;
            if (qh == 0)
            {
                btnThemDuAn.Visible = false;
                btnSuaDuAn.Visible  = false;
            }
            dataGridViewDuAn.Columns[10].Visible = false;
            dataGridViewDuAn.Columns[11].Visible = false;
        }
Пример #3
0
        private void btnThemDuAn_Click(object sender, EventArgs e)
        {
            if (this.txtTenDuAn.Text.Trim().Length <= 0 || this.txtMaDuAn.Text.Trim().Length <= 0 || this.dateNgayDuKienHoanThanh.Value > DateTime.Now || this.dateTimeBatDauDuAn.Value > DateTime.Now || this.dateNgayDuKienHoanThanh.Value > DateTime.Now)
            {
                if (this.txtMaDuAn.Text.Trim().Length <= 0)
                {
                    this.errorProvider1.SetError(this.txtMaDuAn, "Ma du an khong duoc trong");
                    return;
                }
                else if (DuAnControllers.getMaDuAnfromDB(this.txtMaDuAn.Text.Trim()) != null)
                {
                    this.errorProvider1.SetError(this.txtMaDuAn, "Ma du an da ton tai");
                    return;
                }
                this.errorProvider1.Clear();
                if (this.txtTenDuAn.Text.Trim().Length <= 0)
                {
                    this.errorProvider1.SetError(this.txtTenDuAn, "nhap ten du an");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }
                if (this.dateTimeBatDauDuAn.Value <= DateTime.Now)
                {
                    this.errorProvider1.SetError(this.dateTimeBatDauDuAn, "nhap ngay bat dau");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }
                if (this.dateNgayDuKienHoanThanh.Value <= DateTime.Now)
                {
                    this.errorProvider1.SetError(this.dateNgayDuKienHoanThanh, "nhap ngay du kien hoan thanh");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }
            }
            DuAn da = new DuAn();

            da.MaDuAn          = txtMaDuAn.Text.Trim();
            da.TenDuAn         = txtTenDuAn.Text.Trim();
            da.NgayBatDau      = DateTime.Parse(dateTimeBatDauDuAn.Value.ToString());
            da.DuKienHoanThanh = DateTime.Parse(dateNgayDuKienHoanThanh.Value.ToString());
            da.MucTieuDuAn     = rtxtMucTieu.Text.Trim();
            da.TienDo          = 0;
            da.NgayHoanThanh   = DateTime.Parse("01/01/2000 12:00:00 AM");


            DuAnControllers.AddDuAn(da);
            BindingSource source = new BindingSource();

            source.DataSource = DuAnControllers.getListDuAnfromDB();
            this.dataGridViewDuAn.DataSource = source;
        }
Пример #4
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);
                }
            }
        }
Пример #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);
                }
            }
        }
Пример #6
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;
        }
Пример #7
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;
        }
Пример #8
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;
        }
Пример #9
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;
            }
        }
Пример #10
0
        private void btnSuaDuAn_Click(object sender, EventArgs e)
        {
            if (this.txtTenDuAn.Text.Trim().Length <= 0 || this.txtMaDuAn.Text.Trim().Length <= 0 || this.dateNgayDuKienHoanThanh.Value > DateTime.Now || this.dateTimeBatDauDuAn.Value > DateTime.Now || this.dateNgayDuKienHoanThanh.Value > DateTime.Now)
            {
                if (this.txtMaDuAn.Text.Trim().Length <= 0)
                {
                    this.errorProvider1.SetError(this.txtMaDuAn, "Ma du an khong duoc trong");
                    return;
                }
                this.errorProvider1.Clear();
                if (this.txtTenDuAn.Text.Trim().Length <= 0)
                {
                    this.errorProvider1.SetError(this.txtTenDuAn, "nhap ten du an");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }
                if (this.dateTimeBatDauDuAn.Value <= DateTime.Now)
                {
                    this.errorProvider1.SetError(this.dateTimeBatDauDuAn, "nhap ngay bat dau");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }
                if (this.dateNgayDuKienHoanThanh.Value <= DateTime.Now)
                {
                    this.errorProvider1.SetError(this.dateNgayDuKienHoanThanh, "nhap ngay du kien hoan thanh");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }
            }
            DuAn da = new DuAn();

            da.MaDuAn          = txtMaDuAn.Text.Trim();
            da.TenDuAn         = txtTenDuAn.Text.Trim();
            da.NgayBatDau      = DateTime.Parse(dateTimeBatDauDuAn.Value.ToString());
            da.DuKienHoanThanh = DateTime.Parse(dateNgayDuKienHoanThanh.Value.ToString());
            da.MucTieuDuAn     = rtxtMucTieu.Text.Trim();
            var lsda = DuAnControllers.getListDuAnfromDB();

            da.TienDo        = lsda[dataGridViewDuAn.CurrentRow.Index].TienDo;
            da.ChiPhiDuAn    = Int32.Parse(txtChiPhiDuAn.Text.Trim());
            da.NhomPhuTrach  = lsda[dataGridViewDuAn.CurrentRow.Index].NhomPhuTrach;
            da.CongViec      = lsda[dataGridViewDuAn.CurrentRow.Index].CongViec;
            da.NgayHoanThanh = lsda[dataGridViewDuAn.CurrentRow.Index].NgayHoanThanh;
            da.CongViecDuAn  = lsda[dataGridViewDuAn.CurrentRow.Index].CongViecDuAn;
            da.Nhom          = lsda[dataGridViewDuAn.CurrentRow.Index].Nhom;

            DuAnControllers.updateDA(da);
            BindingSource source = new BindingSource();

            source.DataSource = DuAnControllers.getListDuAnfromDB();
            this.dataGridViewDuAn.DataSource = source;
        }
Пример #11
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;
            }
        }