/// <summary> /// Save all Other Costs Costing Sheet /// </summary> /// <param name="companyId">companyId</param> /// <param name="costingSheetId">costingSheetId</param> public void Save(int companyId, int costingSheetId) { ProjectCostingSheetInformationTDS otherCostsInformationChanges = (ProjectCostingSheetInformationTDS)Data.GetChanges(); if (otherCostsInformationChanges.OtherCostsInformation.Rows.Count > 0) { ProjectCostingSheetInformationOtherCostsInformationGateway projectCostingSheetInformationOtherCostsInformationGateway = new ProjectCostingSheetInformationOtherCostsInformationGateway(otherCostsInformationChanges); foreach (ProjectCostingSheetInformationTDS.OtherCostsInformationRow row in (ProjectCostingSheetInformationTDS.OtherCostsInformationDataTable)otherCostsInformationChanges.OtherCostsInformation) { // Insert new costing sheet Other Costs if ((!row.Deleted) && (!row.InDatabase)) { ProjectCostingSheetOtherCosts otherCosts = new ProjectCostingSheetOtherCosts(null); otherCosts.InsertDirect(costingSheetId, row.RefID, row.Work_, row.Function_, row.Description, row.UnitOfMeasurement, row.Quantity, row.CostCad, row.TotalCostCad, row.CostUsd, row.TotalCostUsd, row.Deleted, row.COMPANY_ID, row.StartDate, row.EndDate); } // Update costing sheet Other Costs if ((!row.Deleted) && (row.InDatabase)) { int refId = row.RefID; bool deleted = false; //original values string originalWork_ = projectCostingSheetInformationOtherCostsInformationGateway.GetWork_Original(costingSheetId, refId); string originalFunction = projectCostingSheetInformationOtherCostsInformationGateway.GetFunction_Original(costingSheetId, refId); string originalDescription = projectCostingSheetInformationOtherCostsInformationGateway.GetDescriptionOriginal(costingSheetId, refId); string originalUnitOfMeasurement = projectCostingSheetInformationOtherCostsInformationGateway.GetUnitOfMeasurementOriginal(costingSheetId, refId); double originalQuantity = projectCostingSheetInformationOtherCostsInformationGateway.GetQuantityOriginal(costingSheetId, refId); decimal originalCostCad = projectCostingSheetInformationOtherCostsInformationGateway.GetCostCadOriginal(costingSheetId, refId); decimal originalTotalCostCad = projectCostingSheetInformationOtherCostsInformationGateway.GetTotalCostCadOriginal(costingSheetId, refId); decimal originalCostUsd = projectCostingSheetInformationOtherCostsInformationGateway.GetCostUsdOriginal(costingSheetId, refId); decimal originalTotalCostUsd = projectCostingSheetInformationOtherCostsInformationGateway.GetTotalCostUsdOriginal(costingSheetId, refId); DateTime originalStartDate = projectCostingSheetInformationOtherCostsInformationGateway.GetStartDateOriginal(costingSheetId, refId); DateTime originalEndDate = projectCostingSheetInformationOtherCostsInformationGateway.GetEndDateOriginal(costingSheetId, refId); //original values string newWork_ = projectCostingSheetInformationOtherCostsInformationGateway.GetWork_(costingSheetId, refId); string newFunction = projectCostingSheetInformationOtherCostsInformationGateway.GetFunction_(costingSheetId, refId); string newDescription = projectCostingSheetInformationOtherCostsInformationGateway.GetDescription(costingSheetId, refId); string newUnitOfMeasurement = projectCostingSheetInformationOtherCostsInformationGateway.GetUnitOfMeasurement(costingSheetId, refId); double newQuantity = projectCostingSheetInformationOtherCostsInformationGateway.GetQuantity(costingSheetId, refId); decimal newCostCad = projectCostingSheetInformationOtherCostsInformationGateway.GetCostCad(costingSheetId, refId); decimal newTotalCostCad = projectCostingSheetInformationOtherCostsInformationGateway.GetTotalCostCad(costingSheetId, refId); decimal newCostUsd = projectCostingSheetInformationOtherCostsInformationGateway.GetCostUsd(costingSheetId, refId); decimal newTotalCostUsd = projectCostingSheetInformationOtherCostsInformationGateway.GetTotalCostUsd(costingSheetId, refId); DateTime newStartDate = projectCostingSheetInformationOtherCostsInformationGateway.GetStartDate(costingSheetId, refId); DateTime newEndDate = projectCostingSheetInformationOtherCostsInformationGateway.GetEndDate(costingSheetId, refId); ProjectCostingSheetOtherCosts otherCosts = new ProjectCostingSheetOtherCosts(null); otherCosts.UpdateDirect(costingSheetId, refId, originalWork_, originalFunction, originalDescription, originalUnitOfMeasurement, originalQuantity, originalCostCad, originalTotalCostCad, originalCostUsd, originalTotalCostUsd, deleted, companyId, originalStartDate, originalEndDate, newWork_, newFunction, newDescription, newUnitOfMeasurement, newQuantity, newCostCad, newTotalCostCad, newCostUsd, newTotalCostUsd, deleted, companyId, newStartDate, newEndDate); } // Delete costing sheet Other Costs if ((row.Deleted) && (row.InDatabase)) { ProjectCostingSheetOtherCosts otherCosts = new ProjectCostingSheetOtherCosts(null); otherCosts.DeleteDirect(row.CostingSheetID, row.RefID, row.COMPANY_ID); } } } }
protected void grdOtherCosts_RowDataBound(object sender, GridViewRowEventArgs e) { // Edit items if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Edit) || (e.Row.RowState == (DataControlRowState.Edit | DataControlRowState.Alternate)))) { int costingSheetId = Int32.Parse(((Label)e.Row.FindControl("lblCostingSheetIDEdit")).Text.Trim()); int refId = Int32.Parse(((Label)e.Row.FindControl("lblRefIDEdit")).Text.Trim()); ProjectCostingSheetInformationOtherCostsInformationGateway projectCostingSheetInformationOtherCostsInformationGateway = new ProjectCostingSheetInformationOtherCostsInformationGateway(projectCostingSheetInformationTDS); string unitOfMeasurement = projectCostingSheetInformationOtherCostsInformationGateway.GetUnitOfMeasurement(costingSheetId, refId); ((DropDownList)e.Row.FindControl("ddlUnitOfMeasurementOthersEdit")).SelectedValue = unitOfMeasurement; ((RadDatePicker)e.Row.FindControl("hdfFrom")).SelectedDate = Convert.ToDateTime(hdfFromDate.Value); ((RadDatePicker)e.Row.FindControl("hdfTo")).SelectedDate = Convert.ToDateTime(hdfToDate.Value); } // Footer Item if (e.Row.RowType == DataControlRowType.Footer) { ((RadDatePicker)e.Row.FindControl("hdfFrom")).SelectedDate = Convert.ToDateTime(hdfFromDate.Value); ((RadDatePicker)e.Row.FindControl("hdfTo")).SelectedDate = Convert.ToDateTime(hdfToDate.Value); } }