コード例 #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);
            }
        }
コード例 #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;
        }
コード例 #3
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;
        }
コード例 #4
0
        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;
        }
コード例 #5
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);
        }