Esempio n. 1
0
        public async Task <IActionResult> Post([FromForm] GameDTO game)
        {
            try
            {
                GameProcessor processor  = new GameProcessor(game);
                GameResult    gameResult = processor.Process();

                HistoryDTO historyDTO = new HistoryDTO
                {
                    GameResultType      = gameResult.GameResultType,
                    FirstPlayerName     = game.FirstPlayerName,
                    FirstPlayerElement  = game.FirstPlayerElement,
                    SecondPlayerName    = game.SecondPlayerName,
                    SecondPlayerElement = game.SecondPlayerElement
                };

                await historyService.AddAsync(historyMapper.ToEntity(historyDTO));

                return(Ok(gameResult));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
Esempio n. 2
0
        public void Update(HistoryDTO historyDTO)
        {
            History history = Mapper.Map <History>(historyDTO);

            history.ChangeDate = DateTime.Now;
            _unitOfWork.History.Update(history);
            _unitOfWork.Save();
        }
Esempio n. 3
0
        public void Add(HistoryDTO historyDTO)
        {
            History history = Mapper.Map <History>(historyDTO);

            history.Id         = Guid.NewGuid();
            history.ChangeDate = DateTime.Now;
            _unitOfWork.History.Create(history);
            _unitOfWork.Save();
        }
        public bool addData(HistoryDTO historyDTO)
        {
            if (historyDTO.Name == string.Empty || historyDTO.Time == string.Empty)
            {
                return(false);
            }

            return(HistoryDAO.Instance.addData(historyDTO));
        }
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            HistoryDTO historyDTO = HistoryService.Get((Guid)id);

            if (historyDTO == null)
            {
                return(HttpNotFound());
            }

            HistoryVM historyVM = Mapper.Map <HistoryVM>(historyDTO);

            List <EquipmentSelectModel> equipmentSelectModel = new List <EquipmentSelectModel>();
            var eqipmentWithInventNumber = EquipmentService.GetAll();

            foreach (var item in eqipmentWithInventNumber)
            {
                equipmentSelectModel.Add(
                    new EquipmentSelectModel
                {
                    Id = item.Id,
                    TypeAndInventNumber = item.EquipmentType.Name + " (Номер: " + item.InventNumber + ")"
                }
                    );
            }
            ViewBag.ChangeDateNow = ((DateTime)historyVM.ChangeDate).ToString("dd.MM.yyyy HH:mm:ss");

            ViewBag.StatusTypeId = new SelectList(
                StatusTypeService.GetAll(),
                "Id",
                "Name",
                historyVM.StatusTypeId);

            ViewBag.RepairPlaceId = new SelectList(
                RepairPlaceService.GetAll(),
                "Id",
                "Name",
                historyVM.RepairPlaceId);

            ViewBag.EquipmentId = new SelectList(
                equipmentSelectModel,
                "Id",
                "TypeAndInventNumber",
                historyVM.EquipmentId);

            ViewBag.EmployeeId = new SelectList(
                EmployeeService.GetAll(),
                "EmployeeId",
                "EmployeeFullName",
                historyVM.EmployeeId);

            return(View(historyVM));
        }
Esempio n. 6
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            string str_ProjectIDLocal = this.txtEdtProjectID.Text.Trim();
            string str_StageLocal     = this.txtEdtStage.Text.Trim();

            StageDTO stageDTOLocal = new StageDTO();

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

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

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

                this.btnNext.Enabled = true;

                // Tăng stage lên và kiểm tra có lớn hơn 20 stage không.
                i_StageGlobal++;
                if (i_StageGlobal > 20)
                {
                    this.btnOK.Enabled = false;
                }

                XtraMessageBox.Show("Successfully added project - stage: " + str_ProjectIDLocal + " - " + str_StageLocal + "!", "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: " + str_ProjectIDLocal + " - " + str_StageLocal;
                string status = "Failed";

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

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

                return;
            }
            #endregion


            this.formCreatingStage_Load(null, null);
        }
