private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { if (e.Column.FieldName == "Coef/Area") { var _localID = int.Parse(gridView1.GetRowCellValue(e.RowHandle, gridView1.Columns["ID"]).ToString()); var _local = new DB_BIM().GetSingleElement <Local>(x => x.Id == _localID); var _porcientoBD = new DB_PLANTILLA().GetSingleRecord <T_Porciento_BD>(x => x.Id == _local.Porciento_BD).Value; var _coef = float.Parse(gridView1.GetRowCellValue(e.RowHandle, gridView1.Columns["Coef/Area"]).ToString()); var _coefNumHab = (_coef < 2 && !_local.Key_Name.Contains("Closet")) ? _proyecto.Cant_Habitaciones : 1; gridView1.SetRowCellValue(e.RowHandle, gridView1.Columns["Coef/Num.Habitaciones"], _coefNumHab); gridView1.SetRowCellValue(e.RowHandle, gridView1.Columns["Área Útil [m²]"], (_coef * _coefNumHab).ToString()); var _area = gridView1.GetRowCellValue(e.RowHandle, gridView1.Columns["Área Útil [m²]"]).ToString() == "" ? "1" : gridView1.GetRowCellValue(e.RowHandle, gridView1.Columns["Área Útil [m²]"]).ToString(); var _areaUtil = float.Parse(_area); var _porciento = float.Parse(_porcientoBD.ToString()); var _AreaPrograma = (_areaUtil * _porciento).ToString("#.##"); gridView1.SetRowCellValue(e.RowHandle, gridView1.Columns["Promedio de % Base Diseño"], _porciento); var _coefEntity = new DB_BIM().GetSingleElement <CoefArea>(x => x.Id == _local.Coef_Area); _coefEntity.Value = _coef.ToString(); _coefEntity.Area_Local = _areaUtil; _coefEntity.Area_Programa = _AreaPrograma == "" ? double.Parse("0") : double.Parse(_AreaPrograma); ProyectoController.UpdateCoefArea(_coefEntity); gridView1.SetRowCellValue(e.RowHandle, gridView1.Columns["Áreas De Cálculo [m²]"], _AreaPrograma); gridView1.UpdateCurrentRow(); gridView1.RefreshRow(e.RowHandle); } if (e.Column.FieldName == "Promedio de % Base Diseño" && gridView1.GetRowCellValue(e.RowHandle, gridView1.Columns["Áreas De Cálculo [m²]"]) != null) { var _localID = int.Parse(gridView1.GetRowCellValue(e.RowHandle, gridView1.Columns["ID"]).ToString()); var _local = new DB_BIM().GetSingleElement <Local>(x => x.Id == _localID); var _porcientoValue = float.Parse(gridView1.GetRowCellValue(e.RowHandle, gridView1.Columns["Promedio de % Base Diseño"]).ToString()); var _areaUtil = float.Parse(gridView1.GetRowCellValue(e.RowHandle, gridView1.Columns["Área Útil [m²]"]).ToString()); var _areaPrograma = (_areaUtil * _porcientoValue); gridView1.SetRowCellValue(e.RowHandle, gridView1.Columns["Áreas De Cálculo [m²]"], _areaPrograma); gridView1.UpdateCurrentRow(); gridView1.RefreshRow(e.RowHandle); var _coefEntity = new DB_BIM().GetSingleElement <CoefArea>(x => x.Id == _local.Coef_Area); _coefEntity.Area_Programa = double.Parse(_areaPrograma.ToString()); var _porcientoEntity = new DB_PLANTILLA().GetSingleRecord <T_Porciento_BD>(x => x.Value == _porcientoValue); _local.Porciento_BD = _porcientoEntity.Id; ProyectoController.UpdateCoefArea(_coefEntity); LocalController.UpdatePorcientoBD(_local); } if (e.Column.FieldName == "Hab") { var _localID = int.Parse(gridView1.GetRowCellValue(e.RowHandle, gridView1.Columns["ID"]).ToString()); var _localProyecto = new DB_BIM().GetSingleElement <Locales_Proyecto>(x => x.Local == _localID && x.Proyecto == _proyecto.Id); _localProyecto.Cantidad = int.Parse(gridView1.GetRowCellValue(e.RowHandle, "Hab").ToString()); LocalController.UpdateLocalesProyecto(_localProyecto); } }