/// <summary> /// 获得数据列表 /// </summary> public List <LPWeb.Model.LoanTasks> DataTableToList(DataTable dt) { List <LPWeb.Model.LoanTasks> modelList = new List <LPWeb.Model.LoanTasks>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { LPWeb.Model.LoanTasks model; for (int n = 0; n < rowsCount; n++) { model = new LPWeb.Model.LoanTasks(); if (dt.Rows[n]["LoanTaskId"].ToString() != "") { model.LoanTaskId = int.Parse(dt.Rows[n]["LoanTaskId"].ToString()); } if (dt.Rows[n]["FileId"].ToString() != "") { model.FileId = int.Parse(dt.Rows[n]["FileId"].ToString()); } if (dt.Rows[n]["WflTemplId"].ToString() != "") { model.WflTemplId = int.Parse(dt.Rows[n]["WflTemplId"].ToString()); } model.Name = dt.Rows[n]["Name"].ToString(); if (dt.Rows[n]["Due"].ToString() != "") { model.Due = DateTime.Parse(dt.Rows[n]["Due"].ToString()); } if (dt.Rows[n]["Completed"].ToString() != "") { model.Completed = DateTime.Parse(dt.Rows[n]["Completed"].ToString()); } if (dt.Rows[n]["CompletedBy"].ToString() != "") { model.CompletedBy = int.Parse(dt.Rows[n]["CompletedBy"].ToString()); } if (dt.Rows[n]["LastModified"].ToString() != "") { model.LastModified = DateTime.Parse(dt.Rows[n]["LastModified"].ToString()); } modelList.Add(model); } } return(modelList); }
protected void btnSave_Click(object sender, EventArgs e) { string sErrorJs = string.Empty; if (this.Request.QueryString["CloseDialogCodes"] == null) { sErrorJs = "window.parent.RefreshPage();"; } else { sErrorJs = this.Request.QueryString["CloseDialogCodes"] + ";"; } int iStageID = Convert.ToInt32(this.LoanTaskInfo.Rows[0]["LoanStageId"]); int iCurrentUserID = this.CurrUser.iUserID; string sTaskName = string.Empty; if (radTaskList.Checked == true) { sTaskName = this.ddlTaskList.SelectedValue; if (sTaskName == "-- select --") { sTaskName = string.Empty; } } else { sTaskName = this.txtTaskName.Text.Trim(); } string sDesc = this.txtDescription.Text.Trim(); int iOwnerID = Convert.ToInt32(this.ddlOwner.SelectedItem.Value); string sDueDate = this.txtDueDate.Text.Trim(); int iPrerequisiteID = Convert.ToInt32(this.ddlPrerequisite.SelectedItem.Value); //Get task template Calculation Method int iCalculationMethod = 0; if (this.LoanTaskInfo.Rows[0]["TemplTaskId"].ToString() != "" && this.LoanTaskInfo.Rows[0]["TemplTaskId"].ToString() != "0") { LPWeb.BLL.Template_Wfl_Tasks taskTempMgr = new Template_Wfl_Tasks(); LPWeb.Model.Template_Wfl_Tasks taskTempModel = taskTempMgr.GetModel(int.Parse(this.LoanTaskInfo.Rows[0]["TemplTaskId"].ToString())); if (taskTempModel != null) { LPWeb.BLL.Template_Wfl_Stages stageWflMgr = new Template_Wfl_Stages(); LPWeb.Model.Template_Wfl_Stages stageModel = stageWflMgr.GetModel(taskTempModel.WflStageId); if (stageModel != null) { LPWeb.BLL.Template_Workflow templateMgr = new Template_Workflow(); LPWeb.Model.Template_Workflow templateModel = templateMgr.GetModel(stageModel.WflTemplId); if (templateModel != null) { iCalculationMethod = templateModel.CalculationMethod; } if (stageModel.CalculationMethod != null && stageModel.CalculationMethod.Value != 0) { iCalculationMethod = stageModel.CalculationMethod.Value; } } } } int iDaysToEstClose = 0; if (this.txtDaysToEst.Text != string.Empty) { if (iCalculationMethod == 2 && this.txtDaysAfterCreation.Text != string.Empty) { iDaysToEstClose = 0; this.txtDaysToEst.Text = ""; } else { iDaysToEstClose = Convert.ToInt32(this.txtDaysToEst.Text); } } int iDaysAfterCreation = 0; if (this.txtDaysAfterCreation.Text != string.Empty) { if (iCalculationMethod == 1 && this.txtDaysToEst.Text != string.Empty) { iDaysAfterCreation = -1; this.txtDaysAfterCreation.Text = ""; } else { iDaysAfterCreation = Convert.ToInt32(this.txtDaysAfterCreation.Text); } } int iDaysDueAfterPre = 0; if (this.txtDaysDueAfter.Text != string.Empty) { iDaysDueAfterPre = Convert.ToInt32(this.txtDaysDueAfter.Text); } int iWarningEmailID = Convert.ToInt32(this.ddlWarningEmail.SelectedItem.Value); int iOverdueEmailID = Convert.ToInt32(this.ddlOverdueEmail.SelectedItem.Value); // 原Loan Stage ID int iOldStageID = string.IsNullOrEmpty(ddlStage.SelectedValue) ? Convert.ToInt32(this.LoanTaskInfo.Rows[0]["LoanStageId"]) : Convert.ToInt32(ddlStage.SelectedValue); //CR54 this.iCurrentLoanStageId; //Convert.ToInt32(this.LoanTaskInfo.Rows[0]["LoanStageId"]); #region 检查任务名称重复 if (string.IsNullOrEmpty(sTaskName) || sTaskName.Trim() == string.Empty) { PageCommon.AlertMsg(this, "The task name cannot be blank."); return; } var loanInfo = this.LoanManager.GetModel(this.iLoanID); if (loanInfo == null || loanInfo.Status != "Prospect") //CR54 当为Prospect时检查重复 { bool bIsExist = this.LoanTaskManager.IsLoanTaskExists_Update(this.iLoanID, this.iTaskID, sTaskName); if (bIsExist == true) { PageCommon.AlertMsg(this, "The task name is already taken."); return; } } LPWeb.Model.LoanTasks taskModel = new LPWeb.Model.LoanTasks(); taskModel.LoanTaskId = iTaskID; taskModel.Name = sTaskName.Trim(); taskModel.Desc = sDesc.Trim(); taskModel.LoanStageId = iStageID; if (iStageID == iOldStageID || iOldStageID <= 0) { taskModel.OldLoanStageId = 0; } else { taskModel.OldLoanStageId = iOldStageID; } taskModel.Owner = iOwnerID; taskModel.ModifiedBy = iCurrentUserID; taskModel.LastModified = DateTime.Now; taskModel.FileId = iLoanID; if (string.IsNullOrEmpty(sDueDate)) { taskModel.Due = DateTime.MinValue; } else { taskModel.Due = DateTime.Parse(sDueDate); } string sDueTime = this.ddlDueTime_hour.Text + ":" + this.ddlDueTime_min.Text; sDueTime = sDueTime.Replace("am", "").Replace("pm", ""); DateTime DTN = DateTime.Now; string sDueTime_Span = null; TimeSpan DueTime = new TimeSpan(); if (sDueTime == string.Empty) { taskModel.DueTime = null; } else { taskModel.DueTime = null; if (DateTime.TryParse(sDueTime, out DTN) == true) { sDueTime_Span = DTN.ToString("HH:mm"); if (TimeSpan.TryParse(sDueTime_Span, out DueTime) == true) { taskModel.DueTime = DueTime; } } } taskModel.DaysDueFromEstClose = (short)iDaysToEstClose; taskModel.DaysFromCreation = (short)iDaysAfterCreation; taskModel.PrerequisiteTaskId = iPrerequisiteID; taskModel.DaysDueAfterPrerequisite = (short)iDaysDueAfterPre; taskModel.WarningEmailId = iWarningEmailID; taskModel.OverdueEmailId = iOverdueEmailID; taskModel.ExternalViewing = false; if (this.chkCompleted.Checked == true) { taskModel.Completed = DateTime.Now; taskModel.CompletedBy = iCurrentUserID; } #endregion // update bool bIsSuccess1 = LPWeb.BLL.WorkflowManager.UpdateTask(taskModel, this.txtDaysToEst.Text.Trim(), this.txtDaysAfterCreation.Text.Trim(), this.txtDaysDueAfter.Text.Trim(), this.txtDaysDueAfterPrevStage.Text.Trim()); if (bIsSuccess1 == true) { SaveCompletetionEmails(iTaskID); #region completed if (chkCompleted.Checked == true) { string sResult = this.CompleteTask(this.iTaskID); if (sResult != string.Empty) { this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Failed", "$('#divContainer').hide();alert('Failed to complete task.');" + sErrorJs, true); } } #endregion // save and create if (((Button)sender).Text == "Save and Create Another") { this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Redirect", "$('#divContainer').hide();alert('Saved successfully.');window.parent.CloseDialog_EditTask();window.parent.ShowDialog_AddTask();", true); } else { this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Success", "$('#divContainer').hide();alert('Saved successfully.');" + sErrorJs, true); } } else { this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Failed", "$('#divContainer').hide();alert('Failed to save the record.');" + sErrorJs, true); } }
protected int CreateLoanTask(int iFileID, string sTaskName, int TaskOwnerId, string sDueDate, string sDueTime, int iLoanStageID) { #region create new task LoanTasks LoanTaskManager = new LoanTasks(); // add task LPWeb.Model.LoanTasks taskModel = new LPWeb.Model.LoanTasks(); taskModel.LoanTaskId = 0; taskModel.FileId = iFileID; taskModel.Name = sTaskName; if (sDueDate == string.Empty) { taskModel.Due = null; } else { taskModel.Due = DateTime.Parse(sDueDate); } DateTime DTN = DateTime.Now; string sDueTime_Span = null; TimeSpan DueTime = new TimeSpan(); if (sDueTime == string.Empty) { taskModel.DueTime = null; } else { taskModel.DueTime = null; if (DateTime.TryParse(sDueTime, out DTN) == true) { sDueTime_Span = DTN.ToString("HH:mm"); if (TimeSpan.TryParse(sDueTime_Span, out DueTime) == true) { taskModel.DueTime = DueTime; } } } taskModel.LoanStageId = iLoanStageID; taskModel.OldLoanStageId = 0; taskModel.Owner = TaskOwnerId; taskModel.ModifiedBy = CurrUser.iUserID; taskModel.LastModified = DateTime.Now; taskModel.DaysDueFromEstClose = 0; taskModel.DaysFromCreation = 0; taskModel.PrerequisiteTaskId = 0; taskModel.DaysDueAfterPrerequisite = 0; taskModel.CompletionEmailId = 0; taskModel.WarningEmailId = 0; taskModel.OverdueEmailId = 0; taskModel.SequenceNumber = 1; taskModel.ExternalViewing = false; int iLoanTaskId = LPWeb.BLL.WorkflowManager.AddTask_Lead(taskModel); #endregion return(iLoanTaskId); }
protected void btnSave_Click(object sender, EventArgs e) { int Valid_LoanStageId = 0; string sErrorJs = string.Empty; if (this.Request.QueryString["CloseDialogCodes"] == null) { sErrorJs = "window.parent.RefreshPage();"; } else { sErrorJs = this.Request.QueryString["CloseDialogCodes"] + ";"; } #region 获取数据 DataTable LoanStages = this.LoanManager.GetLoanStages(this.iLoanID); if (LoanStages == null || LoanStages.Rows.Count <= 0) { this.iCurrentLoanStageId = GetTaskStageID(this.iLoanID); if ((this.iCurrentLoanStageId == null) || (this.iCurrentLoanStageId <= 0)) { this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Failed0", "$('#divContainer').hide();alert('The loan does not have any stage to add the task to.');" + sErrorJs, true); return; } } int iStageID = string.IsNullOrEmpty(ddlStage.SelectedValue) ? this.iCurrentLoanStageId : Convert.ToInt32(ddlStage.SelectedValue); //CR54 this.iCurrentLoanStageId; string sTaskName = string.Empty; if (radTaskList.Checked == true) { sTaskName = this.ddlTaskList.SelectedValue; if (sTaskName == "-- select --") { sTaskName = string.Empty; } } else { sTaskName = this.txtTaskName.Text.Trim(); } string sDesc = this.txtDescription.Text.Trim(); int iOwnerID = Convert.ToInt32(this.ddlOwner.SelectedItem.Value); string sDueDate = this.txtDueDate.Text.Trim(); int iDaysToEstClose = 0; if (this.txtDaysToEst.Text != string.Empty) { iDaysToEstClose = Convert.ToInt32(this.txtDaysToEst.Text); } int iDaysAfterCreation = 0; if (this.txtDaysAfterCreation.Text != string.Empty) { iDaysAfterCreation = Convert.ToInt32(this.txtDaysAfterCreation.Text); } //int iDaysDueAfterPrevStage = 0; //if (this.txtDaysDueAfterPrevStage.Text != string.Empty) //{ // iDaysDueAfterPrevStage = Convert.ToInt32(this.txtDaysDueAfterPrevStage.Text.Trim()); //} int iPrerequisiteID = Convert.ToInt32(this.ddlPrerequisite.SelectedItem.Value); int iDaysDueAfterPre = 0; if (this.txtDaysDueAfter.Text != string.Empty) { iDaysDueAfterPre = Convert.ToInt32(this.txtDaysDueAfter.Text); } int iCompletionEmailID = 0; int iWarningEmailID = Convert.ToInt32(this.ddlWarningEmail.SelectedItem.Value); int iOverdueEmailID = Convert.ToInt32(this.ddlOverdueEmail.SelectedItem.Value); bool bExternalViewing = false; #endregion #region 检查任务名称重复 if (string.IsNullOrEmpty(sTaskName) || sTaskName.Trim() == string.Empty) { PageCommon.AlertMsg(this, "The task name cannot be blank."); return; } var loanInfo = this.LoanManager.GetModel(this.iLoanID); if (loanInfo == null || loanInfo.Status != "Prospect") //CR54 当为Prospect时检查重复 { bool bIsExist = this.LoanTaskManager.IsLoanTaskExists_Insert(this.iLoanID, sTaskName); if (bIsExist == true) { this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Duplicate", "$('#divContainer').hide();alert('The task name is already taken.');$('#divContainer').show();", true); return; } } #endregion #region Invoke Workflow Manager checking and task API bool StageCompleted = LPWeb.BLL.WorkflowManager.StageCompleted(iStageID); // get next seq num int iNextSeq = LoanTaskManager.GetNextSequenceNum(this.iLoanID); // add task LPWeb.Model.LoanTasks taskModel = new LPWeb.Model.LoanTasks(); taskModel.LoanTaskId = 0; taskModel.FileId = iLoanID; taskModel.Name = sTaskName.Trim(); taskModel.Desc = sDesc.Trim(); taskModel.LoanStageId = iStageID; taskModel.OldLoanStageId = 0; taskModel.Owner = iOwnerID; taskModel.ModifiedBy = CurrUser.iUserID; taskModel.LastModified = DateTime.Now; taskModel.FileId = iLoanID; if (string.IsNullOrEmpty(sDueDate)) { taskModel.Due = DateTime.MinValue; } else { taskModel.Due = DateTime.Parse(sDueDate); } string sDueTime = ddlDueTime_hour.Text + ":" + ddlDueTime_min.Text; //this.txtDueTime.Text.Trim(); CR54 sDueTime = sDueTime.Replace("am", "").Replace("pm", ""); DateTime DTN = DateTime.Now; string sDueTime_Span = null; TimeSpan DueTime = new TimeSpan(); if (sDueTime == string.Empty) { taskModel.DueTime = null; } else { taskModel.DueTime = null; if (DateTime.TryParse(sDueTime, out DTN) == true) { sDueTime_Span = DTN.ToString("HH:mm"); if (TimeSpan.TryParse(sDueTime_Span, out DueTime) == true) { taskModel.DueTime = DueTime; } } } taskModel.DaysDueFromEstClose = (short)iDaysToEstClose; taskModel.DaysFromCreation = (short)iDaysAfterCreation; taskModel.PrerequisiteTaskId = iPrerequisiteID; taskModel.DaysDueAfterPrerequisite = (short)iDaysDueAfterPre; taskModel.CompletionEmailId = iCompletionEmailID; taskModel.WarningEmailId = iWarningEmailID; taskModel.OverdueEmailId = iOverdueEmailID; taskModel.SequenceNumber = (short)iNextSeq; taskModel.ExternalViewing = bExternalViewing; #endregion // create task int iLoanTaskId = LPWeb.BLL.WorkflowManager.AddTask(taskModel, this.txtDaysToEst.Text.Trim(), this.txtDaysAfterCreation.Text.Trim(), this.txtDaysDueAfter.Text.Trim(), txtDaysDueAfterPrevStage.Text.Trim()); if (iLoanTaskId > 0) { SaveCompletetionEmails(iLoanTaskId); string Notes = txtNotes.Text; this.CreateLoanNotes(taskModel.FileId, iLoanTaskId, Notes); //gdc CR40 try { LPWeb.BLL.Company_Alerts companyAlertBLL = new Company_Alerts(); LPWeb.Model.Company_Alerts modelAlert = companyAlertBLL.GetModel(); if (modelAlert != null && modelAlert.SendEmailCustomTasks == true && modelAlert.CustomTaskEmailTemplId > 0) { SaveOKAndSendEmail(modelAlert, iLoanTaskId); } } catch { } //gdc CR40 END } else { this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Failed", "$('#divContainer').hide();alert('Failed to save the record.');" + sErrorJs, true); } #region update point file stage if (StageCompleted) { string sError = LoanTaskCommon.UpdatePointFileStage(this.iLoanID, this.CurrUser.iUserID, iStageID); // if failed //if (sError != string.Empty) //{ // this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Failed0", "$('#divContainer').hide();alert('Added task successfully but failed to update stage date in Point.');$('#divContainer').show();", true); // return; //} } #endregion #region completed if (chkCompleted.Checked == true) { string sResult = this.CompleteTask(iLoanTaskId); if (sResult != string.Empty) { this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Failed", "$('#divContainer').hide();alert('Failed to complete task.');" + sErrorJs, true); } } #endregion // success if (((Button)sender).Text == "Save and Create Another") { this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Redirect", "$('#divContainer').hide();alert('Added task successfully.');window.location.href=window.location.href;", true); } else { this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Success", "$('#divContainer').hide();alert('Added task successfully.');" + sErrorJs, true); } }
protected void btnSave_Click(object sender, EventArgs e) { int iStageID = Convert.ToInt32(this.ddlStage.SelectedItem.Value); #region Update Loan Stage of Point File DataTable SelectedStageInfo = this.LoanManager.GetLoanStage(" and LoanStageId=" + iStageID); string sStageCompletedDate = SelectedStageInfo.Rows[0]["Completed"].ToString(); if (sStageCompletedDate != string.Empty) { bool bIsSuccess = true; // invoke PointManager.UpdateLoanStage() if (bIsSuccess == false) { PageCommon.AlertMsg(this, "Failed to update status date in Point."); return; } } #endregion LoginUser CurrentUser = new LoginUser(); int iCurrentUserID = CurrentUser.iUserID; string sTaskName = this.txtTaskName.Text.Trim(); int iOwnerID = Convert.ToInt32(this.ddlOwner.SelectedItem.Value); string sDueDate = this.txtDueDate.Text.Trim(); int iPrerequisiteID = Convert.ToInt32(this.ddlPrerequisite.SelectedItem.Value); //Get task template Calculation Method int iCalculationMethod = 0; if (this.LoanTaskInfo.Rows[0]["TemplTaskId"].ToString() != "" && this.LoanTaskInfo.Rows[0]["TemplTaskId"].ToString() != "0") { LPWeb.BLL.Template_Wfl_Tasks taskTempMgr = new Template_Wfl_Tasks(); LPWeb.Model.Template_Wfl_Tasks taskTempModel = taskTempMgr.GetModel(int.Parse(this.LoanTaskInfo.Rows[0]["TemplTaskId"].ToString())); if (taskTempModel != null) { LPWeb.BLL.Template_Wfl_Stages stageWflMgr = new Template_Wfl_Stages(); LPWeb.Model.Template_Wfl_Stages stageModel = stageWflMgr.GetModel(taskTempModel.WflStageId); if (stageModel != null) { LPWeb.BLL.Template_Workflow templateMgr = new Template_Workflow(); LPWeb.Model.Template_Workflow templateModel = templateMgr.GetModel(stageModel.WflTemplId); if (templateModel != null) { iCalculationMethod = templateModel.CalculationMethod; } if (stageModel.CalculationMethod != null && stageModel.CalculationMethod.Value != 0) { iCalculationMethod = stageModel.CalculationMethod.Value; } } } } int iDaysToEstClose = 0; if (this.txtDaysToEst.Text != string.Empty) { if (iCalculationMethod == 2 && this.txtDaysAfterCreation.Text != string.Empty) { iDaysToEstClose = 0; this.txtDaysToEst.Text = ""; } else { iDaysToEstClose = Convert.ToInt32(this.txtDaysToEst.Text); } } int iDaysAfterCreation = 0; if (this.txtDaysAfterCreation.Text != string.Empty) { if (iCalculationMethod == 1 && this.txtDaysToEst.Text != string.Empty) { iDaysAfterCreation = -1; this.txtDaysAfterCreation.Text = ""; } else { iDaysAfterCreation = Convert.ToInt32(this.txtDaysAfterCreation.Text); } } int iDaysDueAfterPre = 0; if (this.txtDaysDueAfter.Text != string.Empty) { iDaysDueAfterPre = Convert.ToInt32(this.txtDaysDueAfter.Text); } //int iDaysDueAfterPrevStage = 0; //if (this.txtDaysDueAfterPrevStage.Text != string.Empty) //{ // iDaysDueAfterPrevStage = Convert.ToInt32(this.txtDaysDueAfterPrevStage.Text.Trim()); //} int iCompletionEmailID = Convert.ToInt32(this.ddlCompletionEmail.SelectedItem.Value); int iWarningEmailID = Convert.ToInt32(this.ddlWarningEmail.SelectedItem.Value); int iOverdueEmailID = Convert.ToInt32(this.ddlOverdueEmail.SelectedItem.Value); // 原Loan Stage ID int iOldStageID = Convert.ToInt32(this.LoanTaskInfo.Rows[0]["LoanStageId"]); #region 检查任务名称重复 if (string.IsNullOrEmpty(sTaskName) || sTaskName.Trim() == string.Empty) { PageCommon.AlertMsg(this, "The task name cannot be blank."); return; } bool bIsExist = this.LoanTaskManager.IsLoanTaskExists_Update(this.iLoanID, this.iTaskID, sTaskName); if (bIsExist == true) { PageCommon.AlertMsg(this, "The task name is already taken."); return; } LPWeb.Model.LoanTasks taskModel = new LPWeb.Model.LoanTasks(); taskModel.LoanTaskId = iTaskID; taskModel.Name = sTaskName.Trim(); taskModel.LoanStageId = iStageID; if (iStageID == iOldStageID || iOldStageID <= 0) { taskModel.OldLoanStageId = 0; } else { taskModel.OldLoanStageId = iOldStageID; } taskModel.Owner = iOwnerID; taskModel.ModifiedBy = iCurrentUserID; taskModel.LastModified = DateTime.Now; taskModel.FileId = iLoanID; if (string.IsNullOrEmpty(sDueDate)) { taskModel.Due = DateTime.MinValue; } else { taskModel.Due = DateTime.Parse(sDueDate); } taskModel.DaysDueFromEstClose = (short)iDaysToEstClose; taskModel.DaysFromCreation = (short)iDaysAfterCreation; taskModel.PrerequisiteTaskId = iPrerequisiteID; taskModel.DaysDueAfterPrerequisite = (short)iDaysDueAfterPre; taskModel.CompletionEmailId = iCompletionEmailID; taskModel.WarningEmailId = iWarningEmailID; taskModel.OverdueEmailId = iOverdueEmailID; taskModel.ExternalViewing = chbExternalViewing.Checked; //taskModel.DaysDueAfterPrevStage = (short)iDaysDueAfterPrevStage; #endregion // update //bool bIsSuccess1 = this.LoanTaskManager.UpdateLoanTask(this.iTaskID, sTaskName, sDueDate, iCurrentUserID, iOwnerID, iStageID, iPrerequisiteID, iDaysToEstClose, iDaysDueAfterPre, iWarningEmailID, iOverdueEmailID, iCompletionEmailID, iOldStageID); // we need to invoke Workflow Manager UpdateTask in order to set up everything correctly! //bool bIsSuccess1 = LPWeb.BLL.WorkflowManager.UpdateTask(this.iTaskID, sTaskName, sDueDate, iCurrentUserID, iOwnerID, iStageID, iPrerequisiteID, iDaysToEstClose, iDaysDueAfterPre, iWarningEmailID, iOverdueEmailID, iCompletionEmailID, iOldStageID); bool bIsSuccess1 = LPWeb.BLL.WorkflowManager.UpdateTask(taskModel, this.txtDaysToEst.Text.Trim(), this.txtDaysAfterCreation.Text.Trim(), this.txtDaysDueAfter.Text.Trim(), this.txtDaysDueAfterPrevStage.Text.Trim()); if (bIsSuccess1 == true) { SaveCompletetionEmails(iTaskID); this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Success", "$('#divContainer').hide();alert('Saved successfully.');window.parent.RefreshPage();", true); } else { this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Failed", "$('#divContainer').hide();alert('Failed to save the record.');window.parent.RefreshPage();", true); } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(LPWeb.Model.LoanTasks model) { dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(LPWeb.Model.LoanTasks model) { return(dal.Add(model)); }
protected void btnSave_Click(object sender, EventArgs e) { #region 获取数据 DataTable LoanStages = this.LoanManager.GetLoanStages(this.iLoanID); if (LoanStages == null || LoanStages.Rows.Count <= 0) { this.iCurrentLoanStageId = GetTaskStageID(this.iLoanID); if ((this.iCurrentLoanStageId == null) || (this.iCurrentLoanStageId <= 0)) { this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Failed0", "$('#divContainer').hide();alert('The loan does not have any stage to add the task to.');window.parent.RefreshPage();", true); return; } } //int iStageID = Convert.ToInt32(this.ddlStage.SelectedItem.Value); int iStageID = string.IsNullOrEmpty(ddlStage.SelectedValue) ? this.iCurrentLoanStageId : Convert.ToInt32(ddlStage.SelectedValue); //CR54 this.iCurrentLoanStageId; string sTaskName = this.txtTaskName.Text.Trim(); int iOwnerID = Convert.ToInt32(this.ddlOwner.SelectedItem.Value); string sDueDate = this.txtDueDate.Text.Trim(); int iDaysToEstClose = 0; if (this.txtDaysToEst.Text != string.Empty) { iDaysToEstClose = Convert.ToInt32(this.txtDaysToEst.Text); } int iDaysAfterCreation = 0; if (this.txtDaysAfterCreation.Text != string.Empty) { iDaysAfterCreation = Convert.ToInt32(this.txtDaysAfterCreation.Text); } //int iDaysDueAfterPrevStage = 0; //if (this.txtDaysDueAfterPrevStage.Text != string.Empty) //{ // iDaysDueAfterPrevStage = Convert.ToInt32(this.txtDaysDueAfterPrevStage.Text.Trim()); //} int iPrerequisiteID = Convert.ToInt32(this.ddlPrerequisite.SelectedItem.Value); int iDaysDueAfterPre = 0; if (this.txtDaysDueAfter.Text != string.Empty) { iDaysDueAfterPre = Convert.ToInt32(this.txtDaysDueAfter.Text); } int iCompletionEmailID = Convert.ToInt32(this.ddlCompletionEmail.SelectedItem.Value); int iWarningEmailID = Convert.ToInt32(this.ddlWarningEmail.SelectedItem.Value); int iOverdueEmailID = Convert.ToInt32(this.ddlOverdueEmail.SelectedItem.Value); bool bExternalViewing = chbExternalViewing.Checked; #endregion #region 检查任务名称重复 if (string.IsNullOrEmpty(sTaskName) || sTaskName.Trim() == string.Empty) { PageCommon.AlertMsg(this, "The task name cannot be blank."); return; } bool bIsExist = this.LoanTaskManager.IsLoanTaskExists_Insert(this.iLoanID, sTaskName); if (bIsExist == true) { this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Duplicate", "$('#divContainer').hide();alert('The task name is already taken.');$('#divContainer').show();", true); return; } #endregion #region Invoke Workflow Manager checking and task API bool StageCompleted = LPWeb.BLL.WorkflowManager.StageCompleted(iStageID); // get next seq num int iNextSeq = LoanTaskManager.GetNextSequenceNum(this.iLoanID); // add task LPWeb.Model.LoanTasks taskModel = new LPWeb.Model.LoanTasks(); taskModel.LoanTaskId = 0; taskModel.FileId = iLoanID; taskModel.Name = sTaskName.Trim(); taskModel.LoanStageId = iStageID; taskModel.OldLoanStageId = 0; taskModel.Owner = iOwnerID; taskModel.ModifiedBy = CurrUser.iUserID; taskModel.LastModified = DateTime.Now; taskModel.FileId = iLoanID; if (string.IsNullOrEmpty(sDueDate)) { taskModel.Due = DateTime.MinValue; } else { taskModel.Due = DateTime.Parse(sDueDate); } taskModel.DaysDueFromEstClose = (short)iDaysToEstClose; taskModel.DaysFromCreation = (short)iDaysAfterCreation; taskModel.PrerequisiteTaskId = iPrerequisiteID; taskModel.DaysDueAfterPrerequisite = (short)iDaysDueAfterPre; taskModel.CompletionEmailId = iCompletionEmailID; taskModel.WarningEmailId = iWarningEmailID; taskModel.OverdueEmailId = iOverdueEmailID; taskModel.SequenceNumber = (short)iNextSeq; taskModel.ExternalViewing = bExternalViewing; #endregion // update //bool bIsSuccess1 = this.LoanTaskManager.UpdateLoanTask(this.iTaskID, sTaskName, sDueDate, iCurrentUserID, iOwnerID, iStageID, iPrerequisiteID, iDaysToEstClose, iDaysDueAfterPre, iWarningEmailID, iOverdueEmailID, iCompletionEmailID, iOldStageID); // we need to invoke Workflow Manager UpdateTask in order to set up everything correctly! //bool bIsSuccess1 = LPWeb.BLL.WorkflowManager.UpdateTask(this.iTaskID, sTaskName, sDueDate, iCurrentUserID, iOwnerID, iStageID, iPrerequisiteID, iDaysToEstClose, iDaysDueAfterPre, iWarningEmailID, iOverdueEmailID, iCompletionEmailID, iOldStageID); int iLoanTaskId = LPWeb.BLL.WorkflowManager.AddTask(taskModel, this.txtDaysToEst.Text.Trim(), this.txtDaysAfterCreation.Text.Trim(), this.txtDaysDueAfter.Text.Trim(), txtDaysDueAfterPrevStage.Text.Trim()); if (iLoanTaskId > 0) { SaveCompletetionEmails(iLoanTaskId); //gdc CR40 try { LPWeb.BLL.Company_Alerts companyAlertBLL = new Company_Alerts(); LPWeb.Model.Company_Alerts modelAlert = companyAlertBLL.GetModel(); if (modelAlert != null && modelAlert.SendEmailCustomTasks == true && modelAlert.CustomTaskEmailTemplId > 0) { SaveOKAndSendEmail(modelAlert, iLoanTaskId); } } catch { } //gdc CR40 END this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Success", "$('#divContainer').hide();alert('Saved successfully.');window.parent.RefreshPage();", true); } else { this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Failed", "$('#divContainer').hide();alert('Failed to save the record.');window.parent.RefreshPage();", true); } //LoanTaskManager.InsertLoanTask(this.iLoanID, sTaskName, sDueDate, iOwnerID, iStageID, iPrerequisiteID, iNextSeq, iDaysToEstClose, iDaysDueAfterPre, iWarningEmailID, iOverdueEmailID, iCompletionEmailID); #region update point file stage if (StageCompleted) { string sError = LoanTaskCommon.UpdatePointFileStage(this.iLoanID, this.CurrUser.iUserID, iStageID); // if failed if (sError != string.Empty) { this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Failed0", "$('#divContainer').hide();alert('Added task successfully but failed to update stage date in Point.');$('#divContainer').show();", true); return; } } #endregion // success this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Success", "$('#divContainer').hide();alert('Added task successfully.');window.parent.RefreshPage();", true); }