Esempio n. 7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string str_CurrentPasswordLocal    = txtEdtCurrentPassword.Text.Trim();
            string str_NewPasswordLocal        = txtEdtNewPassword.Text.Trim();
            string str_ConfirmNewPasswordLocal = txtEdtConfirmNewPassword.Text.Trim();
            int    i_CompareLocal = 0;

            if (StaticVarClass.account_Password != str_CurrentPasswordLocal)
            {
                XtraMessageBox.Show("Current password does not match. Please try again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                i_CompareLocal = String.Compare(str_NewPasswordLocal, str_ConfirmNewPasswordLocal, false);

                if (i_CompareLocal == 0)
                {
                    if (EmployeeBUS.Instance.updateDataPassword(StaticVarClass.account_Username, str_ConfirmNewPasswordLocal))
                    {
                        StaticVarClass.account_Password = str_ConfirmNewPasswordLocal;

                        #region Cập nhật lịch sử.
                        string name   = StaticVarClass.account_Username;
                        string time   = DateTime.Now.ToString();
                        string action = "Change password";
                        string status = "Successful";

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

                        XtraMessageBox.Show("Successfully changed password", "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 = "Change password";
                        string status = "Failed";

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

                        XtraMessageBox.Show("Change password failed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    XtraMessageBox.Show("New passwords do not match. Please try again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        public ActionResult Edit([Bind(Include = "Id,EquipmentId,ChangeDate,EmployeeId,RepairPlaceId,StatusTypeId,Comments")] HistoryVM historyVM)
        {
            if (ModelState.IsValid)
            {
                HistoryDTO historyDTO = Mapper.Map <HistoryDTO>(historyVM);
                HistoryService.Update(historyDTO);

                return(RedirectToAction("Index"));
            }

            List <EquipmentSelectModel> equipmentSelectModel = new List <EquipmentSelectModel>();
            var eqipmentWithInventNumber = EquipmentService.GetAll();

            foreach (var item in eqipmentWithInventNumber)
            {
                equipmentSelectModel.Add(
                    new EquipmentSelectModel
                {
                    Id = item.Id,
                    TypeAndInventNumber = item.EquipmentType.Name + " (Номер: " + item.InventNumber + ")"
                }
                    );
            }

            ViewBag.ChangeDateNow = DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss");

            ViewBag.StatusTypeId = new SelectList(
                StatusTypeService.GetAll(),
                "Id",
                "Name",
                historyVM.StatusTypeId);

            ViewBag.RepairPlaceId = new SelectList(
                RepairPlaceService.GetAll(),
                "Id",
                "Name",
                historyVM.RepairPlaceId);

            ViewBag.EquipmentId = new SelectList(
                equipmentSelectModel,
                "Id",
                "TypeAndInventNumber",
                historyVM.EquipmentId);

            ViewBag.EmployeeId = new SelectList(
                EmployeeService.GetAll(),
                "EmployeeId",
                "EmployeeFullName",
                historyVM.EmployeeId);

            return(View(historyVM));
        }
        public bool addData(HistoryDTO hisDTO)
        {
            if (hisDTO.Name == string.Empty || hisDTO.Time == string.Empty)
            {
                return(false);
            }

            string query = "INSERT INTO HISTORY VALUES ('" + hisDTO.Name + "', '" + hisDTO.Time + "', '" + hisDTO.Action + "', '" + hisDTO.Status + "')";

            int result = DataProvider.Instance.ExecuteNonQuery(query);

            return(result > 0);
        }
Esempio n. 10
0
 public History ToEntity(HistoryDTO historyDTO)
 {
     return(new History
     {
         Id = historyDTO.Id,
         GameResult = historyDTO.GameResultType.ToString(),
         FirstPlayerName = historyDTO.FirstPlayerName,
         FirstPlayerElement = historyDTO.FirstPlayerElement,
         SecondPlayerName = historyDTO.SecondPlayerName,
         SecondPlayerElement = historyDTO.SecondPlayerElement,
         GameDate = historyDTO.GameDate
     });
 }
Esempio n. 11
0
        public ActionResult ShowMessage(HistoryDTO model)
        {
            string response = this.messageService.GetResponse(model.CurrentMessage.Message);

            model.CurrentMessage.CreatedOn = DateTime.Now;
            model.CurrentMessage.Type      = MessageType.User;
            history.History.Add(model.CurrentMessage);
            history.History.Add(new MessageDTO()
            {
                UserName = "******", Message = response, Type = MessageType.Bot, CreatedOn = DateTime.Now
            });
            history.CurrentMessage = new MessageDTO();
            ModelState.Clear();
            return(View("Message", history));
        }
Esempio n. 12
0
        private void nmrUpDwnProgress_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                string str_ProjectIDLocal = this.str_ProjectIDGlobal;
                string str_StageLocal     = this.str_StageGlobal;
                string str_TaskLocal      = this.str_TaskGlobal;
                string str_ProgressLocal  = this.nmrUpDwnProgress.Text.Trim();

                if (TaskCreatingBUS.Instance.updateDataForProgress(str_ProjectIDLocal, str_StageLocal, str_TaskLocal, str_ProgressLocal))
                {
                    // Kiểm tra xem đc xác nhận chưa.
                    this.checkConfirm();

                    // Load lại tab thông tin.
                    this.loadInformation();


                    #region Cập nhật lịch sử.
                    string name   = StaticVarClass.account_Username;
                    string time   = DateTime.Now.ToString();
                    string action = "Edit project - stage - task: " + str_ProjectIDLocal + " - " + str_StageLocal + " - " + str_TaskLocal;
                    string status = "Successful";

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

                    XtraMessageBox.Show("Successfully edited!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    tbpnTaskDetail.SelectedPageIndex = 1;
                }
                else
                {
                    #region Cập nhật lịch sử.
                    string name   = StaticVarClass.account_Username;
                    string time   = DateTime.Now.ToString();
                    string action = "Edit project - stage - task: " + str_ProjectIDLocal + " - " + str_StageLocal + " - " + str_TaskLocal;
                    string status = "Successful";

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

                    XtraMessageBox.Show("Edit failed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private HistoryDTO CreateHistoryResultDto(History hist)
        {
            var post = _sharedService.GetPost(hist.Postid);
            var dto  = new HistoryDTO
            {
                Title     = post.Title,
                Body      = post.Body,
                Date      = hist.Date,
                ThreadUrl = Url.Link(
                    nameof(QuestionsController.GetThread),
                    new { questionId = hist.Postid }
                    )
            };

            return(dto);
        }
Esempio n. 14
0
        private void btnApprove_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            System.Data.DataRow dtR_rowLocal = grvPersonalInformation.GetDataRow(grvPersonalInformation.FocusedRowHandle);

            string str_ProjectIDLocal = dtR_rowLocal[0].ToString().Trim();
            string str_StageLocal     = dtR_rowLocal[1].ToString().Trim();
            string str_TaskLocal      = dtR_rowLocal[2].ToString().Trim();
            string str_EmployeeLocal  = dtR_rowLocal[3].ToString().Trim();
            string str_Status         = StaticVarClass.status_Complete;

            DialogResult dr = XtraMessageBox.Show("Are you sure you want to approve project - stage - task: " + str_ProjectIDLocal + " - " + str_StageLocal + " - " + str_TaskLocal + " for employee " + str_EmployeeLocal + "!", "Confirm approve", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

            if (dr == DialogResult.OK)
            {
                if (TaskCreatingBUS.Instance.updateDataForConfirmApprove(str_ProjectIDLocal, str_StageLocal, str_TaskLocal, str_Status))
                {
                    #region Cập nhật lịch sử.
                    string name   = StaticVarClass.account_Username;
                    string time   = DateTime.Now.ToString();
                    string action = "Approve 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 approved 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 = "Approve 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("Approve project - stage - task: " + str_ProjectIDLocal + " - " + str_StageLocal + " - " + str_TaskLocal + " for employee " + str_EmployeeLocal + " failed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            this.loadSearchInfo();
        }
Esempio n. 15
0
        public ActionResult Details(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            HistoryDTO historyDTO = HistoryService.Get((Guid)id);

            if (historyDTO == null)
            {
                return(HttpNotFound());
            }

            HistoryVM historyVM = Mapper.Map <HistoryVM>(historyDTO);

            return(View(historyVM));
        }
Esempio n. 16
0
        private void btnStop_Click(object sender, EventArgs e)
        {
            string str_ProjectIDLocal       = this.cbbProjectID.Text.Trim();
            string str_DateRepeatLocal      = "0";
            string str_AutoRepeatLocal      = "0";
            string str_StartDateRepeatLocal = null;
            string str_EndDateRepeatLocal   = null;

            #region Sửa.
            // Sửa.
            if (ProjectBUS.Instance.updateDataRepeatedProject(str_ProjectIDLocal, str_DateRepeatLocal, str_AutoRepeatLocal, str_StartDateRepeatLocal, str_EndDateRepeatLocal))
            {
                #region Cập nhật lịch sử.
                string name   = StaticVarClass.account_Username;
                string time   = DateTime.Now.ToString();
                string action = "Stop repeating project: " + str_ProjectIDLocal;
                string status = "Successful";

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

                XtraMessageBox.Show("Successfully stopped repeating 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 = "Stop repeating project: " + str_ProjectIDLocal;
                string status = "Failed";

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

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

                return;
            }
            #endregion

            formRepeatedProject_Load(sender, e);
        }
Esempio n. 17
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string str_NameLocal = this.txtEdtName.Text.Trim();

            EmployeeDTO employeeDTOLocal = new EmployeeDTO();

            // Gán giá trị vào đối tượng employeeDTOLocal
            setData(employeeDTOLocal);

            // Sửa.
            if (EmployeeBUS.Instance.updateDataNotAllColumns(employeeDTOLocal))
            {
                #region Cập nhật lịch sử.
                string name   = StaticVarClass.account_Username;
                string time   = DateTime.Now.ToString();
                string action = "Edit personal information";
                string status = "Successful";

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

                XtraMessageBox.Show("Successfully edited personal information of " + str_NameLocal + "!", "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 = "Edit personal information";
                string status = "Failed";

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

                XtraMessageBox.Show("Edit personal information of " + str_NameLocal + " failed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }

            formPersonalInformation_Load(sender, e);
        }
Esempio n. 18
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

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

            if (sendMail())
            {
                #region Cập nhật lịch sử.
                string name   = StaticVarClass.account_Username;
                string time   = DateTime.Now.ToString();
                string action = "Send a mail to confirm project - stage - task: " + str_ProjectIDLocal + " - " + str_StageLocal + " - " + str_TaskLocal;
                string status = "Successful";

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

                XtraMessageBox.Show("Successfully sent!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);

                i_FlagMailGlobal = 1;  // Báo hiệu đã gửi mail thành công.

                // Kiểm tra xác nhận đc chưa.
                this.checkConfirm();
            }
            else
            {
                #region Cập nhật lịch sử.
                string name   = StaticVarClass.account_Username;
                string time   = DateTime.Now.ToString();
                string action = "Send a mail to confirm project - stage - task: " + str_ProjectIDLocal + " - " + str_StageLocal + " - " + str_TaskLocal;
                string status = "Failed";

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

                XtraMessageBox.Show("Send failed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 19
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            // Lưu thông tin của stage mới vào bảng STAGE.
            string str_ProjectIDLocal    = this.txtEdtProjectID.Text.Trim();
            string str_StageLocal        = this.txtEdtStage.Text.Trim();
            string str_StageSubjectLocal = this.txtEdtStageSubject.Text.Trim();
            string str_StatusLocal       = StaticVarClass.status_NotComplete;

            StageDTO stageDTOTemp = new StageDTO(str_ProjectIDLocal, str_StageLocal, str_StageSubjectLocal, str_StatusLocal);

            if (StageBUS.Instance.addData(stageDTOTemp))
            {
                #region Cập nhật lịch sử.
                string name   = StaticVarClass.account_Username;
                string time   = DateTime.Now.ToString();
                string action = "Add project - stage: " + str_ProjectIDLocal + " - " + str_StageLocal;
                string status = "Successful";

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

                XtraMessageBox.Show("Successfully added project - stage: " + str_ProjectIDLocal + " - " + str_StageLocal + "!", "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: " + str_ProjectIDLocal + " - " + str_StageLocal;
                string status = "Failed";

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

                XtraMessageBox.Show("Add project - stage: " + str_ProjectIDLocal + " - " + str_StageLocal + " failed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 20
0
        public async Task <HistoryDTO> GetHistory(string id, DateTime start, DateTime end)
        {
            var results = Repositories.Datas.FindByCondition(x => x.Lilypad.Id == id &&
                                                             (DateTime.Compare(x.RecordedAt, start) >= 0) &&
                                                             (DateTime.Compare(x.RecordedAt, end) <= 0)).ToList();
            var resultsGrouped = results.Select(x => x).OrderByDescending(x => x.Temperature).GroupBy(x => new { temp = x.RecordedAt.ToShortDateString() }).ToList();
            var historyDTO     = new HistoryDTO();

            historyDTO.Temps = new List <TempMaxMin>();
            resultsGrouped.Select(x =>
            {
                var dayTemp        = new TempMaxMin();
                dayTemp.TempMax    = (x.Select(y => y.Temperature).FirstOrDefault());
                dayTemp.TempMin    = (x.Select(y => y.Temperature).LastOrDefault());
                dayTemp.RecordedAt = (x.Select(y => y.RecordedAt).LastOrDefault());

                historyDTO.Temps.Add(dayTemp);
                return(0);
            }).ToList();
            historyDTO.Temps.Reverse();
            return(historyDTO);
        }
Esempio n. 21
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);
            }
        }
Esempio n. 22
0
        private void btnRemove_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string str_ProjectIDLocal = cbbProjectID.Text.Trim();
            string str_StageLocal     = txtEdtStage.Text.Trim();

            #region Nếu project đã complete thì ko đc xóa stage.
            string str_StatusProjectLocal = ProjectBUS.Instance.getStringStatusFollowProjectID(str_ProjectIDLocal);

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

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

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

            #region Nếu project - stage đã complete thì ko đc xóa stage.
            string str_StatusLocal = StageBUS.Instance.getStringStatusFollowProjectIDAndStage(str_ProjectIDLocal, str_StageLocal);

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

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

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

            int i_SumOfTaskLocal = TaskCreatingBUS.Instance.getIntQuantityInStageForFormProjectDiagram(str_ProjectIDLocal, str_StageLocal);

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

            #region Lấy ra các chỉ số để xem xét việc xóa task.
            int    i_RuleLocal = StageBUS.Instance.getIntWarningWhenRemovingStage(str_ProjectIDLocal, str_StageLocal);
            string str_Message = string.Empty;

            switch (i_RuleLocal)
            {
            case -1:
                DialogResult dr = XtraMessageBox.Show("Cannot connect to database!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;

            case 1:
                str_Message = "Warning: If you remove project - stage:" + str_ProjectIDLocal + " - " + str_StageLocal + ", you will not be able to add any stages in this project. \nThere are " + i_SumOfTaskLocal + " tasks in project - stage: " + str_ProjectIDLocal + " - " + str_StageLocal + ". \nAre you sure you want to remove?";
                break;

            case 0:
            case 2:
                str_Message = "Warning: There are " + i_SumOfTaskLocal + " tasks in project - stage: " + str_ProjectIDLocal + " - " + str_StageLocal + ". \nAre you sure you want to remove?";
                break;
            }
            #endregion

            DialogResult drLocal = XtraMessageBox.Show(str_Message, "Comfirm remove", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

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

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

                    XtraMessageBox.Show("Successfully removed project - stage: " + str_ProjectIDLocal + " - " + str_StageLocal + "!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    #region update status and progress project.
                    StageDTO stageDTOTemp = StageBUS.Instance.getDataObjectForUpdateWhenRemovingStage(str_ProjectIDLocal);

                    if (stageDTOTemp.Empty() == false && stageDTOTemp != null)
                    {
                        if (!StageBUS.Instance.updateDataStatus(stageDTOTemp.ProjectID, stageDTOTemp.Stage, stageDTOTemp.Status))
                        {
                            XtraMessageBox.Show("Update status of project " + str_ProjectIDLocal + " failed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    #endregion
                }
                else
                {
                    #region Cập nhật lịch sử.
                    string name   = StaticVarClass.account_Username;
                    string time   = DateTime.Now.ToString();
                    string action = "Remove project - stage: " + str_ProjectIDLocal + " - " + str_StageLocal;
                    string status = "Failed";

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

                    XtraMessageBox.Show("Remove project - stage: " + str_ProjectIDLocal + " - " + str_StageLocal + " failed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                return;
            }

            formStage_Load(sender, e);
        }
Esempio n. 23
0
        private void btnSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string str_ProjectIDLocal = cbbProjectID.Text.Trim();
            string str_StageLocal     = txtEdtStage.Text.Trim();

            StageDTO stageDTOLocal = new StageDTO();

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

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

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

                    XtraMessageBox.Show("Successfully added project - stage: " + str_ProjectIDLocal + " - " + str_StageLocal + "!", "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: " + str_ProjectIDLocal + " - " + str_StageLocal;
                    string status = "Failed";

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

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

                    return;
                }
            }
            #endregion

            #region Sửa.
            else if (i_FlagGlobal == 2)
            {
                // Sửa.
                if (StageBUS.Instance.updateData(stageDTOLocal))
                {
                    #region Cập nhật lịch sử.
                    string name   = StaticVarClass.account_Username;
                    string time   = DateTime.Now.ToString();
                    string action = "Edit project - stage: " + str_ProjectIDLocal + " - " + str_StageLocal;
                    string status = "Successful";

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

                    XtraMessageBox.Show("Successfully edited project - stage: " + str_ProjectIDLocal + " - " + str_StageLocal + "!", "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 = "Edit project - stage: " + str_ProjectIDLocal + " - " + str_StageLocal;
                    string status = "Failed";

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

                    XtraMessageBox.Show("Edit project - stage: " + str_ProjectIDLocal + " - " + str_StageLocal + " failed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    return;
                }
            }
            #endregion

            formStage_Load(sender, e);
        }
Esempio n. 24
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            string str_ProjectIDLocal = this.str_ProjectIDGlobal;
            string str_StageLocal     = this.str_StageGlobal;
            string str_TaskLocal      = this.str_TaskGlobal;
            string str_TimeLocal      = DateTime.Now.ToString();
            string str_FileNameLocal  = this.txtEdtFileNameUpload.Text.Trim();
            string str_NoteLocal      = this.txtEdtNoteUpload.Text.Trim();

            ftp ftpClientLocal = new ftp(StaticVarClass.ftp_Server, StaticVarClass.ftp_Username, StaticVarClass.ftp_Password);

            if (ftpClientLocal.upload(StaticVarClass.account_Username, ftpInfo.FileName, ftpInfo.FullName))
            {
                AttachedFileDTO attachFileDTOTemp = new AttachedFileDTO(str_ProjectIDLocal, str_StageLocal, str_TaskLocal, str_TimeLocal, str_FileNameLocal, str_NoteLocal);

                if (AttachedFileDAO.Instance.addData(attachFileDTOTemp))
                {
                    //this.i_FlagUploadGlobal = 1;  // Báo hiệu đã đăng file.

                    // Kiểm tra xác nhận được chưa.
                    this.checkConfirm();

                    // Load lại attachFile.
                    this.loadDataAttachFile();

                    #region Cập nhật lịch sử.
                    string name   = StaticVarClass.account_Username;
                    string time   = DateTime.Now.ToString();
                    string action = "Upload a file named " + str_FileNameLocal + " in project - stage - task: " + str_ProjectIDLocal + " - " + str_StageLocal + " - " + str_TaskLocal;
                    string status = "Successful";

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

                    XtraMessageBox.Show("Successfully uploaded!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    // Làm sạch control.
                    this.clearUpload();
                    this.disableAttachFileUpload(true);
                }
                else
                {
                    #region Cập nhật lịch sử.
                    string name   = StaticVarClass.account_Username;
                    string time   = DateTime.Now.ToString();
                    string action = "Upload a file named " + str_FileNameLocal + " in project - stage - task: " + str_ProjectIDLocal + " - " + str_StageLocal + " - " + str_TaskLocal;
                    string status = "Failed";

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

                    XtraMessageBox.Show("Upload 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 = "Upload a file named " + str_FileNameLocal + " in project - stage - task: " + str_ProjectIDLocal + " - " + str_StageLocal + " - " + str_TaskLocal;
                string status = "Failed";

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

                XtraMessageBox.Show("Upload failed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 25
0
        private void btnOke_Click(object sender, EventArgs e)
        {
            string str_ProjectLocal = this.txtEdtProjectID.Text.Trim();

            ProjectDTO projectDTOLocal = new ProjectDTO();

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

            #region Kiểm tra start date.
            if (DateTime.Parse(projectDTOLocal.StartDate) >= DateTime.Parse(projectDTOLocal.EndDate))
            {
                XtraMessageBox.Show("Invalid start date!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TimeSpan difference = new TimeSpan(1, 0, 0, 0);
                this.dtEdtStartDate.DateTime = this.dtEdtEndDate.DateTime.Subtract(difference);
                return;
            }
            #endregion

            #region Thêm mới.

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

            // Thêm mới.
            if (ProjectDAO.Instance.addData(projectDTOLocal))
            {
                #region Cập nhật lịch sử.
                string name   = StaticVarClass.account_Username;
                string time   = DateTime.Now.ToString();
                string action = "Add project " + projectDTOLocal.ProjectID;
                string status = "Successful";

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

                XtraMessageBox.Show("Successfully added project " + str_ProjectLocal + "!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);


                #region Chuyển qua creating stage.
                this.Hide();

                formProjectCreating frmProjectCreating = formProjectCreating.Instance;
                formCreatingStage   frmCreatingStage   = new formCreatingStage();
                frmCreatingStage.setInfo(str_ProjectLocal);
                frmCreatingStage.MdiParent = frmProjectCreating;
                frmCreatingStage.Show();
                #endregion
            }
            else
            {
                #region Cập nhật lịch sử.
                string name   = StaticVarClass.account_Username;
                string time   = DateTime.Now.ToString();
                string action = "Add project " + projectDTOLocal.ProjectID;
                string status = "Failed";

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

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

                return;
            }
            #endregion
        }
Esempio n. 26
0
        public async Task <IEnumerable <HistoryDTO> > GetAllAsync()
        {
            var history = await _unitOfWork.HistoryRepository.GetAllAsync();

            List <HistoryDTO> datareturn = new List <HistoryDTO>();

            foreach (var element in history)
            {
                var historyDto = new HistoryDTO()
                {
                    Id              = element.Id,
                    Date            = element.Date,
                    DateFinished    = element.DateFinished,
                    BookDescription = element.BookDescription,
                    CategoryName    = element.CategoryName,
                    SubcategoryName = element.SubcategoryName,
                    WorkDescription = element.WorkDescription,

                    Customer = new CustomerDTO()
                    {
                        Id     = element.Customer.Id,
                        Person = new PersonDTO()
                        {
                            Id      = element.Customer.Person.Id,
                            Name    = element.Customer.Person.Name,
                            Surname = element.Customer.Person.Surname,
                            Phone   = element.Customer.Person.Phone
                        }
                    }
                };



                if (element.Vendor != null)
                {
                    historyDto.Vendor = new ShortVendorDTO()
                    {
                        Id       = element.Vendor.Id,
                        Birthday = element.Vendor.Person.Birthday,
                        Avatar   = element.Vendor.Person.Account.Avatar,
                        Name     = element.Vendor.Person.Name
                    };
                }

                if (element.Company != null)
                {
                    historyDto.Company = new CompanyDTO()
                    {
                        Id      = element.Company.Id,
                        Account = new AccountDTO()
                        {
                            Id          = element.Company.Account.Id,
                            DateCreated = element.Company.Account.DateCreated
                        },
                        Vendors = element.Company.Vendors.Select
                                      (x => new VendorDTO {
                            Id = x.Id, Person = new PersonDTO()
                            {
                                Id = x.Person.Id, Name = x.Person.Name, Surname = x.Person.Surname
                            }
                        })
                                  .ToList()
                    };
                }
                datareturn.Add(historyDto);
            }
            return(datareturn);
        }
Esempio n. 27
0
        public async Task <HistoryDTO> GetById(long id)
        {
            var history = await _unitOfWork.HistoryRepository.GetByIdAsync(id);

            var historyDto = new HistoryDTO()
            {
                Id              = history.Id,
                Date            = history.Date,
                DateFinished    = history.DateFinished,
                WorkDescription = history.WorkDescription,
                BookDescription = history.BookDescription,
                CategoryName    = history.CategoryName,
                SubcategoryName = history.SubcategoryName,

                Customer = new CustomerDTO()
                {
                    Id     = history.Customer.Id,
                    Person = new PersonDTO()
                    {
                        Id      = history.Customer.Person.Id,
                        Name    = history.Customer.Person.Name,
                        Surname = history.Customer.Person.Surname,
                        Phone   = history.Customer.Person.Phone
                    }
                }
            };

            if (history.Review != null)
            {
                historyDto.Review = new ReviewDTO()
                {
                    Id = history.Review.Id,

                    FromAccountId = history.Review.Sender.Id,
                    Avatar        = history.Review.Sender.Avatar,
                    From          = $"{history.Customer.Person.Name} {history.Customer.Person.Surname}",
                    Date          = history.Review.Date,
                    Description   = history.Review.Description,
                    BookId        = history.Review.BookId,
                    To            = history.Review.To,
                    ToAccountId   = history.Review.ToAccountId
                };
            }
            if (history.Vendor != null)
            {
                historyDto.Vendor = new ShortVendorDTO()
                {
                    Name = "ololo"
                };
            }
            if (history.Company != null)
            {
                historyDto.Company = new CompanyDTO()
                {
                    Id      = history.Company.Id,
                    Account = new AccountDTO()
                    {
                        Id          = history.Company.Account.Id,
                        DateCreated = history.Company.Account.DateCreated
                    },
                    Vendors = history.Company.Vendors.Select(x => new VendorDTO {
                        Id = x.Id, Person = new PersonDTO()
                        {
                            Id = x.Person.Id, Name = x.Person.Name, Surname = x.Person.Surname
                        }
                    }).ToList()
                };
            }
            return(historyDto);
        }
Esempio n. 28
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);
        }
Esempio n. 29
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);
        }
Esempio n. 30
0
        private void btnSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string str_ProjectIDLocal = this.txtEdtProjectID.Text.Trim(); // ProjectID mới (nếu có).

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

            ProjectDTO projectDTOLocal = new ProjectDTO();

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

            #region Kiểm tra start date.
            if (DateTime.Parse(projectDTOLocal.StartDate) >= DateTime.Parse(projectDTOLocal.EndDate))
            {
                XtraMessageBox.Show("Invalid start date!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TimeSpan difference = new TimeSpan(1, 0, 0, 0);
                this.dtEdtStartDate.DateTime = this.dtEdtEndDate.DateTime.Subtract(difference);
                return;
            }
            #endregion

            #region Thêm mới.
            if (this.i_FlagGlobal == 1)
            {
                #region Kiểm tra end date.
                if (DateTime.Parse(projectDTOLocal.EndDate) <= DateTime.Parse(projectDTOLocal.StartDate))
                {
                    XtraMessageBox.Show("Invalid end date!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.dtEdtEndDate.DateTime = this.dtEdtStartDate.DateTime.AddDays(1);
                    return;
                }
                #endregion

                // Thêm mới.
                if (ProjectBUS.Instance.addData(projectDTOLocal))
                {
                    #region Cập nhật lịch sử.
                    string name   = StaticVarClass.account_Username;
                    string time   = DateTime.Now.ToString();
                    string action = "Add project " + projectDTOLocal.ProjectID;
                    string status = "Successful";

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

                    XtraMessageBox.Show("Successfully added project " + projectDTOLocal.ProjectID + "!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    if (this.frmRepeatedProject == null)
                    {
                        this.frmRepeatedProject = new formRepeatedProject();
                    }
                    this.frmRepeatedProject.getCreatedProject(projectDTOLocal.ProjectID); // Lưu lại projectID mới tạo cho form Repeated Project.
                }
                else
                {
                    #region Cập nhật lịch sử.
                    string name   = StaticVarClass.account_Username;
                    string time   = DateTime.Now.ToString();
                    string action = "Add project " + projectDTOLocal.ProjectID;
                    string status = "Failed";

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

                    XtraMessageBox.Show("Add project " + projectDTOLocal.ProjectID + " failed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    return;
                }
            }
            #endregion

            #region Sửa.
            else if (this.i_FlagGlobal == 2)
            {
                #region Kiểm tra end date.
                if (DateTime.Parse(projectDTOLocal.EndDate) < DateTime.Parse(this.str_OldEndDateGlobal))
                {
                    XtraMessageBox.Show("Invalid end date!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.dtEdtEndDate.DateTime = DateTime.Parse(this.str_OldEndDateGlobal);
                    return;
                }
                #endregion

                // Sửa.
                if (ProjectBUS.Instance.updateData(projectDTOLocal, str_ProjectIDLocal))
                {
                    #region Cập nhật lịch sử.
                    string name   = StaticVarClass.account_Username;
                    string time   = DateTime.Now.ToString();
                    string action = "Edit project " + projectDTOLocal.ProjectID;
                    string status = "Successful";

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

                    XtraMessageBox.Show("Successfully edited project " + projectDTOLocal.ProjectID + "!", "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 = "Edit project " + projectDTOLocal.ProjectID;
                    string status = "Failed";

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

                    XtraMessageBox.Show("Edit project " + projectDTOLocal.ProjectID + " failed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    return;
                }
            }
            #endregion

            formProject_Load(sender, e);
        }