private void UpdateTheRateExtendLock(int extendDays) { BLL.Company_Alerts bllComAlert = new Company_Alerts(); BLL.LoanAlerts bllAlert = new LoanAlerts(); BLL.Loans bllLoans = new BLL.Loans(); Model.Loans modelLoan = new Model.Loans(); modelLoan = bllLoans.GetModel(FileId); modelLoan.RateLockExpiration = OrgDate.AddDays(extendDays); bllLoans.Update(modelLoan); var comModel = bllComAlert.GetModel(); //todo:确认此处是否这样查询LoanAlerts表中对应当前Loan的记录 //此处应该只能查处一条数据 var alertModelList = bllAlert.GetModelList(string.Format("FileId={0} AND AlertType={1}", FileId, "'Rate Lock'")); if (alertModelList.Count == 0) { return; } //if (extendDays < comModel.RateLockYellowDays || extendDays < comModel.RateLockRedDays) //{ // alertModelList[0].DueDate = OrgDate.AddDays(extendDays); // bllAlert.Update(alertModelList[0]); //} //else if (extendDays > comModel.RateLockYellowDays || extendDays > comModel.RateLockRedDays) //{ // alertModelList[0].DueDate = OrgDate.AddDays(extendDays); // bllAlert.Delete(alertModelList[0].LoanAlertId); //} PageCommon.WriteJs(this, "Update succeeded!", "window.parent.parent.location.href=window.parent.parent.location.href;parent.CloseCurrentWindowHandller();"); }
private void GetTaskDays() { LPWeb.BLL.Company_Alerts bll = new Company_Alerts(); LPWeb.Model.Company_Alerts model = bll.GetModel(); taskRedDays = model.TaskRedDays.Value; taskYellowDays = model.TaskYellowDays.Value; }
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) { #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); }