public static string GetTaskRowCssClass(JGConstant.TaskStatus objTaskStatus, JGConstant.TaskPriority?objTaskPriority) { string strRowCssClass = string.Empty; switch (objTaskStatus) { case JGConstant.TaskStatus.Open: strRowCssClass += " task-open"; if (objTaskPriority.HasValue) { strRowCssClass += " task-with-priority"; } break; case JGConstant.TaskStatus.Requested: strRowCssClass += " task-requested"; break; case JGConstant.TaskStatus.Assigned: strRowCssClass += " task-assigned"; break; case JGConstant.TaskStatus.InProgress: strRowCssClass += " task-inprogress"; break; case JGConstant.TaskStatus.Pending: strRowCssClass += " task-pending"; break; case JGConstant.TaskStatus.ReOpened: strRowCssClass += " task-reopened"; break; case JGConstant.TaskStatus.Closed: strRowCssClass += " task-closed closed-task-bg"; break; case JGConstant.TaskStatus.Finished: strRowCssClass += " task-finished finished-task-bg"; break; case JGConstant.TaskStatus.SpecsInProgress: strRowCssClass += " task-specsinprogress"; break; case JGConstant.TaskStatus.Deleted: strRowCssClass += " task-deleted deleted-task-bg"; break; default: break; } return(strRowCssClass); }
/// <summary> /// Save user's to whom task is assigned. /// </summary> private void SaveAssignedTaskUsers(DropDownCheckBoxes ddcbAssigned, JGConstant.TaskStatus objTaskStatus) { //if task id is available to save its note and attachement. if (hdnTaskId.Value != "0") { string strUsersIds = string.Empty; foreach (ListItem item in ddcbAssigned.Items) { if (item.Selected) { strUsersIds = strUsersIds + (item.Value + ","); } } // removes any extra comma "," from the end of the string. strUsersIds = strUsersIds.TrimEnd(','); // save (insert / delete) assigned users. bool isSuccessful = TaskGeneratorBLL.Instance.SaveTaskAssignedUsers(Convert.ToUInt64(hdnTaskId.Value), strUsersIds); // send email to selected users. if (strUsersIds.Length > 0) { if (isSuccessful) { // Change task status to assigned = 3. if (objTaskStatus == JGConstant.TaskStatus.Open || objTaskStatus == JGConstant.TaskStatus.Requested || objTaskStatus == JGConstant.TaskStatus.SpecsInProgress) { UpdateTaskStatus(Convert.ToInt32(hdnTaskId.Value), Convert.ToUInt16(JGConstant.TaskStatus.Assigned)); } SendEmailToAssignedUsers(Convert.ToInt32(hdnTaskId.Value), strUsersIds); } } // send email to all users of the department as task is assigned to designation, but not to any specific user. else { string strUserIDs = ""; foreach (ListItem item in ddcbAssigned.Items) { strUserIDs += string.Concat(item.Value, ","); } SendEmailToAssignedUsers(Convert.ToInt32(hdnTaskId.Value), strUserIDs.TrimEnd(',')); } } }
public bool SaveAssignedTaskUsers(Int32 intTaskId, int intTaskStatus, int[] arrAssignedUsers, int[] arrDesignationUsers) { JGConstant.TaskStatus objTaskStatus = (JGConstant.TaskStatus)intTaskStatus; //if task id is available to save its note and attachement. if (intTaskId != 0) { string strUsersIds = string.Join(",", arrAssignedUsers); // save (insert / delete) assigned users. bool isSuccessful = TaskGeneratorBLL.Instance.SaveTaskAssignedUsers(Convert.ToUInt64(intTaskId), strUsersIds); // send email to selected users. if (strUsersIds.Length > 0) { if (isSuccessful) { // Change task status to assigned = 3. if (objTaskStatus == JGConstant.TaskStatus.Open || objTaskStatus == JGConstant.TaskStatus.Requested) { TaskGeneratorBLL.Instance.UpdateTaskStatus ( new Task() { TaskId = intTaskId, Status = Convert.ToUInt16(JGConstant.TaskStatus.Assigned) } ); } SendEmailToAssignedUsers(intTaskId, strUsersIds); } } // send email to all users of the department as task is assigned to designation, but not to any specific user. else { string strUserIDs = string.Join(",", arrDesignationUsers); SendEmailToAssignedUsers(intTaskId, strUserIDs.TrimEnd(',')); } } return(true); }
protected void gvTasks_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView drTask = e.Row.DataItem as DataRowView; HyperLink hypTask = e.Row.FindControl("hypTask") as HyperLink; Label lblDesignation = e.Row.FindControl("lblDesignation") as Label; Label lblAssignedUser = e.Row.FindControl("lblAssignedUser") as Label; DropDownCheckBoxes ddcbAssignedUser = e.Row.FindControl("ddcbAssignedUser") as DropDownCheckBoxes; LinkButton lbtnRequestStatus = e.Row.FindControl("lbtnRequestStatus") as LinkButton; Literal ltrlStatus = e.Row.FindControl("ltrlStatus") as Literal; Literal ltrlPriority = e.Row.FindControl("ltrlPriority") as Literal; DropDownList ddlStatus = e.Row.FindControl("ddlStatus") as DropDownList; DropDownList ddlPriority = e.Row.FindControl("ddlPriority") as DropDownList; Literal ltrlDueDate = e.Row.FindControl("ltrlDueDate") as Literal; hypTask.Text = drTask["Title"].ToString(); if (hypTask.Text.Length > 55) { hypTask.ToolTip = hypTask.Text; hypTask.Text = hypTask.Text.Substring(0, 55) + ".."; } hypTask.NavigateUrl = "~/sr_app/TaskGenerator.aspx?TaskId=" + drTask["TaskId"].ToString(); lblDesignation.Text = drTask["TaskDesignations"].ToString(); if (lblDesignation.Text.Length > 30) { lblDesignation.ToolTip = lblDesignation.Text; lblDesignation.Text = lblDesignation.Text.Substring(0, 30) + ".."; } lblAssignedUser.Text = drTask["TaskAssignedUsers"].ToString(); if (lblAssignedUser.Text.Length > 30) { lblAssignedUser.ToolTip = lblAssignedUser.Text; lblAssignedUser.Text = lblAssignedUser.Text.Substring(0, 30) + ".."; } ltrlStatus.Text = ((JGConstant.TaskStatus)Convert.ToInt32(drTask["Status"])).ToString(); ddlStatus.DataSource = CommonFunction.GetTaskStatusList(); ddlStatus.DataTextField = "Text"; ddlStatus.DataValueField = "Value"; ddlStatus.DataBind(); //ddlStatus.Items.FindByValue(Convert.ToByte(JGConstant.TaskStatus.SpecsInProgress).ToString()).Enabled = false; SetStatusSelectedValue(ddlStatus, drTask["Status"].ToString()); ddlPriority.DataSource = CommonFunction.GetTaskPriorityList(); ddlPriority.DataTextField = "Text"; ddlPriority.DataValueField = "Value"; ddlPriority.DataBind(); if (!string.IsNullOrEmpty(drTask["TaskPriority"].ToString())) { ddlPriority.SelectedValue = drTask["TaskPriority"].ToString(); ltrlPriority.Text = ((JGConstant.TaskPriority)Convert.ToInt32(drTask["TaskPriority"])).ToString(); } if (!string.IsNullOrEmpty(Convert.ToString(drTask["DueDate"]))) { ltrlDueDate.Text = Convert.ToDateTime(drTask["DueDate"]).ToString("MM-dd-yyyy"); } if (this.IsAdminMode) { #region Admin User if ( ddlStatus.SelectedValue != Convert.ToByte(JGConstant.TaskStatus.Requested).ToString() && ddlStatus.SelectedValue != Convert.ToByte(JGConstant.TaskStatus.InProgress).ToString() && ddlStatus.SelectedValue != Convert.ToByte(JGConstant.TaskStatus.SpecsInProgress).ToString() && ddlStatus.SelectedValue != Convert.ToByte(JGConstant.TaskStatus.Closed).ToString() //&& //string.IsNullOrEmpty(Convert.ToString(drTask["TaskAssignedUsers"])) ) { ddcbAssignedUser.Visible = true; lbtnRequestStatus.Visible = lblAssignedUser.Visible = false; ddcbAssignedUser.Items.Clear(); ddcbAssignedUser.DataSource = TaskGeneratorBLL.Instance.GetInstallUsers(2, Convert.ToString(drTask["TaskDesignations"]).Trim()); ddcbAssignedUser.DataTextField = "FristName"; ddcbAssignedUser.DataValueField = "Id"; ddcbAssignedUser.DataBind(); } else if (ddlStatus.SelectedValue == Convert.ToByte(JGConstant.TaskStatus.Requested).ToString()) { lbtnRequestStatus.Visible = true; ddcbAssignedUser.Visible = lblAssignedUser.Visible = false; string[] arrTaskAssignmentRequest = Convert.ToString(drTask["TaskAssignmentRequestUsers"]).Split(':'); if (arrTaskAssignmentRequest.Length > 1) { lbtnRequestStatus.Text = arrTaskAssignmentRequest[1]; } lbtnRequestStatus.ForeColor = System.Drawing.Color.Red; lbtnRequestStatus.CommandName = "approve-request"; lbtnRequestStatus.CommandArgument = string.Format( "{0}:{1}", drTask["TaskId"].ToString(), arrTaskAssignmentRequest[0] ); } else { ddcbAssignedUser.Visible = true; lblAssignedUser.Visible = lbtnRequestStatus.Visible = false; DataSet dsUsers = TaskGeneratorBLL.Instance.GetInstallUsers(2, Convert.ToString(DataBinder.Eval(e.Row.DataItem, "TaskDesignations")).Trim()); ddcbAssignedUser.Items.Clear(); ddcbAssignedUser.DataSource = dsUsers; ddcbAssignedUser.DataTextField = "FristName"; ddcbAssignedUser.DataValueField = "Id"; ddcbAssignedUser.DataBind(); } ltrlPriority.Visible = false; ddlPriority.Visible = true; ddlPriority.Attributes.Add("TaskId", drTask["TaskId"].ToString()); SetTaskAssignedUsers(Convert.ToString(drTask["TaskAssignedUsers"]), ddcbAssignedUser); // set assigned user selection in dropdown. if (!string.IsNullOrEmpty(drTask["TaskAssignedUserIds"].ToString()) && ddcbAssignedUser.Items.Count > 0) { string[] arrUserIds = drTask["TaskAssignedUserIds"].ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string strId in arrUserIds) { ListItem objListItem = ddcbAssignedUser.Items.FindByValue(strId.Trim()); if (objListItem != null) { objListItem.Selected = true; ddcbAssignedUser.Texts.SelectBoxCaption = objListItem.Text; } } } ddcbAssignedUser.Attributes.Add("TaskId", drTask["TaskId"].ToString()); ddcbAssignedUser.Attributes.Add("TaskStatus", ddlStatus.SelectedValue); #endregion } else { #region Install User string strMyDesignation = Convert.ToString(Session["DesigNew"]).Trim().ToLower(); // show request link when, // task status is open // task assigned to my designation if (ddlStatus.SelectedValue == Convert.ToByte(JGConstant.TaskStatus.Open).ToString() && strMyDesignation == Convert.ToString(drTask["TaskDesignations"]).Trim().ToLower()) { lbtnRequestStatus.Visible = true; ddcbAssignedUser.Visible = lblAssignedUser.Visible = false; lbtnRequestStatus.ForeColor = System.Drawing.Color.Green; lbtnRequestStatus.CommandName = "request"; lbtnRequestStatus.CommandArgument = string.Format( "{0}:{1}", drTask["TaskId"].ToString(), drTask["CreatedBy"].ToString() ); } else { ddcbAssignedUser.Visible = lbtnRequestStatus.Visible = false; lblAssignedUser.Visible = true; } ltrlPriority.Visible = true; ddlPriority.Visible = false; #endregion } string strRowCssClass = string.Empty; if (e.Row.RowState == DataControlRowState.Alternate) { strRowCssClass = "AlternateRow"; } else { strRowCssClass = "FirstRow"; } JGConstant.TaskStatus objTaskStatus = (JGConstant.TaskStatus)Convert.ToByte(drTask["Status"]); JGConstant.TaskPriority?objTaskPriority = null; if ( !string.IsNullOrEmpty(drTask["TaskPriority"].ToString()) && drTask["TaskPriority"].ToString() != "0" ) { objTaskPriority = (JGConstant.TaskPriority)Convert.ToByte(drTask["TaskPriority"]); } strRowCssClass += " " + CommonFunction.GetTaskRowCssClass(objTaskStatus, objTaskPriority); switch (objTaskStatus) { case JGConstant.TaskStatus.Closed: ddcbAssignedUser.Visible = false; ddlStatus.Enabled = false; ddlPriority.Enabled = false; break; case JGConstant.TaskStatus.Deleted: ddcbAssignedUser.Visible = false; ddlStatus.Enabled = false; ddlPriority.Enabled = false; break; } e.Row.CssClass = strRowCssClass; } }