Exemple #1
0
        public bool addData(TaskCreatingDTO taskCreatingDTO)
        {
            // Nếu khóa chính trống thì không thể thêm vào.
            if (taskCreatingDTO.ProjectID == string.Empty || taskCreatingDTO.Stage == string.Empty ||
                taskCreatingDTO.Task == string.Empty || taskCreatingDTO.Employee == null || taskCreatingDTO.StartDate == null || taskCreatingDTO.EndDate == null)
            {
                return(false);
            }

            string str_Query = string.Empty;

            if (taskCreatingDTO.Approver != null)
            {
                str_Query = "INSERT INTO TASKCREATING VALUES ('" + taskCreatingDTO.ProjectID + "' , '" + taskCreatingDTO.Stage + "', '"
                            + taskCreatingDTO.Task + "', '" + taskCreatingDTO.Employee + "', '" + taskCreatingDTO.TaskDescription + "', '"
                            + DateTime.Parse(taskCreatingDTO.StartDate).ToString("MM/dd/yyyy") + "', '" + DateTime.Parse(taskCreatingDTO.EndDate).ToString("MM/dd/yyyy")
                            + "', '" + taskCreatingDTO.TaskType + "', '" + taskCreatingDTO.Approver + "', '" + taskCreatingDTO.AttachFile + "', '"
                            + taskCreatingDTO.Progress + "', '" + taskCreatingDTO.Status + "', NULL, '" + taskCreatingDTO.TimeDelay + "', '"
                            + taskCreatingDTO.Color + "',  '" + taskCreatingDTO.Note + "')";
            }
            else if (taskCreatingDTO.Approver == null)
            {
                str_Query = "INSERT INTO TASKCREATING VALUES ('" + taskCreatingDTO.ProjectID + "' , '" + taskCreatingDTO.Stage + "', '"
                            + taskCreatingDTO.Task + "', '" + taskCreatingDTO.Employee + "', '" + taskCreatingDTO.TaskDescription + "', '"
                            + DateTime.Parse(taskCreatingDTO.StartDate).ToString("MM/dd/yyyy") + "', '" + DateTime.Parse(taskCreatingDTO.EndDate).ToString("MM/dd/yyyy")
                            + "', '" + taskCreatingDTO.TaskType + "', NULL, '" + taskCreatingDTO.AttachFile + "', '"
                            + taskCreatingDTO.Progress + "', '" + taskCreatingDTO.Status + "', NULL, '" + taskCreatingDTO.TimeDelay + "', '"
                            + taskCreatingDTO.Color + "',  '" + taskCreatingDTO.Note + "')";
            }

            int i_Result = DataProvider.Instance.ExecuteNonQuery(str_Query);

            return(i_Result > 0);
        }
Exemple #2
0
        public bool updateDataForTaskAssign(TaskCreatingDTO taskCreatingDTO)
        {
            // Nếu khóa chính trống thì không thể thêm vào.
            if (taskCreatingDTO.ProjectID == string.Empty || taskCreatingDTO.Stage == string.Empty ||
                taskCreatingDTO.Task == string.Empty || taskCreatingDTO.Employee == null || taskCreatingDTO.StartDate == null || taskCreatingDTO.EndDate == null)
            {
                return(false);
            }

            return(TaskCreatingDAO.Instance.updateDataForTaskAssign(taskCreatingDTO));
        }
