private void UpdateBillRate(DataRow row) { foreach (var timecode in TimeCode.SubList(TimeCode.EnumValueType.Hours)) { decimal?billRate = ProjectWorkClass.GetBillRate(_headerRecord.ProjectId, timecode.MatchId, (string)row[colWorkClass.FieldName]); row[BillRateI(timecode)] = (object)billRate ?? DBNull.Value; if (row[colId.FieldName] != DBNull.Value) { LabourTimeDetail.SqlUpdateBillRate((int)row[colId.FieldName], timecode.MatchId, billRate); } } }
private void CalcOvertime(DataRow row, string colName) { var sqlUpdate = new Action <int, decimal>((timeCodeId, val) => { if (row[colId.FieldName] != DBNull.Value) { if (TimeCode.GetTimeCode(timeCodeId).ValueType == EnumValueType.Hours) { LabourTimeDetail.SqlUpdateHours((int)row[colId.FieldName], timeCodeId, val); } else { LabourTimeDetail.SqlUpdateAmount((int)row[colId.FieldName], timeCodeId, val); } } }); bool handled = false; if ((bool)row[colManual.FieldName] == false) { var ot = OvertimeLimit.GetOvertime(_headerRecord.ProjectId, (int)row[colEmpNum.FieldName]); var regTimeCode = TimeCode.GetTimeCodeList(EnumBillingRateType.Regular).SingleOrDefault(x => colName == EnterHoursI(x)); if (regTimeCode != null && regTimeCode.OvertimeId != null && ot != null) { int? currId = ConvertEx.ToNullable <int>(row[colId.FieldName]); decimal dayHours = LabourTimeEntry.GetDayHours(_headerRecord.ProjectId, (int)row[colEmpNum.FieldName], _headerRecord.LogDate, currId); decimal weekHours = LabourTimeEntry.GetWeekHours(_headerRecord.ProjectId, (int)row[colEmpNum.FieldName], _headerRecord.LogDate, currId); dayHours += ConvertEx.ToNullable <decimal>(row[colName]) ?? 0; weekHours += ConvertEx.ToNullable <decimal>(row[colName]) ?? 0; decimal overHours = ot.Calc(dayHours, weekHours); row[EnterHoursI(regTimeCode.OvertimeId.Value)] = overHours; sqlUpdate(regTimeCode.OvertimeId.Value, overHours); dayHours -= overHours; row[colName] = dayHours; sqlUpdate(regTimeCode.MatchId, dayHours); handled = true; } } if (!handled) { sqlUpdate(int.Parse(colName.Replace(strEnterHours, "")), ConvertEx.ToNullable <decimal>(row[colName]) ?? 0); } }
private void gvLabour_RowUpdated(object sender, RowObjectEventArgs e) { if (gvLabour.IsNewItemRow(e.RowHandle)) { DataRowView row = e.Row as DataRowView; row[colId.FieldName] = LabourTimeEntry.SqlInsert(_headerRecord.Id, (int)row[colEmpNum.FieldName], ConvertEx.ToNullable <int>(row[colChangeOrder.FieldName]), ConvertEx.ToNullable <int>(row[colLevel1Code.FieldName]), ConvertEx.ToNullable <int>(row[colLevel2Code.FieldName]), ConvertEx.ToNullable <int>(row[colLevel3Code.FieldName]), ConvertEx.ToNullable <int>(row[colLevel4Code.FieldName]), (bool)row[colBillable.FieldName], (bool)row[colManual.FieldName], (string)row[colWorkClass.FieldName], ConvertEx.ToNullable <decimal>(row[colIncludedHours.FieldName]), ConvertEx.ToNullable <decimal>(row[colTotalHours.FieldName]), ConvertEx.ToNullable <decimal>(row[colBillAmount.FieldName])); foreach (var timeCode in TimeCode.SubList(EnumValueType.Hours)) { LabourTimeDetail.SqlInsert((int)row[colId.FieldName], timeCode.MatchId, ConvertEx.ToNullable <decimal>(row[BillRateI(timeCode)]), ConvertEx.ToNullable <decimal>(row[EnterHoursI(timeCode)]), null); } foreach (var timeCode in TimeCode.SubList(EnumValueType.Dollars)) { LabourTimeDetail.SqlInsert((int)row[colId.FieldName], timeCode.MatchId, null, null, ConvertEx.ToNullable <decimal>(row[EnterAmountI(timeCode)])); } LemHeader.SqlUpdateSubmitStatus(_headerRecord.Id, EnumSubmitStatus.Open); } }