Exemplo n.º 1
0
        private void checkEnableEdit(string projectID)
        {
            DataTable  dtLocal         = TaskCreatingDAO.Instance.getDataFollowProjectID(projectID);
            ProjectDTO projectDTOLocal = ProjectBUS.Instance.getDataObjectFollowProjectID(projectID);

            if (projectDTOLocal == null)
            {
                XtraMessageBox.Show("Cannot connect to database!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.btnSave.Enabled = false;
                return;
            }

            if (projectDTOLocal.Empty())
            {
                XtraMessageBox.Show("Empty data!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.btnSave.Enabled = false;
                return;
            }

            if (projectDTOLocal.Status == StaticVarClass.status_Complete)
            {
                this.btnSave.Enabled = false;
                return;
            }

            if (DateTime.Parse(projectDTOLocal.StartDate) > DateTime.Now)
            {
                //
                this.dtEdtStartDate.ReadOnly = false;
                this.dtEdtEndDate.ReadOnly   = false;
            }

            // not complete or overdue
            this.cbbProjectType.Enabled = true;
            foreach (DataRow dtR in dtLocal.Rows)
            {
                TaskCreatingDTO taskCreatingDTOTemp = new TaskCreatingDTO(dtR);
                if (taskCreatingDTOTemp.Status != StaticVarClass.status_NotComplete && taskCreatingDTOTemp.Status != StaticVarClass.status_Overdue)
                {
                    this.cbbProjectType.Enabled = false;
                    break;
                }
            }

            if (projectDTOLocal.Status != StaticVarClass.status_Complete)
            {
                // always
                this.txtEdtProjectID.ReadOnly   = false;
                this.txtEdtProjectName.ReadOnly = false;
                this.cbbLeader.Enabled          = true;
                this.cbbPOSMProject.Enabled     = true;
                this.dtEdtEndDate.ReadOnly      = false; // Mở end date để gia hạn.
            }
        }
Exemplo n.º 2
0
        private void loadDate()
        {
            string     str_ProjectID   = this.txtEdtProjectID.Text.Trim();
            ProjectDTO projectDTOLocal = ProjectDAO.Instance.getDataObjectFollowProjectID(str_ProjectID);

            if (projectDTOLocal == null)
            {
                XtraMessageBox.Show("Cannot connect to database!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (projectDTOLocal.Empty())
            {
                return;
            }

            this.dtEdtStartDate.DateTime = DateTime.Parse(projectDTOLocal.StartDate);
            this.dtEdtEndDate.DateTime   = DateTime.Parse(projectDTOLocal.StartDate).AddDays(1);
        }
Exemplo n.º 3
0
        private void dtEdtEndDate_Leave(object sender, EventArgs e)
        {
            string     str_ProjectID   = this.txtEdtProjectID.Text.Trim();
            ProjectDTO projectDTOLocal = ProjectDAO.Instance.getDataObjectFollowProjectID(str_ProjectID);

            if (projectDTOLocal == null)
            {
                XtraMessageBox.Show("Cannot connect to database!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (projectDTOLocal.Empty())
            {
                return;
            }

            if ((this.dtEdtEndDate.DateTime > DateTime.Parse(projectDTOLocal.EndDate)) ||
                (this.dtEdtEndDate.DateTime <= this.dtEdtStartDate.DateTime))
            {
                XtraMessageBox.Show("Invalid end date!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.dtEdtEndDate.DateTime = DateTime.Parse(projectDTOLocal.EndDate);
            }
        }
Exemplo n.º 4
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            TaskCreatingDTO taskCreatingDTOLocal = new TaskCreatingDTO();

            string str_ProjectIDLocal = this.txtEdtProjectID.Text.Trim();
            string str_StageLocal     = this.cbbStage.Text.Trim();
            string str_TaskLocal      = this.rchTxtBxTask.Text.Trim();
            string str_EmployeeLocal  = this.cbbEmployee.Text.Trim();

            if (str_TaskLocal == string.Empty)
            {
                str_TaskLocal = null;
            }

            // Gán giá trị vào thuộc tính trong bảng.
            this.setData(taskCreatingDTOLocal);

            #region Kiểm tra start date.
            string     str_ProjectID   = this.txtEdtProjectID.Text.Trim();
            ProjectDTO projectDTOLocal = ProjectDAO.Instance.getDataObjectFollowProjectID(str_ProjectID);

            if (projectDTOLocal == null)
            {
                XtraMessageBox.Show("Cannot connect to database!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (projectDTOLocal.Empty())
            {
                return;
            }

            if ((DateTime.Parse(taskCreatingDTOLocal.StartDate) < DateTime.Parse(projectDTOLocal.StartDate)) ||
                (DateTime.Parse(taskCreatingDTOLocal.StartDate) >= (DateTime.Parse(taskCreatingDTOLocal.EndDate))))
            {
                XtraMessageBox.Show("Invalid start date!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.dtEdtStartDate.DateTime = DateTime.Parse(projectDTOLocal.StartDate);
                return;
            }
            #endregion

            #region Kiểm tra end date.
            if ((DateTime.Parse(taskCreatingDTOLocal.EndDate) > DateTime.Parse(projectDTOLocal.EndDate)) ||
                (DateTime.Parse(taskCreatingDTOLocal.EndDate) <= (DateTime.Parse(taskCreatingDTOLocal.StartDate))))
            {
                XtraMessageBox.Show("Invalid end date!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.dtEdtEndDate.DateTime = DateTime.Parse(projectDTOLocal.EndDate);
                return;
            }
            #endregion

            #region Thêm.

            // Thêm mới.
            if (TaskCreatingDAO.Instance.addData(taskCreatingDTOLocal))
            {
                #region Cập nhật lịch sử.
                string name   = StaticVarClass.account_Username;
                string time   = DateTime.Now.ToString();
                string action = "Add project - stage - task: " + str_ProjectIDLocal + " - " + str_StageLocal + " - " + str_TaskLocal + " for employee " + str_EmployeeLocal;
                string status = "Successful";

                HistoryDTO hisDTO = new HistoryDTO(name, time, action, status);
                HistoryDAO.Instance.addData(hisDTO);
                #endregion

                this.btnDone.Enabled = true;

                XtraMessageBox.Show("Successfully added project - stage - task: " + str_ProjectIDLocal + " - " + str_StageLocal + " - " + str_TaskLocal + " for employee " + str_EmployeeLocal + "!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                #region Cập nhật lịch sử.
                string name   = StaticVarClass.account_Username;
                string time   = DateTime.Now.ToString();
                string action = "Add project - stage - task: " + str_ProjectIDLocal + " - " + str_StageLocal + " - " + str_TaskLocal + " for employee " + str_EmployeeLocal;
                string status = "Failed";

                HistoryDTO hisDTO = new HistoryDTO(name, time, action, status);
                HistoryDAO.Instance.addData(hisDTO);
                #endregion

                XtraMessageBox.Show("Add project - stage - task: " + str_ProjectIDLocal + " - " + str_StageLocal + " - " + str_TaskLocal + " for employee " + str_EmployeeLocal + " failed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }
            #endregion

            this.formCreatingTask_Load(null, null);
        }
Exemplo n.º 5
0
        private void btnRemove_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            System.Data.DataRow dtR_RowLocal = grvProject.GetDataRow(grvProject.FocusedRowHandle);
            string str_ProjectIDLocal        = dtR_RowLocal[0].ToString().Trim();

            #region Nếu project đã hoàn thành thì ko xoá đc.
            ProjectDTO projectDTOLocal = ProjectBUS.Instance.getDataObjectFollowProjectID(str_ProjectIDLocal);

            if (projectDTOLocal == null)
            {
                XtraMessageBox.Show("Cannot connect to database!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (projectDTOLocal.Empty())
            {
                return;
            }

            if (projectDTOLocal.Status == StaticVarClass.status_Complete)
            {
                XtraMessageBox.Show("Cannot remove project because project " + str_ProjectIDLocal + " has been completed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            #endregion

            List <string> lst_ListQuatityLocal = ProjectBUS.Instance.getListQuantityRelatedToRemovingProject(str_ProjectIDLocal);

            if (lst_ListQuatityLocal == null)
            {
                XtraMessageBox.Show("Cannot connect to database!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (lst_ListQuatityLocal.Count == 0)
            {
                return;
            }

            // Hộp thoại xác nhận khi nhấn nút xóa.
            DialogResult dr = XtraMessageBox.Show("Warning: There are " + lst_ListQuatityLocal[0] + " stages, " + lst_ListQuatityLocal[1] + " tasks in project " + str_ProjectIDLocal + ". \nAre you sure you want to remove?", "Confirm remove", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dr == DialogResult.Yes)
            {
                // Xóa.
                if (ProjectBUS.Instance.deleteData(str_ProjectIDLocal))
                {
                    #region Cập nhật lịch sử.
                    string name   = StaticVarClass.account_Username;
                    string time   = DateTime.Now.ToString();
                    string action = "Remove project " + str_ProjectIDLocal;
                    string status = "Successful";

                    HistoryDTO hisDTO = new HistoryDTO(name, time, action, status);
                    HistoryDAO.Instance.addData(hisDTO);
                    #endregion

                    XtraMessageBox.Show("Successfully removed project " + str_ProjectIDLocal + "!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    #region Cập nhật lịch sử.
                    string name   = StaticVarClass.account_Username;
                    string time   = DateTime.Now.ToString();
                    string action = "Remove project " + str_ProjectIDLocal;
                    string status = "Failed";

                    HistoryDTO hisDTO = new HistoryDTO(name, time, action, status);
                    HistoryDAO.Instance.addData(hisDTO);
                    #endregion

                    XtraMessageBox.Show("Remove project " + str_ProjectIDLocal + " failed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    return;
                }
            }
            else
            {
                return;
            }

            formProject_Load(sender, e);
        }
Exemplo n.º 6
0
        private void setValue(string projectID)
        {
            ProjectDTO projectDTOLocal  = ProjectBUS.Instance.getDataObjectFollowProjectID(projectID);
            int        i_Number1Local   = ProjectBUS.Instance.getIntNumberOfProjectType1FollowProjectID(projectID);
            int        i_Number2Local   = ProjectBUS.Instance.getIntNumberOfProjectType2FollowProjectID(projectID);
            int        i_Number5Local   = 0;
            int        i_Number345Local = ProjectBUS.Instance.getIntNumberOfProjectType345FollowProjectID(projectID);

            if (projectDTOLocal == null || i_Number1Local == -1 || i_Number2Local == -1 || i_Number345Local == -1)
            {
                XtraMessageBox.Show("Cannot connect to database!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.btnCancel_Click(null, null);
            }

            if (projectDTOLocal.Empty())
            {
                return;
            }



            #region Set value các ô.
            //this.cbbProjectID.Text = projectDTOLocal.ProjectID;
            this.nmrUpDwnDateRepeat.Value = Decimal.Parse(projectDTOLocal.DateRepeat);

            if (projectDTOLocal.AutoRepeat == "0")
            {
                this.chkBxAutoRepeat.CheckState = CheckState.Unchecked;
            }
            else
            {
                this.chkBxAutoRepeat.CheckState = CheckState.Checked;
            }

            if (projectDTOLocal.StartDateRepeat != string.Empty && projectDTOLocal.EndDateRepeat != string.Empty)
            {
                this.dtEdtStartDate.DateTime = DateTime.Parse(projectDTOLocal.StartDateRepeat);
                this.dtEdtEndDate.DateTime   = DateTime.Parse(projectDTOLocal.EndDateRepeat);
            }
            else if (projectDTOLocal.StartDateRepeat == string.Empty && projectDTOLocal.EndDateRepeat == string.Empty)
            {
                this.dtEdtStartDate.EditValue = null;
                this.dtEdtEndDate.EditValue   = null;
            }
            #endregion

            #region Nếu 4 thuộc tính ở giá trị mặc định.
            if (projectDTOLocal.DateRepeat == "0" && projectDTOLocal.AutoRepeat == "0" && projectDTOLocal.StartDateRepeat == string.Empty &&
                projectDTOLocal.EndDateRepeat == string.Empty)
            {
                this.nmrUpDwnDateRepeat.Enabled = true;
                this.chkBxAutoRepeat.Enabled    = false;

                if (i_Number1Local == 1 || i_Number2Local > 0) // Nếu đã tạo dự án 1 hay 2 thì khóa Date Repeat và AutoRepeat.
                {
                    this.chkBxAutoRepeat.Enabled    = false;
                    this.nmrUpDwnDateRepeat.Enabled = false;
                }
                else if (i_Number345Local > 0) // Nếu đã tạo dự án 3 hay 4 hay 5 thì khóa Date Repeat và AutoRepeat.
                {
                    this.chkBxAutoRepeat.Enabled    = false;
                    this.nmrUpDwnDateRepeat.Enabled = false;
                }
            }
            #endregion

            #region Nếu chưa tạo dự án 1 thì chỉnh sửa tùy ý Date Repeat + Auto Repeat + Start Date Repeat + End Date Repeat.
            if (projectDTOLocal.DateRepeat != "0" && projectDTOLocal.AutoRepeat == "0" && projectDTOLocal.StartDateRepeat == string.Empty &&
                projectDTOLocal.EndDateRepeat == string.Empty)
            {
                this.nmrUpDwnDateRepeat.Enabled = true;
                this.chkBxAutoRepeat.Enabled    = true;
            }
            #endregion

            #region Nếu đang tạo dự án 2.
            if (projectDTOLocal.DateRepeat != "0" && projectDTOLocal.AutoRepeat == "1" && projectDTOLocal.StartDateRepeat == string.Empty &&
                projectDTOLocal.EndDateRepeat == string.Empty)
            {
                if (i_Number2Local > 0)
                {
                    this.chkBxAutoRepeat.Enabled = false;
                }
                else if (i_Number2Local == 0)
                {
                    this.chkBxAutoRepeat.Enabled = true;
                }

                this.nmrUpDwnDateRepeat.Enabled = true;
            }
            #endregion

            #region Nếu chưa tạo dự án 3.
            if (projectDTOLocal.DateRepeat == "0" && projectDTOLocal.AutoRepeat == "0" && projectDTOLocal.StartDateRepeat != string.Empty &&
                projectDTOLocal.EndDateRepeat != string.Empty)
            {
                this.nmrUpDwnDateRepeat.Enabled = true;
                this.chkBxAutoRepeat.Enabled    = false;
            }
            #endregion

            #region Nếu chưa tạo dự án 4 HAY đã tạo 1 dự án 4 và đang chờ tạo 1 dự án 4 nữa.
            if (projectDTOLocal.DateRepeat != "0" && projectDTOLocal.AutoRepeat == "0" && projectDTOLocal.StartDateRepeat != string.Empty &&
                projectDTOLocal.EndDateRepeat != string.Empty)
            {
                this.nmrUpDwnDateRepeat.Enabled = true;
                this.chkBxAutoRepeat.Enabled    = true;
            }
            #endregion

            #region Nếu chưa tạo dự án 5.
            if (projectDTOLocal.DateRepeat != "0" && projectDTOLocal.AutoRepeat == "1" && projectDTOLocal.StartDateRepeat != string.Empty &&
                projectDTOLocal.EndDateRepeat != string.Empty)
            {
                i_Number5Local = ProjectBUS.Instance.getIntNumberOfProjectType5FollowProjectIDAndStartDate(projectDTOLocal.ProjectID,
                                                                                                           projectDTOLocal.StartDateRepeat);

                if (i_Number5Local <= 1)
                {
                    this.chkBxAutoRepeat.Enabled = true;
                }
                else if (i_Number5Local > 1)
                {
                    this.chkBxAutoRepeat.Enabled = false;
                }

                this.nmrUpDwnDateRepeat.Enabled = true;
            }
            #endregion

            #region Xử lí đây có phải là dự án lặp lại ko.
            int i_IsRepeatedProjectLocal = ProjectBUS.Instance.getIntConfirmRepeatedProject(projectID);

            if (i_IsRepeatedProjectLocal == -1)
            {
                XtraMessageBox.Show("Cannot connect to database!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.nmrUpDwnDateRepeat.Enabled = false;
                this.chkBxAutoRepeat.Enabled    = false;
                this.dtEdtStartDate.ReadOnly    = true;
                this.dtEdtEndDate.ReadOnly      = true;

                this.btnStop.Enabled  = false;
                this.btnStart.Enabled = false;
                return;
            }

            if (i_IsRepeatedProjectLocal == 1)
            {
                this.nmrUpDwnDateRepeat.Enabled = false;
                this.chkBxAutoRepeat.Enabled    = false;
                this.dtEdtStartDate.ReadOnly    = true;
                this.dtEdtEndDate.ReadOnly      = true;

                this.btnStop.Enabled  = true;
                this.btnStart.Enabled = false;
            }
            else
            {
                this.dtEdtStartDate.ReadOnly = false;
                this.dtEdtEndDate.ReadOnly   = false;
                this.btnStop.Enabled         = false;
                this.btnStart.Enabled        = true;
            }
            #endregion
        }
Exemplo n.º 7
0
        private void dtEdtEndDate_EditValueChanged(object sender, EventArgs e)
        {
            string str_ProjectIDLocal = this.cbbProjectID.Text.Trim();

            int        i_Number1Local   = ProjectBUS.Instance.getIntNumberOfProjectType1FollowProjectID(str_ProjectIDLocal);
            int        i_Number2Local   = ProjectBUS.Instance.getIntNumberOfProjectType2FollowProjectID(str_ProjectIDLocal);
            int        i_Number345Local = ProjectBUS.Instance.getIntNumberOfProjectType345FollowProjectID(str_ProjectIDLocal);
            ProjectDTO projectDTOLocal  = ProjectBUS.Instance.getDataObjectFollowProjectID(str_ProjectIDLocal);

            if (projectDTOLocal == null || i_Number1Local == -1 || i_Number2Local == -1 || i_Number345Local == -1)
            {
                XtraMessageBox.Show("Cannot connect to database!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (projectDTOLocal.Empty())
            {
                return;
            }

            #region Nếu 4 thuộc tính ở giá trị mặc định.
            if (projectDTOLocal.DateRepeat == "0" && projectDTOLocal.AutoRepeat == "0" && projectDTOLocal.StartDateRepeat == string.Empty &&
                projectDTOLocal.EndDateRepeat == string.Empty)
            {
                this.nmrUpDwnDateRepeat.Enabled = true;
                this.chkBxAutoRepeat.Enabled    = false;

                if (i_Number1Local == 1 || i_Number2Local > 0) // Nếu đã tạo dự án 1 hay 2 thì khóa Date Repeat và AutoRepeat.
                {
                    if (dtEdtStartDate.Text == string.Empty)
                    {
                        this.nmrUpDwnDateRepeat.Value = 0;
                        chkBxAutoRepeat.Checked       = false;

                        this.nmrUpDwnDateRepeat.Enabled = false;
                        this.chkBxAutoRepeat.Enabled    = false;
                    }
                    else
                    {
                        this.nmrUpDwnDateRepeat.Enabled = true;
                    }
                }
                else if (i_Number345Local > 0) // Nếu đã tạo dự án 3 hay 4 hay 5 thì khóa Date Repeat và AutoRepeat.
                {
                    if (dtEdtStartDate.Text == string.Empty)
                    {
                        this.nmrUpDwnDateRepeat.Value = 0;
                        chkBxAutoRepeat.Checked       = false;

                        this.nmrUpDwnDateRepeat.Enabled = false;
                        this.chkBxAutoRepeat.Enabled    = false;
                    }
                    else
                    {
                        this.nmrUpDwnDateRepeat.Enabled = true;
                    }
                }
            }
            #endregion

            if (dtEdtEndDate.Text != string.Empty)
            {
                int i_StartDateEndDateTemp = 0;
                i_StartDateEndDateTemp = DateTime.Parse(projectDTOLocal.EndDate).Subtract(DateTime.Parse(projectDTOLocal.StartDate)).Days;

                TimeSpan difference = new TimeSpan(i_StartDateEndDateTemp, 0, 0, 0);
                dtEdtStartDate.DateTime = dtEdtEndDate.DateTime.Subtract(difference);
            }
            else
            {
                dtEdtStartDate.EditValue = null;
            }
        }