Exemple #3
0
        // Gán dữ liệu.
        private void setData(TaskCreatingDTO taskCreatingDTO)
        {
            taskCreatingDTO.ProjectID = this.txtEdtProjectID.Text.Trim();
            taskCreatingDTO.Stage     = this.cbbStage.Text.Trim();
            taskCreatingDTO.Task      = this.rchTxtBxTask.Text.Trim();

            if (this.cbbEmployee.Text.Trim() == string.Empty)
            {
                taskCreatingDTO.Employee = null;
            }
            else
            {
                taskCreatingDTO.Employee = this.cbbEmployee.Text.Trim();
            }

            taskCreatingDTO.TaskDescription = this.rchTxtBxTaskDescription.Text.Trim();

            if (this.dtEdtStartDate.Text.Trim() == string.Empty)
            {
                taskCreatingDTO.StartDate = null;
            }
            else
            {
                taskCreatingDTO.StartDate = this.dtEdtStartDate.Text.Trim();
            }

            if (this.dtEdtEndDate.Text.Trim() == string.Empty)
            {
                taskCreatingDTO.EndDate = null;
            }
            else
            {
                taskCreatingDTO.EndDate = this.dtEdtEndDate.Text.Trim();
            }

            taskCreatingDTO.TaskType = this.cbbTaskType.Text.Trim();

            if (this.cbbApprover.Text.Trim() == "Admin" || this.cbbApprover.Text.Trim() == string.Empty)
            {
                taskCreatingDTO.Approver = null;
            }
            else
            {
                taskCreatingDTO.Approver = this.cbbApprover.Text.Trim();
            }

            taskCreatingDTO.AttachFile = this.cbbAttachFile.Text.Trim();

            taskCreatingDTO.Progress   = "0";
            taskCreatingDTO.Status     = StaticVarClass.status_NotComplete;
            taskCreatingDTO.FinishDate = null;
            taskCreatingDTO.TimeDelay  = "0";
            taskCreatingDTO.Note       = string.Empty;
        }
Exemple #4
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.
            }
        }
