private void LoadTaskGrid() { Diary.Entity.TaskEntity taskentity = new Diary.Entity.TaskEntity(); taskentity.TaskDate = DateTime.Parse(dtDate.Text); taskentity.FeeEarner = new Guid(cmbFeeEarner.Value.ToString()); //taskentity.CaseId = new Guid(cmbCase.Value.ToString()); DataSet taskCalculateDataSet = currentTask.CalculateTask(taskentity); if (taskCalculateDataSet != null && taskCalculateDataSet.Tables.Count > 0 && taskCalculateDataSet.Tables[0] != null && taskCalculateDataSet.Tables[0].Rows.Count > 0) { string remainingHours = taskCalculateDataSet.Tables[0].Rows[0]["BalanceHours"].ToString(); lblRemainingHours.Text = remainingHours; if (int.Parse(decimal.Parse(remainingHours).ToString("N0")) < 0) { seTotalHours.MaxValue = 50; } //else //{ // seTotalHours.MaxValue = int.Parse(decimal.Parse(remainingHours).ToString("N0")); //} string maximumRecording = taskCalculateDataSet.Tables[0].Rows[0]["TimeRestriction"].ToString(); lblMaximumRecording.Text = maximumRecording; } if (taskCalculateDataSet != null && taskCalculateDataSet.Tables.Count > 0 && taskCalculateDataSet.Tables[1] != null && taskCalculateDataSet.Tables[1].Rows.Count > 0) { gvHistory.Visible = true; dvGridSection.Visible = true; gvHistory.DataSource = taskCalculateDataSet.Tables[1]; gvHistory.DataBind(); } else { dvGridSection.Visible = false; gvHistory.Visible = false; gvHistory.DataSource = null; gvHistory.DataBind(); } }
private bool validateToSave() { bool result = true; decimal maximumRecording = 0; decimal consumedHours = 0; maximumRecording = decimal.Parse(lblMaximumRecording.Text); if (gvHistory.GetTotalSummaryValue(gvHistory.TotalSummary["TotalHours", DevExpress.Data.SummaryItemType.Sum]) != null) { consumedHours = decimal.Parse(gvHistory.GetTotalSummaryValue(gvHistory.TotalSummary["TotalHours", DevExpress.Data.SummaryItemType.Sum]).ToString()); } if (maximumRecording <= consumedHours) { result = false; Master.ShowMessage(Diary.Common.Constant.Message_AllTimeConsumed); return result; } //// Check for over to maximum readin time decimal totalHours = 0; decimal maximumRecordingTime = 0; if (seTotalHours.Text != string.Empty) { totalHours = Convert.ToDecimal(seTotalHours.Text); } maximumRecordingTime = Convert.ToDecimal(maximumRecording); if (totalHours+consumedHours > maximumRecordingTime) { result = false; Master.ShowMessage(Diary.Common.Constant.Message_MoreThanReadingHours); return result; } //// Check start/end time on insert if (hdnTaskId.Value == string.Empty) { Diary.Entity.TaskEntity taskentity = new Diary.Entity.TaskEntity(); taskentity.TaskDate = DateTime.Parse(dtDate.Text); taskentity.CaseId = new Guid(cmbCase.Value.ToString()); taskentity.FeeEarner = new Guid(cmbFeeEarner.Value.ToString()); taskentity.StartTime = DateTime.Parse(teStartTime.Text); taskentity.EndTime = DateTime.Parse(teEndTime.Text); if (currentTask.IsWithinValidTimeFrame(taskentity)) { result = false; Master.ShowMessage(Diary.Common.Constant.Message_TimeNotAllowed); return result; } } //// Check start/end time on update if (hdnTaskId.Value != string.Empty) { Diary.Entity.TaskEntity taskentity = new Diary.Entity.TaskEntity(); taskentity.TaskId = new Guid(hdnTaskId.Value); taskentity.TaskDate = DateTime.Parse(dtDate.Text); taskentity.CaseId = new Guid(cmbCase.Value.ToString()); taskentity.FeeEarner = new Guid(cmbFeeEarner.Value.ToString()); taskentity.StartTime = DateTime.Parse(teStartTime.Text); taskentity.EndTime = DateTime.Parse(teEndTime.Text); if (currentTask.IsWithinValidTimeFrameOnUpdate(taskentity)) { result = false; Master.ShowMessage(Diary.Common.Constant.Message_TimeNotAllowed); return result; } } return result; }
private bool validateToSave() { bool result = true; decimal maximumRecording = 0; decimal consumedHours = 0; maximumRecording = decimal.Parse(lblMaximumRecording.Text); if (gvHistory.GetTotalSummaryValue(gvHistory.TotalSummary["TotalHours", DevExpress.Data.SummaryItemType.Sum]) != null) { consumedHours = decimal.Parse(gvHistory.GetTotalSummaryValue(gvHistory.TotalSummary["TotalHours", DevExpress.Data.SummaryItemType.Sum]).ToString()); } if (maximumRecording <= consumedHours) { result = false; Master.ShowMessage(Diary.Common.Constant.Message_AllTimeConsumed); return(result); } //// Check for over to maximum readin time decimal totalHours = 0; decimal maximumRecordingTime = 0; if (seTotalHours.Text != string.Empty) { totalHours = Convert.ToDecimal(seTotalHours.Text); } maximumRecordingTime = Convert.ToDecimal(maximumRecording); if (totalHours + consumedHours > maximumRecordingTime) { result = false; Master.ShowMessage(Diary.Common.Constant.Message_MoreThanReadingHours); return(result); } //// Check start/end time on insert if (hdnTaskId.Value == string.Empty) { Diary.Entity.TaskEntity taskentity = new Diary.Entity.TaskEntity(); taskentity.TaskDate = DateTime.Parse(dtDate.Text); taskentity.CaseId = new Guid(cmbCase.Value.ToString()); taskentity.FeeEarner = new Guid(cmbFeeEarner.Value.ToString()); taskentity.StartTime = DateTime.Parse(teStartTime.Text); taskentity.EndTime = DateTime.Parse(teEndTime.Text); if (currentTask.IsWithinValidTimeFrame(taskentity)) { result = false; Master.ShowMessage(Diary.Common.Constant.Message_TimeNotAllowed); return(result); } } //// Check start/end time on update if (hdnTaskId.Value != string.Empty) { Diary.Entity.TaskEntity taskentity = new Diary.Entity.TaskEntity(); taskentity.TaskId = new Guid(hdnTaskId.Value); taskentity.TaskDate = DateTime.Parse(dtDate.Text); taskentity.CaseId = new Guid(cmbCase.Value.ToString()); taskentity.FeeEarner = new Guid(cmbFeeEarner.Value.ToString()); taskentity.StartTime = DateTime.Parse(teStartTime.Text); taskentity.EndTime = DateTime.Parse(teEndTime.Text); if (currentTask.IsWithinValidTimeFrameOnUpdate(taskentity)) { result = false; Master.ShowMessage(Diary.Common.Constant.Message_TimeNotAllowed); return(result); } } return(result); }