예제 #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 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);
                }
            }
        }
예제 #3
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);
                }
            }
        }
예제 #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;
        }
예제 #5
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;
        }
예제 #6
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;
        }