Exemple #5
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            TaskCreatingDTO taskCreatingDTOLocal = TaskCreatingBUS.Instance.getDataObjectFollowProjectIDAndStageAndTask(this.str_ProjectIDGlobal, this.str_StageGlobal, this.str_TaskGlobal);

            // Nếu nút comfirm đã đủ điều kiện.
            if (this.btnConfirm.Enabled == true)
            {
                // Biến lưu nếu không xác nhận thành công thì status mặc định lại ban đầu.
                string str_StatusTemp = this.txtEdtStatus.Text.Trim();

                if (taskCreatingDTOLocal.TaskType == StaticVarClass.type_Normal)
                {
                    this.txtEdtStatus.Text = StaticVarClass.status_Complete;
                }
                else if (taskCreatingDTOLocal.TaskType == StaticVarClass.type_AdminApproval)
                {
                    this.txtEdtStatus.Text = StaticVarClass.status_WaitForApproval;
                }

                // Cập nhật lại ngày hoàn thành và trạng thái của task.
                taskCreatingDTOLocal.FinishDate = DateTime.Now.Date.ToString();
                if (taskCreatingDTOLocal.FinishDate == string.Empty)
                {
                    taskCreatingDTOLocal.FinishDate = null;
                }

                taskCreatingDTOLocal.Status = this.txtEdtStatus.Text.Trim();

                // Cập nhật status của task.
                if (TaskCreatingBUS.Instance.updateDataForFormTaskDetail(taskCreatingDTOLocal.ProjectID, taskCreatingDTOLocal.Stage,
                                                                         taskCreatingDTOLocal.Task, taskCreatingDTOLocal.FinishDate, taskCreatingDTOLocal.Status))
                {
                    XtraMessageBox.Show("Successfully confirmed!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    // Đặt lại mặc định của các nút liên quan đến confirm.
                    this.resetConfirm();
                }
                else
                {
                    this.txtEdtStatus.Text = str_StatusTemp;

                    XtraMessageBox.Show("Confirm failed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemple #6
0
        //public List<TaskCreatingDTO> getDataList()
        //{
        //    string str_Query = ("SELECT * FROM TASKCREATING");

        //    DataTable dt_Data = DataProvider.Instance.ExecuteQuery(str_Query);

        //    if (dt_Data == null)
        //        return null;

        //    List<TaskCreatingDTO> lst_TaskCreatingListResult = new List<TaskCreatingDTO>();

        //    foreach (DataRow item in dt_Data.Rows)
        //    {
        //        TaskCreatingDTO taskCreatingDTO = new TaskCreatingDTO(item);
        //        lst_TaskCreatingListResult.Add(taskCreatingDTO);
        //    }

        //    return lst_TaskCreatingListResult;
        //}

        public List <TaskCreatingDTO> getDataListFollowProjectIDAndStageAndDept(string projectID, string stage, string dept)
        {
            string str_Query = ("SELECT * FROM TASKCREATING TC, EMPLOYEE EM WHERE TC.EMPLOYEE = EM.NAME AND TC.PROJECTID = '" + projectID + "' AND TC.STAGE = '" + stage + "' AND EM.DEPARTMENT = '" + dept + "'");

            DataTable dt_Data = DataProvider.Instance.ExecuteQuery(str_Query);

            if (dt_Data == null)
            {
                return(null);
            }

            List <TaskCreatingDTO> lst_TaskCreatingListResult = new List <TaskCreatingDTO>();

            foreach (DataRow item in dt_Data.Rows)
            {
                TaskCreatingDTO taskCreatingDTO = new TaskCreatingDTO(item);
                lst_TaskCreatingListResult.Add(taskCreatingDTO);
            }

            return(lst_TaskCreatingListResult);
        }
Exemple #7
0
        private void loadInformation()
        {
            if (this.str_ProjectIDGlobal == string.Empty || this.str_StageGlobal == string.Empty || this.str_TaskGlobal == string.Empty)
            {
                return;
            }

            // Chạy thông tin nhân viên được chọn.
            TaskCreatingDTO taskCreatingDTOLocal = TaskCreatingBUS.Instance.getDataObjectFollowProjectIDAndStageAndTask(this.str_ProjectIDGlobal, this.str_StageGlobal, str_TaskGlobal);

            this.txtEdtProjectID.Text = taskCreatingDTOLocal.ProjectID;

            this.txtEdtStage.Text = taskCreatingDTOLocal.Stage;

            this.rchTxtBxTask.Text = taskCreatingDTOLocal.Task;

            this.txtEdtEmployee.Text = taskCreatingDTOLocal.Employee;

            this.rchTxtBxTaskDescription.Text = taskCreatingDTOLocal.TaskDescription;

            this.txtEdtStartDate.Text = taskCreatingDTOLocal.StartDate;

            this.txtEdtEndDate.Text = taskCreatingDTOLocal.EndDate;

            this.txtEdtTaskType.Text = taskCreatingDTOLocal.TaskType;

            this.txtEdtApprover.Text = taskCreatingDTOLocal.Approver;

            this.txtEdtAttachFile.Text = taskCreatingDTOLocal.AttachFile;

            this.nmrUpDwnProgress.Text = taskCreatingDTOLocal.Progress;

            this.txtEdtStatus.Text = taskCreatingDTOLocal.Status;

            this.txtEdtFinishDate.Text = taskCreatingDTOLocal.FinishDate;

            this.txtEdtTimeDelay.Text = taskCreatingDTOLocal.TimeDelay;

            this.txtEdtNote.Text = taskCreatingDTOLocal.Note;
        }
Exemple #8
0
        public TaskCreatingDTO getDataObjectForUpdateWhenRemovingTask(string projectID, string stage)
        {
            string str_Query = ("SELECT * FROM TASKCREATING WHERE PROJECTID = '" + projectID + "' AND STAGE = '" + stage + "'");

            DataTable dt_Data = DataProvider.Instance.ExecuteQuery(str_Query);

            if (dt_Data == null)
            {
                return(null);
            }

            if (dt_Data.Rows.Count == 0)
            {
                TaskCreatingDTO taskCreatingDTOTemp = new TaskCreatingDTO();
                return(taskCreatingDTOTemp);
            }

            List <TaskCreatingDTO> lst_TaskCreatingListResult = new List <TaskCreatingDTO>();

            foreach (DataRow item in dt_Data.Rows)
            {
                TaskCreatingDTO taskCreatingDTO = new TaskCreatingDTO(item);
                lst_TaskCreatingListResult.Add(taskCreatingDTO);
            }

            TaskCreatingDTO taskCreatingDTOResult = new TaskCreatingDTO(lst_TaskCreatingListResult[0]);

            for (int i = 0; i < lst_TaskCreatingListResult.Count; i++)
            {
                if (lst_TaskCreatingListResult[i].Status != StaticVarClass.status_Complete)
                {
                    taskCreatingDTOResult = new TaskCreatingDTO(lst_TaskCreatingListResult[i]);
                    break;
                }
            }

            return(taskCreatingDTOResult);
        }
Exemple #9
0
        //public DataTable getDataFollowProjectIDAndStage(string projectID, string stage)
        //{
        //    string str_Query = ("SELECT * FROM TASKCREATING WHERE PROJECTID = '" + projectID + "' AND STAGE = '" + stage + "'");

        //    DataTable dt_Result = DataProvider.Instance.ExecuteQuery(str_Query);

        //    return dt_Result;
        //}

        //public DataTable getDataFollowProjectIDAndStageAndTask(string projectID, string stage, string task)
        //{
        //    string str_Query = ("SELECT * FROM TASKCREATING WHERE PROJECTID = '" + projectID + "' AND STAGE = '" + stage + "' AND TASK = '" + task + "'");

        //    DataTable dt_Result = DataProvider.Instance.ExecuteQuery(str_Query);

        //    return dt_Result;
        //}

        //public DataTable getDataForFormTaskDetail(string employee, string startDate, string endDate)
        //{
        //    string str_Query = ("SELECT * FROM TASKCREATING WHERE EMPLOYEE = '" + employee + "' AND STARTDATE >= '" + DateTime.Parse(startDate).ToString("MM/dd/yyyy") + "' AND ENDDATE <= '" + DateTime.Parse(endDate).ToString("MM/dd/yyyy") + "'");

        //    DataTable dt_Result = DataProvider.Instance.ExecuteQuery(str_Query);

        //    return dt_Result;
        //}

        public TaskCreatingDTO getDataObjectFollowProjectIDAndStageAndTask(string projectID, string stage, string task)
        {
            string str_Query = ("SELECT * FROM TASKCREATING WHERE PROJECTID = '" + projectID + "' AND STAGE = '" + stage + "' AND TASK = '" + task + "'");

            DataTable dt_Data = DataProvider.Instance.ExecuteQuery(str_Query);

            if (dt_Data == null)
            {
                return(null);
            }

            if (dt_Data.Rows.Count == 0)
            {
                TaskCreatingDTO taskCreatingDTOTemp = new TaskCreatingDTO();

                return(taskCreatingDTOTemp);
            }

            DataRow dtR_DataRow = dt_Data.Rows[0];

            TaskCreatingDTO taskCreatingDTOResult = new TaskCreatingDTO(dtR_DataRow);

            return(taskCreatingDTOResult);
        }
Exemple #10
0
        public bool updateDataForTaskAssign(TaskCreatingDTO taskCreatingDTO)
        {
            // Nếu khóa chính trống thì không thể thêm vào.
            if (taskCreatingDTO.ProjectID == string.Empty || taskCreatingDTO.Stage == string.Empty ||
                taskCreatingDTO.Task == string.Empty || taskCreatingDTO.Employee == null || taskCreatingDTO.StartDate == null || taskCreatingDTO.EndDate == null)
            {
                return(false);
            }

            string str_Query = string.Empty;

            if (taskCreatingDTO.Approver == null)
            {
                str_Query = "UPDATE TASKCREATING SET EMPLOYEE = '" + taskCreatingDTO.Employee + "', TASKDESCRIPTION = '"
                            + taskCreatingDTO.TaskDescription + "', STARTDATE = '" + DateTime.Parse(taskCreatingDTO.StartDate).ToString("MM/dd/yyyy") + "', ENDDATE = '"
                            + DateTime.Parse(taskCreatingDTO.EndDate).ToString("MM/dd/yyyy") + "', TASKTYPE = '" + taskCreatingDTO.TaskType + "', APPROVER = NULL, ATTACHFILE = '" + taskCreatingDTO.AttachFile + "', PROGRESS = '"
                            + taskCreatingDTO.Progress + "', STATUS = '" + taskCreatingDTO.Status + "', FINISHDATE = NULL, TIMEDELAY = '" + taskCreatingDTO.TimeDelay + "', COLOR = '"
                            + taskCreatingDTO.Color + "', NOTE = '" + taskCreatingDTO.Note + "' WHERE PROJECTID = '"
                            + taskCreatingDTO.ProjectID + "' AND STAGE = '"
                            + taskCreatingDTO.Stage + "' AND TASK = '" + taskCreatingDTO.Task + "'";
            }
            else
            {
                str_Query = "UPDATE TASKCREATING SET EMPLOYEE = '" + taskCreatingDTO.Employee + "', TASKDESCRIPTION = '"
                            + taskCreatingDTO.TaskDescription + "', STARTDATE = '" + DateTime.Parse(taskCreatingDTO.StartDate).ToString("MM/dd/yyyy") + "', ENDDATE = '"
                            + DateTime.Parse(taskCreatingDTO.EndDate).ToString("MM/dd/yyyy") + "', TASKTYPE = '" + taskCreatingDTO.TaskType + "', APPROVER = '" + taskCreatingDTO.Approver + "', ATTACHFILE = '" + taskCreatingDTO.AttachFile + "', PROGRESS = '"
                            + taskCreatingDTO.Progress + "', STATUS = '" + taskCreatingDTO.Status + "', FINISHDATE = NULL, TIMEDELAY = '" + taskCreatingDTO.TimeDelay + "', COLOR = '"
                            + taskCreatingDTO.Color + "', NOTE = '" + taskCreatingDTO.Note + "' WHERE PROJECTID = '"
                            + taskCreatingDTO.ProjectID + "' AND STAGE = '"
                            + taskCreatingDTO.Stage + "' AND TASK = '" + taskCreatingDTO.Task + "'";
            }

            int i_Result = DataProvider.Instance.ExecuteNonQuery(str_Query);

            return(i_Result > 0);
        }
Exemple #11
0
        //public TaskCreatingDTO getDataObjectFollowProjectID(string projectID)
        //{
        //    string str_Query = ("SELECT * FROM TASKCREATING WHERE PROJECTID = '" + projectID + "' ");

        //    DataTable dt_Data = DataProvider.Instance.ExecuteQuery(str_Query);

        //    if (dt_Data == null)
        //        return null;

        //    if (dt_Data.Rows.Count == 0)
        //    {
        //        TaskCreatingDTO taskCreatingDTOTemp = new TaskCreatingDTO();

        //        return taskCreatingDTOTemp;
        //    }

        //    DataRow dtR_DataRow = dt_Data.Rows[0];

        //    TaskCreatingDTO taskCreatingDTOResult = new TaskCreatingDTO(dtR_DataRow);

        //    return taskCreatingDTOResult;
        //}

        //public TaskCreatingDTO getDataObjectFollowAllPrimaryKeys(string projectID, string stage, string task)
        //{
        //    string str_Query = ("SELECT * FROM TASKCREATING WHERE PROJECTID = '" + projectID + "' AND STAGE = '" + stage + "' AND TASK = '" + task + "'");

        //    DataTable data = DataProvider.Instance.ExecuteQuery(str_Query);

        //    if (data == null)
        //        return null;

        //    DataRow dataRow = data.Rows[0];

        //    TaskCreatingDTO taskCreatingDTOResult = new TaskCreatingDTO(dataRow);

        //    return taskCreatingDTOResult;
        //}

        //public TaskCreatingDTO getDataObjectForQuickAccessTaskWorking(string employee, string projectID)
        //{
        //    string str_Query = ("SELECT * FROM TASKCREATING WHERE EMPLOYEE = '" + employee + "' AND PROJECTID = '" + projectID + "'");

        //    DataTable dt_Data = DataProvider.Instance.ExecuteQuery(str_Query);

        //    if (dt_Data == null)
        //        return null;

        //    if (dt_Data.Rows.Count == 0)
        //    {
        //        TaskCreatingDTO taskCreatingDTOTemp = new TaskCreatingDTO();

        //        return taskCreatingDTOTemp;
        //    }

        //    DataRow dtR_DataRow = dt_Data.Rows[0];

        //    TaskCreatingDTO taskCreatingDTOResult = new TaskCreatingDTO(dtR_DataRow);

        //    return taskCreatingDTOResult;
        //}

        //public TaskCreatingDTO findNextTask(string username, string projectID)
        //{
        //    TaskCreatingDTO taskCreatingDTOResult = null;

        //    List<TaskCreatingDTO> taskCreatingList = this.getDataListForNextStage(username, projectID);
        //    int i_Pos = -1;
        //    int i = 0;

        //    // Tìm task chưa hoàn thành của một người trong giai đoạn.
        //    for (i = 0; i < taskCreatingList.Count(); i++)
        //    {
        //        // Nếu dự án đầu tiên chưa làm xong.
        //        if (taskCreatingList[i].Status == StaticVarClass.status_NotComplete || taskCreatingList[i].Status == StaticVarClass.status_WaitForApproval || taskCreatingList[i].Status == StaticVarClass.status_Overdue || taskCreatingList[i].Status == StaticVarClass.status_Approver)
        //        {
        //            i_Pos = i;
        //            break;
        //        }
        //    }

        //    if (i_Pos != -1)
        //    {
        //        taskCreatingDTOResult = taskCreatingList[i_Pos];
        //    }

        //    return taskCreatingDTOResult;
        //}

        public TaskCreatingDTO getDataObjectForQuickAccessTaskWorking(string projectID, string stage, string employee)
        {
            string str_Query = ("SELECT * FROM TASKCREATING WHERE EMPLOYEE = '" + employee + "' AND PROJECTID = '" + projectID + "' AND STAGE = '" + stage + "' ORDER BY STARTDATE ASC");

            DataTable dt_Data = DataProvider.Instance.ExecuteQuery(str_Query);

            if (dt_Data == null)
            {
                return(null);
            }

            if (dt_Data.Rows.Count == 0) // Không có task nào.
            {
                TaskCreatingDTO taskCreatingDTOTemp = new TaskCreatingDTO();
                return(taskCreatingDTOTemp);
            }

            // Có task.
            List <TaskCreatingDTO> lst_TaskCreatingListLocal = new List <TaskCreatingDTO>();

            foreach (DataRow item in dt_Data.Rows)
            {
                TaskCreatingDTO taskCreatingDTO = new TaskCreatingDTO(item);
                lst_TaskCreatingListLocal.Add(taskCreatingDTO);
            }

            foreach (TaskCreatingDTO taskCreatingDTOTemp in lst_TaskCreatingListLocal)
            {
                if (taskCreatingDTOTemp.Status == StaticVarClass.status_NotComplete)
                {
                    return(taskCreatingDTOTemp);
                }
            }

            return(lst_TaskCreatingListLocal[lst_TaskCreatingListLocal.Count - 1]);
        }
Exemple #12
0
        // Xét quyền hạn của nhân viên.
        private void Authorize()
        {
            string          str_StatusCurrProjectLocal = ProjectBUS.Instance.getStringStatusFollowProjectID(this.str_ProjectIDGlobal);
            string          str_StatusCurrStageLocal   = StageBUS.Instance.getStringStatusFollowProjectIDAndStage(this.str_ProjectIDGlobal, this.str_StageGlobal);
            string          str_StatusBeforeStageLocal = StageBUS.Instance.getStringStatusFollowProjectIDAndStageBefore(this.str_ProjectIDGlobal, this.str_StageGlobal);
            string          str_StatusCurrTaskLocal    = TaskCreatingBUS.Instance.getStringStatusFollowAllPrimaryKeys(this.str_ProjectIDGlobal, this.str_StageGlobal, this.str_TaskGlobal);
            TaskCreatingDTO taskCreatingDTOLocal       = TaskCreatingBUS.Instance.getDataObjectFollowProjectIDAndStageAndTask(this.str_ProjectIDGlobal, this.str_StageGlobal, this.str_TaskGlobal);

            if (str_StatusCurrStageLocal == null || str_StatusBeforeStageLocal == null || str_StatusCurrTaskLocal == null || str_StatusCurrProjectLocal == null || taskCreatingDTOLocal == null)
            {
                XtraMessageBox.Show("Cannot connect to database!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (str_StatusCurrStageLocal == string.Empty || str_StatusCurrTaskLocal == string.Empty || str_StatusCurrProjectLocal == string.Empty || taskCreatingDTOLocal.Empty() == true)
            {
                XtraMessageBox.Show("Empty data!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            // Nếu project hiện tại đã hoàn thành.
            if (str_StatusCurrProjectLocal == StaticVarClass.status_Complete)
            {
                this.disableAll();
                b_IsBlockAll = true;
            }
            else
            {
                // Nếu stage của task đó hoàn thành rồi thì vào chỉ được xem.
                if (str_StatusCurrStageLocal == StaticVarClass.status_Complete)
                {
                    this.disableAll();
                    b_IsBlockAll = true;
                }
                else
                {
                    // Nếu status task hoàn thành thì chỉ được xem.
                    if (str_StatusCurrTaskLocal == StaticVarClass.status_Complete)
                    {
                        this.disableAll();
                        b_IsBlockAll = true;
                    }
                    else
                    {
                        // Nếu status stage trước đó không hoàn thành thì chỉ được xem.
                        if (str_StatusBeforeStageLocal == StaticVarClass.status_NotComplete)
                        {
                            this.disableAll();
                            b_IsBlockAll = true;
                        }

                        else
                        {
                            if (StaticVarClass.account_Username != this.str_EmployeeGlobal)
                            {
                                this.disableAll();
                                b_IsBlockAll = true;
                            }
                            else
                            {
                                string str_StartDateCurrTaskTemp = taskCreatingDTOLocal.StartDate;
                                if (DateTime.Now < DateTime.Parse(str_StartDateCurrTaskTemp))
                                {
                                    this.disableAll();
                                    b_IsBlockAll = true;
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #13
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);
        }
Exemple #14
0
        private void btnAssignTask_Click(object sender, EventArgs e)
        {
            this.str_EmployeeRecieveGlobal = this.cbbEmployee.Text.Trim();

            // Lấy ra một task creating.
            TaskCreatingDTO taskCreatingAssignDTOLocal = TaskCreatingBUS.Instance.getDataObjectFollowProjectIDAndStageAndTask(this.str_ProjectIDGlobal, this.str_StageGlobal, this.str_TaskGlobal);

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

            if (taskCreatingAssignDTOLocal.Empty())
            {
                XtraMessageBox.Show("Empty data!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            string str_ProjectIDLocal = this.str_ProjectIDGlobal;
            string str_StageLocal     = this.str_StageGlobal;
            string str_TaskLocal      = this.str_TaskGlobal;

            // Lấy ra một task assign.
            // Giờ đưa nhiệm vụ này vào bảng nhiệm vụ đã đẩy.
            TaskAssignDTO taskAssignDTO = new TaskAssignDTO(taskCreatingAssignDTOLocal);

            taskAssignDTO.Note += this.str_EmployeeAssignGlobal + " assigned task to " + this.str_EmployeeRecieveGlobal + "; ";

            if (TaskAssignDAO.Instance.addData(taskAssignDTO))
            {
                // Cập nhật thông tin cho người mới được nhận công việc của người cũ.
                if (taskCreatingAssignDTOLocal.Approver == string.Empty)
                {
                    taskCreatingAssignDTOLocal.Approver = null;
                }

                if (this.str_EmployeeRecieveGlobal == string.Empty)
                {
                    taskCreatingAssignDTOLocal.Employee = null;
                }
                else
                {
                    taskCreatingAssignDTOLocal.Employee = this.str_EmployeeRecieveGlobal;
                }

                if (this.dtEdtStartDate.Text.Trim() == string.Empty)
                {
                    taskCreatingAssignDTOLocal.StartDate = null;
                }
                else
                {
                    taskCreatingAssignDTOLocal.StartDate = this.dtEdtStartDate.Text.Trim();
                }

                if (this.dtEdtEndDate.Text.Trim() == string.Empty)
                {
                    taskCreatingAssignDTOLocal.EndDate = null;
                }
                else
                {
                    taskCreatingAssignDTOLocal.EndDate = this.dtEdtEndDate.Text.Trim();
                }

                taskCreatingAssignDTOLocal.Progress   = "0";
                taskCreatingAssignDTOLocal.Status     = StaticVarClass.status_NotComplete;
                taskCreatingAssignDTOLocal.FinishDate = null;
                taskCreatingAssignDTOLocal.TimeDelay  = "0";
                taskCreatingAssignDTOLocal.Note      += this.str_EmployeeRecieveGlobal + " recieved task from " + this.str_EmployeeAssignGlobal + "; ";

                if (TaskCreatingBUS.Instance.updateDataForTaskAssign(taskCreatingAssignDTOLocal))
                {
                    #region Cập nhật lịch sử.
                    string name   = StaticVarClass.account_Username;
                    string time   = DateTime.Now.ToString();
                    string action = "Assign project - stage - task: " + str_ProjectIDLocal + " - " + str_StageLocal + " - " + str_TaskLocal + " to employee " + str_EmployeeRecieveGlobal;
                    string status = "Successful";

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

                    XtraMessageBox.Show("Successfully assigned project - stage - task: " + str_ProjectIDLocal + " - " + str_StageLocal + " - " + str_TaskLocal + " to employee " + str_EmployeeRecieveGlobal + "!", "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 = "Assign project - stage - task: " + str_ProjectIDLocal + " - " + str_StageLocal + " - " + str_TaskLocal + " to employee " + str_EmployeeRecieveGlobal;
                    string status = "Failed";

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

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

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

                XtraMessageBox.Show("Assign project - stage - task: " + str_ProjectIDLocal + " - " + str_StageLocal + " - " + str_TaskLocal + " to employee " + str_EmployeeRecieveGlobal + " failed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #15
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            // Lưu thông tin của task mới vào bảng TASK.
            string str_ProjectIDLocal = this.txtEdtProjectID.Text.Trim();
            string str_StageLocal     = this.txtEdtStage.Text.Trim();
            string str_TaskLocal      = this.rchTxtBxTask.Text.Trim();

            string str_EmployeeLocal = string.Empty;

            if (this.cbbEmployee.Text.Trim() == string.Empty)
            {
                str_EmployeeLocal = null;
            }
            else
            {
                str_EmployeeLocal = this.cbbEmployee.Text.Trim();
            }

            string str_TaskDescriptionLocal = this.rchTxtBxTaskDescription.Text.Trim();

            string str_StartDateLocal = string.Empty;

            if (this.dtEdtStartDate.Text.Trim() == string.Empty)
            {
                str_StartDateLocal = null;
            }
            else
            {
                str_StartDateLocal = this.dtEdtStartDate.Text.Trim();
            }

            string str_EndDateLocal = string.Empty;

            if (this.dtEdtEndDate.Text.Trim() == string.Empty)
            {
                str_EndDateLocal = null;
            }
            else
            {
                str_EndDateLocal = this.dtEdtEndDate.Text.Trim();
            }

            string str_TaskTypeLocal = this.cbbTaskType.Text.Trim();

            string str_ApproverLocal = string.Empty;

            if (this.cbbApprover.Text.Trim() == string.Empty)
            {
                str_ApproverLocal = null;
            }
            else
            {
                str_ApproverLocal = this.cbbApprover.Text.Trim();
            }

            string str_AttachFileLocal = this.cbbAttachFile.Text.Trim();
            string str_ProgressLocal   = "0";
            string str_StatusLocal     = StaticVarClass.status_NotComplete;
            string str_FinishDateLocal = null;
            string str_TimeDelayLocal  = "0";
            string str_ColorLocal      = "Gray";
            string str_NoteLocal       = string.Empty;

            TaskCreatingDTO taskCreatingDTOTemp = new TaskCreatingDTO(str_ProjectIDLocal, str_StageLocal, str_TaskLocal, str_EmployeeLocal,
                                                                      str_TaskDescriptionLocal, str_StartDateLocal, str_EndDateLocal, str_TaskTypeLocal, str_ApproverLocal, str_AttachFileLocal, str_ProgressLocal,
                                                                      str_StatusLocal, str_FinishDateLocal, str_TimeDelayLocal, str_ColorLocal, str_NoteLocal);

            if (TaskCreatingBUS.Instance.addData(taskCreatingDTOTemp))
            {
                #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

                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);
            }
        }