public int AddProjectTask(ProjectTaskModel taskModel, int phaseId) { ProjectDataAccess obj = new ProjectDataAccess(); var result = obj.AddProjectTask(taskModel, phaseId); return(result); }
public async Task <IActionResult> AddTask(ProjectTaskModel taskModel) { DateTime start = DateTime.ParseExact(taskModel.StartDate, "MM/dd/yyyy", CultureInfo.InvariantCulture); DateTime end = DateTime.ParseExact(taskModel.EndDate, "MM/dd/yyyy", CultureInfo.InvariantCulture); if (start > end) { ViewBag.Error = "End Date can't be greater than start date"; var result1 = await this._repository.GetUsersAsync(3); taskModel.Users = result1.Select(x => new SelectListItem { Text = x.FirstName + " " + x.LastName, Value = x.Id.ToString() }).ToList(); return(View(taskModel)); } taskModel.CreatedBy = this.UserId; if (await this._repository.AddProjectTaskAsync(taskModel)) { int projectid = taskModel.ProjectId; taskModel = new ProjectTaskModel(); taskModel.ProjectId = projectid; ModelState.Clear(); ViewBag.Success = "Task has been added"; } else { ViewBag.Error = "There are error while saving"; } var result = await this._repository.GetUsersAsync(3); taskModel.Users = result.Select(x => new SelectListItem { Text = x.FirstName + " " + x.LastName, Value = x.Id.ToString() }).ToList(); return(View(taskModel)); }
private void btnAdd_Click(object sender, EventArgs e) { _TaskModelNow = null; _IStatusForm = 1; _setStatusForm(); txtTaskID.Focus(); }
public ActionResult CreateTask(int projectID) { ProjectTaskModel projectTaskModel = new ProjectTaskModel(); projectTaskModel.ProjectID = projectID; return(View(projectTaskModel)); }
public JsonResult CreateTask(ProjectTaskModel model) { string response = adminServices.AddNewTask(new BLL.DTO.ProjectTasksDTO() { Label = model.Label, CreatedById = 1, ProjectId = model.ProjectId, PriorityStatusId = model.PriorityStatusId, TaskStatusId = (int)TaskStatusEnum.Created }); return(Json(new { Message = response })); }
private void _getData() { if (_ProjectTaskModelNow == null) { _ProjectTaskModelNow = new ProjectTaskModel(); } //_ProjectTaskModelNow.StrTaskID = lkeTask.GetColumnValue("StrTaskID").ToString(); //_ProjectTaskModelNow.StrProjectID = lkeProject.GetColumnValue("StrProjectID").ToString(); _ProjectTaskModelNow.StrFileName = txtFileName.Text; _ProjectTaskModelNow.StrLinkFile = txtFolderPath.Text; }
public bool addNewProjectTask(ProjectTaskModel projectTask) { try { _Context.ProjectTaskModels.Add(projectTask); return(_Context.SaveChanges() != 0); } catch { return(false); } }
public async Task <IActionResult> AddTask(int ProjectId) { ProjectTaskModel taskModel = new ProjectTaskModel(); taskModel.ProjectId = ProjectId; var result = await this._repository.GetUsersAsync(3); taskModel.Users = result.Select(x => new SelectListItem { Text = x.FirstName + " " + x.LastName, Value = x.Id.ToString() }).ToList(); return(View(taskModel)); }
private void _getData() { if (_TaskModelNow == null) { _TaskModelNow = new ProjectTaskModel(); } _TaskModelNow.StrProjectID = lkeProjectID.GetColumnValue("StrProjectID").ToString(); _TaskModelNow.StrTaskID = txtTaskID.Text; _TaskModelNow.StrTaskName = txtTaskName.Text; _TaskModelNow.DtStartDay = (DateTime)dteStartDay.EditValue; _TaskModelNow.DtEndDay = (DateTime)dteEndDay.EditValue; _TaskModelNow.StrFileName = txtFileName.Text; _TaskModelNow.StrLinkFile = txtLinkFile.Text; }
public bool deleteCurrentProjectTask(ProjectTaskModel projectTask) { try { var ProjectTaskToDelete = _Context.ProjectTaskModels.SingleOrDefault (x => x.StrTaskID == projectTask.StrTaskID); _Context.ProjectTaskModels.Remove(ProjectTaskToDelete); return(_Context.SaveChanges() != 0); } catch { return(false); } }
private void gvListTask_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e) { if (gvListTask.SelectedRowsCount > 0) { _TaskModelNow = (ProjectTaskModel)gvListTask.GetRow(gvListTask.FocusedRowHandle); } else { _TaskModelNow = null; } _loadData(); _IStatusForm = 0; _setStatusForm(); }
public int UpdateProjectTask(ProjectTaskModel taskModel, int phaseId) { ProjectDataAccess obj = new ProjectDataAccess(); var result = 0; if (taskModel.ProjectTaskId > 0) { result = taskModel.ProjectTaskId; obj.UpdateProjectTask(taskModel); } else { result = obj.AddProjectTask(taskModel, phaseId); } return(result); }
public async Task <bool> AddProjectTaskAsync(ProjectTaskModel taskModel) { using (SqlConnection conn = GetConnection()) { conn.Open(); var transaction = conn.BeginTransaction(); try { var list = new List <ProjectTaskModel>(); DynamicParameters param = new DynamicParameters(); if (taskModel.TaskId > 0) { param.Add("@TaskId", taskModel.TaskId); } param.Add("@ProjectId", taskModel.ProjectId); param.Add("@Name", taskModel.Name); param.Add("@StartDate", taskModel.StartDate); param.Add("@EndDate", taskModel.EndDate); param.Add("@CreatedBy", taskModel.CreatedBy); int TaskId = await transaction.Connection.ExecuteScalarAsync <int>("sp_AddTask", param, transaction : transaction, commandType : CommandType.StoredProcedure); if (taskModel.UsersId != null && taskModel.UsersId.Count() > 0) { param = new DynamicParameters(); param.Add("@TaskId", TaskId); await transaction.Connection.ExecuteScalarAsync <int>("sp_DeleteTaskUser", param, transaction : transaction, commandType : CommandType.StoredProcedure); foreach (var item in taskModel.UsersId) { param = new DynamicParameters(); param.Add("@TaskId", TaskId); param.Add("@UserId", item); await transaction.Connection.ExecuteScalarAsync <int>("sp_AddTaskUser", param, transaction : transaction, commandType : CommandType.StoredProcedure); } } transaction.Commit(); return(true); } catch (Exception ex) { transaction.Rollback(); return(false); } } }
public int UpdateProjectTask(ProjectTaskModel taskModel) { int result = 0; try { using (SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["DBConnection"].ToString())) { using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = "UpdateProjectTask"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ProjectTaskId", taskModel.ProjectTaskId); cmd.Parameters.AddWithValue("@TaskName", taskModel.TaskName); cmd.Parameters.AddWithValue("@ExpectedStartDate", taskModel.StartDate); cmd.Parameters.AddWithValue("@ExpectedEndDate", taskModel.EndDate); cmd.Parameters.AddWithValue("@ActualStartDate", string.Empty); cmd.Parameters.AddWithValue("@ActualEndDate", string.Empty); cmd.Parameters.AddWithValue("@Description", taskModel.Description); cmd.Parameters.AddWithValue("@Estimate", string.Empty); cmd.Parameters.AddWithValue("@AmountSpent", string.Empty); cmd.Parameters.AddWithValue("@AssignedUserId", 1); cmd.Parameters.AddWithValue("@AssignedUserName", string.Empty); cmd.Parameters.AddWithValue("@AssignedUserContactNumber", string.Empty); cmd.Parameters.AddWithValue("@Comments", taskModel.Description); cmd.Parameters.AddWithValue("@AddedBy", 1); cmd.Parameters.AddWithValue("@IsCompleted", false); cmd.Parameters.AddWithValue("@IsDeleted", false); cmd.Connection = conn; conn.Open(); using (SqlDataAdapter ada = new SqlDataAdapter(cmd)) { result = Convert.ToInt32(cmd.ExecuteScalar()); } conn.Close(); } } } catch (Exception ex) { //LogError(ex); } return(result); }
public bool addLinkFile(ProjectTaskModel projectTask) { try { var ProjectTaskToUpdate = _Context.ProjectTaskModels.SingleOrDefault (x => x.StrTaskID == projectTask.StrTaskID); if (ProjectTaskToUpdate != null) { ProjectTaskToUpdate.StrFileName = projectTask.StrFileName; ProjectTaskToUpdate.StrLinkFile = projectTask.StrLinkFile; return(_Context.SaveChanges() != 0); } return(false); } catch { return(false); } }
public async Task <ProjectTaskModel> Update(ProjectModel project, ProjectTaskModel projectTask) { var storedProject = await projectDataService.GetById(project.Id); foreach (var storedTask in GetProjectTasks(storedProject)) { if (storedTask.Id == projectTask.Id) { // map project task model to project task projectTask.MapBack(storedTask); break; } } await projectDataService.UpdateById(storedProject.Id, storedProject); return(projectTask); }
public async Task <IActionResult> Create(ProjectTaskModel request) { var dto = Mapper.Map <ProjectTaskDto>(request); if (!User.IsInRole("AdminAupervisor")) { dto.Author.Id = int.Parse(_userManager.GetUserId(User)); } var result = await _service.CreateItemAsync(dto); if (result.IsSuccess) { if (User.IsInRole("AdminAupervisor")) { return(RedirectToAction("IndexAdmin", "Project")); } else { return(RedirectToAction("IndexPM", "Project")); } } else { var project = _serviceProject.GetProject(request.ProjectId); if (User.IsInRole("AdminAupervisor")) { request.AuthorList = new SelectList(_helper.GetUsers(new List <StatusRole>() { StatusRole.AdminAupervisor, StatusRole.ProjectManager }, _serviceUser), "Id", "FullName"); } request.ExecutorList = new SelectList(_helper.GetUsers(project.ProjectUsers), "Id", "FullName"); foreach (var resultError in result.Errors) { ModelState.AddModelError("Error", resultError); } return(View(request)); } }
private void btnDelete_Click(object sender, EventArgs e) { if (_TaskModelNow != null) { if (_Task.deleteCurrentProjectTask(_TaskModelNow)) { _lstLoadListTask(); DevExpress.XtraEditors.XtraMessageBox.Show("Xóa Thành Công!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); if (_lstTask.Count == 0) { _TaskModelNow = null; _IStatusForm = 0; _setStatusForm(); } } else { DevExpress.XtraEditors.XtraMessageBox.Show("Xóa Thất Bại!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private List <ProjectTaskModel> MapProjectTaskDataTable(DataTable dt) { List <ProjectTaskModel> result = new List <ProjectTaskModel>(); if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { var obj = new ProjectTaskModel(); obj.ProjectTaskId = Convert.ToInt32(dt.Rows[i]["ProjectTaskId"]); obj.PhaseName = dt.Rows[i]["PhaseName"].ToString(); obj.TaskName = dt.Rows[i]["TaskName"].ToString(); obj.StartDate = Convert.ToDateTime(dt.Rows[i]["ExpectedStartDate"]).ToString("MM/dd/yyyy"); obj.EndDate = Convert.ToDateTime(dt.Rows[i]["ExpectedEndDate"]).ToString("MM/dd/yyyy"); obj.Description = dt.Rows[i]["Description"].ToString(); result.Add(obj); } } return(result); }
public bool updateCurrentProjectTask(ProjectTaskModel projectTask) { try { var ProjectTaskToUpdate = _Context.ProjectTaskModels.SingleOrDefault (x => x.StrTaskID == projectTask.StrTaskID); if (ProjectTaskToUpdate != null) { ProjectTaskToUpdate.StrProjectID = projectTask.StrProjectID; ProjectTaskToUpdate.StrTaskName = projectTask.StrTaskName; ProjectTaskToUpdate.DtStartDay = projectTask.DtStartDay; ProjectTaskToUpdate.DtEndDay = projectTask.DtEndDay; return(_Context.SaveChanges() != 0); } return(false); } catch { return(false); } }
public async Task <IActionResult> Delete(ProjectTaskModel request) { var dto = Mapper.Map <ProjectTaskDto>(request); var result = await _service.DeleteItemAsync(dto); if (result.IsSuccess) { if (User.IsInRole("AdminAupervisor")) { return(RedirectToAction("IndexAdmin", "Project")); } else { return(RedirectToAction("IndexPM", "Project")); } } else { return(View(request)); } }
public async Task <ProjectTaskModel> Add(ProjectModel project, ProjectTaskModel projectTask) { var storedProject = await projectDataService.GetById(project.Id); // create new project task with unique id var mappedTask = new ProjectTask { Id = ObjectId.GenerateNewId().ToString() }; // map project task model to project task and add it to the list projectTask.MapBack(mappedTask); GetProjectTasks(storedProject).Add(mappedTask); await projectDataService.UpdateById(storedProject.Id, storedProject); // map project task to project task model to get current id projectTask.Map(mappedTask); project.Tasks.Add(projectTask); return(projectTask); }
public IActionResult Create(int?projectId) { if (!projectId.HasValue) { return(NotFound()); } var projectTask = new ProjectTaskModel(); var project = _serviceProject.GetProject(projectId.Value); if (User.IsInRole("AdminAupervisor")) { projectTask.AuthorList = new SelectList(_helper.GetUsers(new List <StatusRole>() { StatusRole.AdminAupervisor, StatusRole.ProjectManager }, _serviceUser), "Id", "FullName"); } projectTask.ExecutorList = new SelectList(_helper.GetUsers(project.ProjectUsers), "Id", "FullName"); projectTask.ProjectId = projectId.Value; return(View(projectTask)); }
private ProjectModel MapProjectDetailsWithTasksAsList(DataSet ds) { var obj = new ProjectModel(); if (ds != null && ds.Tables.Count > 0) { DataTable dt = new DataTable(); dt = ds.Tables[0]; if (dt != null && dt.Rows.Count > 0) { obj.ProjectId = Convert.ToInt32(dt.Rows[0]["ProjectId"]); obj.ProjectName = dt.Rows[0]["ProjectName"].ToString(); obj.PrimaryContactName = dt.Rows[0]["PrimaryContactName"].ToString(); obj.PrimaryNumber = dt.Rows[0]["PrimaryContactNumber"].ToString(); obj.Address = dt.Rows[0]["Address"].ToString(); obj.PinCode = dt.Rows[0]["PinCode"].ToString(); obj.Contact1Name = dt.Rows[0]["Contact1Name"].ToString(); obj.Contact1number = dt.Rows[0]["Contact1number"].ToString(); obj.Contact2Name = dt.Rows[0]["Contact2Name"].ToString(); obj.Contact2Number = dt.Rows[0]["Contact2Number"].ToString(); obj.Contact3Name = dt.Rows[0]["Contact3Name"].ToString(); obj.Contact3Number = dt.Rows[0]["Contact3Number"].ToString(); obj.StartDate = dt.Rows[0]["EstimatedStartDate"].ToString(); obj.EndDate = dt.Rows[0]["EstimatedEndDate"].ToString(); obj.IsHidden = Convert.ToBoolean(dt.Rows[0]["IsHidden"].ToString()); obj.EstimatedStartDate = Convert.ToDateTime(dt.Rows[0]["EstimatedStartDate"]).ToString("yyyy-MM-dd HH:mm"); obj.EstimatedEndDate = Convert.ToDateTime(dt.Rows[0]["EstimatedEndDate"]).ToString("yyyy-MM-dd HH:mm"); obj.ActualStartDate = Convert.ToDateTime(dt.Rows[0]["ActualStartDate"]).ToString("yyyy-MM-dd HH:mm"); obj.ActualEndDate = Convert.ToDateTime(dt.Rows[0]["ActualEndDate"]).ToString("yyyy-MM-dd HH:mm"); obj.ProjectEstimate = dt.Rows[0]["ProjectEstimate"].ToString(); obj.Comments = dt.Rows[0]["Comments"].ToString(); } if (ds.Tables.Count > 1) { DataTable dtPhases = new DataTable(); dtPhases = ds.Tables[1]; var projectPhases = new List <ProjectPhaseModel>(); foreach (DataRow drPhase in dtPhases.Rows) { var projectPhase = new ProjectPhaseModel(); projectPhase.PhaseName = drPhase["Name"].ToString(); projectPhase.PhaseId = Convert.ToInt32(drPhase["ProjectPhaseId"]); projectPhase.ProjectId = Convert.ToInt32(drPhase["ProjectId"]); projectPhase.StartDate = Convert.ToDateTime(drPhase["ExpectedStartDate"]).ToString("yyyy-MM-dd HH:mm"); projectPhase.EndDate = Convert.ToDateTime(drPhase["ExpectedEndDate"]).ToString("yyyy-MM-dd HH:mm"); projectPhase.Description = drPhase["Description"].ToString(); var dtTask = new DataTable(); dtTask = ds.Tables[2]; var tasks = from row in dtTask.AsEnumerable() where row.Field <int>("ProjectPhaseId") == projectPhase.PhaseId select row; var projectTasks = new List <ProjectTaskModel>(); foreach (DataRow drTask in tasks) { var task = new ProjectTaskModel(); task.ProjectPhaseId = projectPhase.PhaseId; task.StartDate = Convert.ToDateTime(drTask["ExpectedStartDate"]).ToString("yyyy-MM-dd HH:mm"); task.EndDate = Convert.ToDateTime(drTask["ExpectedEndDate"]).ToString("yyyy-MM-dd HH:mm"); task.TaskName = drTask["TaskName"].ToString(); task.ProjectTaskId = Convert.ToInt32(drTask["ProjectTaskId"]); task.Description = drTask["Description"].ToString(); projectTasks.Add(task); } projectPhase.ProjectTasks = projectTasks; projectPhases.Add(projectPhase); } obj.ProjectPhases = projectPhases; } } return(obj); }