public static Comunicaciones_Tv ToProject(this T_Comunicaciones_Tv t_Comunicaciones) { var _tf = new DB_PLANTILLA().GetSingleRecord <T_TF>(x => x.Id == t_Comunicaciones.Tf).Convert <TF>(); var _td = new DB_PLANTILLA().GetSingleRecord <T_TD>(x => x.Id == t_Comunicaciones.Td).Convert <TD>(); var _td_pos = new DB_PLANTILLA().GetSingleRecord <T_TD_Pos>(x => x.Id == t_Comunicaciones.TD_Pos).Convert <TD_Pos>(); var _upsc = new DB_PLANTILLA().GetSingleRecord <T_UPSC>(x => x.Id == t_Comunicaciones.UPSC).Convert <UPSC>(); var _ttTv = new DB_PLANTILLA().GetSingleRecord <T_TT_TV>(x => x.Id == t_Comunicaciones.TT_TV).Convert <TT_TV>(); var _di = new DB_PLANTILLA().GetSingleRecord <T_DI>(x => x.Id == t_Comunicaciones.Di).Convert <DI>(); var _altv = new DB_PLANTILLA().GetSingleRecord <T_ALTV>(x => x.Id == t_Comunicaciones.Altv).Convert <ALTV>(); var _upsi = new DB_PLANTILLA().GetSingleRecord <T_UPSI>(x => x.Id == t_Comunicaciones.UPSI).Convert <UPSI>(); Comunicaciones_Tv _comm = new Comunicaciones_Tv() { TF1 = _tf, TD1 = _td, TD_Pos1 = _td_pos, UPSC1 = _upsc, TT_TV1 = _ttTv, DI1 = _di, ALTV1 = _altv, UPSI1 = _upsi }; return(_comm); }
public static void InsertarSubsistemas <T>() where T : class { string _pageName = ""; switch (typeof(T).Name) { case "T_Subsistema_Area": _pageName = "SubsistemaArea"; break; case "T_Subsistema_Tipo": _pageName = "SubsistemaTipo"; break; } var _subAreas = ImportarExcel.GetSubsistema <T>(_pageName); using (var db = new DB_PLANTILLA()) { foreach (var item in _subAreas) { IList <PropertyInfo> _properties = new List <PropertyInfo>(item.GetType().GetProperties()); dynamic _subsistema = Activator.CreateInstance <T>(); _subsistema.Value = _properties.FirstOrDefault(p => p.Name == "Value").GetValue(item).ToString(); DataBaseController.AddElemento(db, typeof(T), _subsistema); } } }
public static Local ToProject(this T_Local t_local) { var grupoLocales = new DB_PLANTILLA().GetSingleRecord <T_Grupo_Locales>(x => x.Id == t_local.Grupo_Local); //var localTipo = new DB_PLANTILLA().GetSingleRecord<T_LocalTipo>(x => x.Grupo_Locales == grupoLocales.Id).ToProject(); var localTipo = new DB_PLANTILLA().GetSingleRecord <T_LocalTipo>(x => x.Id == t_local.LocalTipo).ToProject(); Local _local = new Local() { Alojamiento = t_local.Alojamiento, Ambiente = t_local.Ambiente, Climatizacion = t_local.Climatizacion, Coef_Area = t_local.Coef_Area, Comunicaciones_TV = t_local.Comunicaciones_TV, Habitacion = t_local.Habitacion, Key_Name = t_local.Key_Name, Local_Tipo = localTipo.Id, Grupo_Local = grupoLocales.Id, Mod = t_local.Mod, Porciento_BD = t_local.Porciento_BD, RoomId = t_local.RoomId, SubsistemaArea = t_local.SubsistemaArea, SubsistemaTipo = t_local.SubsistemaTipo, Tipo_Edificio = t_local.Tipo_Edificio }; return(_local); }
public static T_CoefArea InsertarCoefArea(int i) { var _worksheet = ImportarExcel.GetWorkSheetByName("BaseDatos"); var _value = _worksheet.GetSingleCellValue(i, 7); using (var db = new DB_PLANTILLA()) { T_CoefArea _coef = new T_CoefArea() { Value = _value }; var _record = db.GetSingleRecord <T_CoefArea>(x => x.Value == _coef.Value); if (_record == null) { db.AddElemento(_coef.GetType(), _coef); } else { _coef = _record; } return(_coef); } }
public static void InsertarAireFresco() { var _worksheet = ImportarExcel.GetWorkSheetByName("BaseDatos"); T_Aire_Fresco _af = null; for (int i = 2; i < _worksheet.Dimension.Rows + 1; i++) { var _aireFrescoM = _worksheet.GetSingleCellValue(i, 26); var _aireFrescoP = _worksheet.GetSingleCellValue(i, 27); using (var db = new DB_PLANTILLA()) { var _afM = db.GetSingleRecord <T_AF_Metro_Cuadrado>(x => x.Value == _aireFrescoM); var _afP = db.GetSingleRecord <T_AF_Persona>(x => x.Value == _aireFrescoP); var _afRecord = db.GetSingleRecord <T_Aire_Fresco>(x => x.Persona == _afP.Id && x.Metro_Cuadrado == _afM.Id); if (_afRecord == null) { _af = new T_Aire_Fresco() { Metro_Cuadrado = db.GetSingleRecord <T_AF_Metro_Cuadrado>(x => x.Value == _aireFrescoM).Id, Persona = db.GetSingleRecord <T_AF_Persona>(x => x.Value == _aireFrescoP).Id }; db.AddElemento(_af.GetType(), _af); } _af = _afRecord; } } }
public static Usuario FindUsuario(string username) { using (var db = new DB_PLANTILLA()) { return(db.GetSingleRecord <Usuario>(u => u.username == username)); } }
public static Usuario InsertUsuario(string username, string password) { using (var db = new DB_PLANTILLA()) { if (!GetAllUsuarios().Any()) { var _newUser = new Usuario() { username = "******", password = "******", access_Level = 3 }; db.AddElemento(_newUser.GetType(), _newUser); } if (FindUsuario(username) == null) { var _newUser = new Usuario() { username = username, password = password, access_Level = 0 }; db.AddElemento(_newUser.GetType(), _newUser); return(_newUser); } else { return(FindUsuario(username)); } } }
public static List <Usuario> GetAllUsuarios() { using (var db = new DB_PLANTILLA()) { return(db.GetAllRecords <Usuario>()); } }
public static void InsertarLocalesTipo() { var _allLocalesTipo = ImportarExcel.GetAllLocalesTipo(); foreach (var keys in _allLocalesTipo) { var _grupoLocalesId = new DB_PLANTILLA().GetSingleRecord <T_Grupo_Locales>(x => x.Cod1 == keys.Key).Id; foreach (var value in keys.Value) { T_LocalTipo _localTipo = new T_LocalTipo() { Value = value, Grupo_Locales = _grupoLocalesId }; new DB_PLANTILLA().AddElemento(_localTipo.GetType(), _localTipo); } } //using (var db = new DB_PLANTILLA()) //{ //foreach (var item in _allLocalesTipo) //{ // var _grupoLocalesId = DataBaseController.GetSingleRecord<T_Grupo_Locales>(new DB_PLANTILLA(), x => x.Cod1 == item.Value).Id; // T_LocalTipo _localTipo = new T_LocalTipo() // { // Value = item.Key, // Grupo_Locales = _grupoLocalesId // }; // DataBaseController.AddElemento(new DB_PLANTILLA(), _localTipo.GetType(), _localTipo); //} //} }
public static void InsertarLocales() { var _worksheet = ImportarExcel.GetWorkSheetByName("BaseDatos"); using (var db = new DB_PLANTILLA()) { for (int i = 2; i < _worksheet.Dimension.Rows + 1; i++) { var _temp = ""; if (_worksheet.GetSingleCellValue(i, 1) == null || _worksheet.GetSingleCellValue(i, 1) == "-") { break; } var _roomID = int.Parse(_worksheet.GetSingleCellValue(i, 1)); var _keyName = _worksheet.GetSingleCellValue(i, 5); var _name = _worksheet.GetSingleCellValue(i, 6); var _habitacion = _worksheet.GetSingleCellValue(i, 10) != "0"; _temp = _worksheet.GetSingleCellValue(i, 13); var _subTipo = db.GetSingleRecord <T_Subsistema_Tipo>(x => x.Value == _temp).Id; _temp = _worksheet.GetSingleCellValue(i, 14); var _subArea = db.GetSingleRecord <T_Subsistema_Area>(x => x.Value == _temp).Id; _temp = _worksheet.GetSingleCellValue(i, 3); var _grupoLocales = db.GetSingleRecord <T_Grupo_Locales>(x => x.Cod1 == _temp).Id; var _climatizacion = InsertarClimatizaciones(i).Id; var _comunicaciones = InsertarComunicacionesTV(i).Id; _temp = _worksheet.GetSingleCellValue(i, 16); var _ambiente = db.GetSingleRecord <T_Ambiente>(x => x.Nombre == _temp).Id; var _coefArea = InsertarCoefArea(i).Id; var _tempInt = int.Parse(_worksheet.GetSingleCellValue(i, 11)); var _mod = db.GetSingleRecord <T_Mod>(x => x.Value == _tempInt).Id; var _tempFloat = float.Parse(_worksheet.GetSingleCellValue(i, 9)); var _porcientoBD = db.GetSingleRecord <T_Porciento_BD>(x => x.Value == _tempFloat).Id; _temp = _worksheet.GetSingleCellValue(i, 15); var _localTipo = db.GetSingleRecord <T_LocalTipo>(x => x.Value == _temp).Id; _temp = _worksheet.GetSingleCellValue(i, 12); var _tipoEdificio = db.GetSingleRecord <T_Tipo_Edificio>(x => x.Value == _temp).Id; T_Local _local = new T_Local() { RoomId = _roomID, Key_Name = _keyName, Name = _name, Habitacion = _habitacion, SubsistemaTipo = _subTipo, SubsistemaArea = _subArea, Climatizacion = _climatizacion, Comunicaciones_TV = _comunicaciones, Ambiente = _ambiente, Coef_Area = _coefArea, Mod = _mod, Porciento_BD = _porcientoBD, LocalTipo = _localTipo, Grupo_Local = _grupoLocales, Tipo_Edificio = _tipoEdificio }; db.AddElemento(_local.GetType(), _local); } } }
public static void InsertarAlojamiento() { var _alojamientos = ImportarExcel.GetAlojamientos(); using (var db = new DB_PLANTILLA()) { foreach (var item in _alojamientos) { db.AddElemento(item.GetType(), item); } } }
public static float CalcularArea(this Local local, int cantHab) { //var _coef = DataBaseController.GetSingleRecord<T_CoefArea>(new DB_PLANTILLA(), x => x.Id == local.Coef_Area); var _coef = new DB_BIM().GetSingleElement <CoefArea>(x => x.Id == local.Coef_Area); var _localBase = new DB_PLANTILLA().GetSingleRecord <T_Local>(x => x.RoomId == local.RoomId); if (float.Parse(_coef.Value) <= 2 && _localBase.Key_Name.Contains("Closet")) { return(float.Parse(_coef.Value) * cantHab); } return(float.Parse(_coef.Value)); }
public static Aire_Fresco ToProject(this T_Aire_Fresco t_aireFresco) { var _persona = new DB_PLANTILLA().GetSingleRecord <T_AF_Persona>(x => x.Id == t_aireFresco.Persona).Convert <AF_Persona>(); var _metroCuadrado = new DB_PLANTILLA().GetSingleRecord <T_AF_Metro_Cuadrado>(x => x.Id == t_aireFresco.Metro_Cuadrado).Convert <AF_Metro_Cuadrado>(); Aire_Fresco _af = new Aire_Fresco() { AF_Persona = _persona, AF_Metro_Cuadrado = _metroCuadrado }; return(_af); }
DataTable Porcientos() { var _porcientos = new DB_PLANTILLA().GetAllRecords <T_Porciento_BD>(); DataTable _a = new DataTable(); foreach (var item in _porcientos) { _a.Columns.Add(item.Value.GetValueOrDefault().ToString()); } return(_a); }
public static void AdicionarAll <T>() where T : class { //ImportarExcel.Singleton(); string _pageName = ""; switch (typeof(T).Name) { case "T_Catalogo_Techo": _pageName = "Techos"; break; case "T_Catalogo_Pared": _pageName = "Paredes"; break; case "T_Catalogo_Rodapie": _pageName = "Rodapie"; break; case "T_Catalogo_Suelo": _pageName = "Suelos"; break; case "T_Catalogo_Impermeable": _pageName = "Impermeable"; break; } var _workSheet = ImportarExcel.GetWorkSheetByName(_pageName); var _acabadosName = ImportarExcel.GetAcabadosName(_workSheet); using (var dbp = new DB_PLANTILLA()) { foreach (var item in _acabadosName) { var _record = ImportarExcel.GetCatalogoRow(item); IList <PropertyInfo> _properties = new List <PropertyInfo>(_record.GetType().GetProperties()); dynamic _acabado = Activator.CreateInstance(typeof(T)); _acabado.Cod = _properties.FirstOrDefault(p => p.Name == "Cod").GetValue(_record).ToString(); _acabado.CapituloID = _properties.FirstOrDefault(p => p.Name == "Capitulo_ID").GetValue(_record).ToString(); _acabado.Capitulo = _properties.FirstOrDefault(p => p.Name == "Capitulo").GetValue(_record).ToString(); _acabado.Grupo = _properties.FirstOrDefault(p => p.Name == "Grupo").GetValue(_record).ToString(); DataBaseController.AddElemento(dbp, typeof(T), _acabado); } } }
public static T_Climatizacion InsertarClimatizaciones(int i) { var _worksheet = ImportarExcel.GetWorkSheetByName("BaseDatos"); var _tratamiento = _worksheet.GetSingleCellValue(i, 22); var _equipamiento = _worksheet.GetSingleCellValue(i, 23); var _criterioM = _worksheet.GetSingleCellValue(i, 24); var _aireFrescoM = _worksheet.GetSingleCellValue(i, 26); var _aireFrescoP = _worksheet.GetSingleCellValue(i, 27); var _renovaciones = _worksheet.GetSingleCellValue(i, 28); var _wAire = _worksheet.GetSingleCellValue(i, 29); using (var db = new DB_PLANTILLA()) { var _afM = db.GetSingleRecord <T_AF_Metro_Cuadrado>(x => x.Value == _aireFrescoM).Id; var _afP = db.GetSingleRecord <T_AF_Persona>(x => x.Value == _aireFrescoP).Id; var _af = db.GetSingleRecord <T_Aire_Fresco>(x => x.Metro_Cuadrado == _afM && x.Persona == _afP).Id; T_Climatizacion _clima = new T_Climatizacion() { Tratamiento = db.GetSingleRecord <T_Tratamiento>(x => x.Value == _tratamiento).Id, Equipamiento = db.GetSingleRecord <T_Equipamiento>(x => x.Value == _equipamiento).Id, Criterio = db.GetSingleRecord <T_Criterio>(x => x.Value == _criterioM).Id, Aire_Fresco = _af, Renovaciones = db.GetSingleRecord <T_Renovaciones>(x => x.Value == _renovaciones).Id, W_Aire = db.GetSingleRecord <T_W_Aire>(x => x.Value == _wAire).Id }; var _record = db.GetSingleRecord <T_Climatizacion>(x => x.Tratamiento == _clima.Tratamiento && x.Equipamiento == _clima.Equipamiento && x.Criterio == _clima.Criterio && x.Aire_Fresco == _clima.Aire_Fresco && x.Renovaciones == _clima.Renovaciones && x.W_Aire == _clima.W_Aire); if (_record == null) { db.AddElemento(_clima.GetType(), _clima); } else { _clima = _record; } return(_clima); } }
public static T_Comunicaciones_Tv InsertarComunicacionesTV(int i) { var _worksheet = ImportarExcel.GetWorkSheetByName("BaseDatos"); var _tf = _worksheet.GetSingleCellValue(i, 30); var _td = _worksheet.GetSingleCellValue(i, 31); var _tdPos = _worksheet.GetSingleCellValue(i, 32); var _upsc = _worksheet.GetSingleCellValue(i, 33); var _upsi = _worksheet.GetSingleCellValue(i, 34); var _tttv = _worksheet.GetSingleCellValue(i, 35); var _di = _worksheet.GetSingleCellValue(i, 36); var _altv = _worksheet.GetSingleCellValue(i, 37); using (var db = new DB_PLANTILLA()) { T_Comunicaciones_Tv _comm = new T_Comunicaciones_Tv() { Tf = db.GetSingleRecord <T_TF>(x => x.Value == _tf).Id, Td = db.GetSingleRecord <T_TD>(x => x.Value == _td).Id, TD_Pos = db.GetSingleRecord <T_TD_Pos>(x => x.Value == _tdPos).Id, UPSC = db.GetSingleRecord <T_UPSC>(x => x.Value == _upsc).Id, UPSI = db.GetSingleRecord <T_UPSI>(x => x.Value == _upsi).Id, TT_TV = db.GetSingleRecord <T_TT_TV>(x => x.Value == _tttv).Id, Di = db.GetSingleRecord <T_DI>(x => x.Value == _di).Id, Altv = db.GetSingleRecord <T_ALTV>(x => x.Value == _altv).Id }; var _record = db.GetSingleRecord <T_Comunicaciones_Tv>(x => x.Tf == _comm.Tf && x.Td == _comm.Td && x.TD_Pos == _comm.TD_Pos && x.UPSC == _comm.UPSC && x.UPSI == _comm.UPSI && x.TT_TV == _comm.TT_TV && x.Di == _comm.Di && x.Altv == _comm.Altv); if (_record == null) { db.AddElemento(_comm.GetType(), _comm); } else { _comm = _record; } return(_comm); } }
public static Usuario Autenticate(string username, string password) { using (var db = new DB_PLANTILLA()) { if (!db.GetAllRecords <Usuario>().Any()) { var _newUser = new Usuario() { username = "******", password = "******", access_Level = 3 }; db.AddElemento(_newUser.GetType(), _newUser); } var result = db.GetSingleRecord <Usuario>(u => u.username == username && u.password == password); return(result); } }
public static Usuario UpdateUser(Usuario user) { using (var db = new DB_PLANTILLA()) { var result = db.Usuario.FirstOrDefault(u => u.username == user.username); if (result != null) { result.access_Level = user.access_Level; db.SaveChanges(); return(result); } else { return(result); } } }
public static string CalcularCod3(this Local local) { var _porcientoBD = new DB_PLANTILLA().GetSingleRecord <T_Porciento_BD>(x => x.Id == local.Porciento_BD).Value.ToString().Replace('.', ','); switch (_porcientoBD) { case "1,0": return("CC"); case "1": return("CC"); case "0,25": return("EX"); default: return("CA"); } }
public static Climatizacion ToProject(this T_Climatizacion t_climatizacion) { var _tratamiento = new DB_PLANTILLA().GetSingleRecord <T_Tratamiento>(x => x.Id == t_climatizacion.Tratamiento).Convert <Tratamiento>(); var _equipamiento = new DB_PLANTILLA().GetSingleRecord <T_Equipamiento>(x => x.Id == t_climatizacion.Equipamiento).Convert <Equipamiento>(); var _criterio = new DB_PLANTILLA().GetSingleRecord <T_Criterio>(x => x.Id == t_climatizacion.Criterio).Convert <Criterio>(); var _aireFresco = new DB_PLANTILLA().GetSingleRecord <T_Aire_Fresco>(x => x.Id == t_climatizacion.Aire_Fresco).ToProject(); var _renovaciones = new DB_PLANTILLA().GetSingleRecord <T_Renovaciones>(x => x.Id == t_climatizacion.Renovaciones).Convert <Renovaciones>(); var _wAire = new DB_PLANTILLA().GetSingleRecord <T_W_Aire>(x => x.Id == t_climatizacion.W_Aire).Convert <W_Aire>(); Climatizacion _clima = new Climatizacion() { Tratamiento1 = _tratamiento, Equipamiento1 = _equipamiento, Criterio1 = _criterio, Aire_Fresco1 = _aireFresco, Renovaciones1 = _renovaciones, W_Aire1 = _wAire }; return(_clima); }
public ProjectManagementForm(Proyecto proyecto) { InitializeComponent(); //gridControl1.ForceInitialize(); _proyecto = new DB_BIM().GetSingleElement <Proyecto>(x => x.Id == proyecto.Id); this.Text = string.Format("{0} - {1}", _proyecto.Cod, _proyecto.Nombre); backgroundWorker1.WorkerReportsProgress = true; txt_nombre.Text = _proyecto.Nombre; txt_codigo.Text = _proyecto.Cod; txt_Localizacion.Text = _proyecto.Localizacion; txt_tipoAlojamiento.Text = _proyecto.Tipo_Alojamiento; txt_subtipoAlojamiento.Text = _proyecto.Subtipo_Alojamiento; txt_TipoHotel.Text = _proyecto.Tipo_Hotel; numeric_cantHabitaciones.Value = Convert.ToDecimal(_proyecto.Cant_Habitaciones); numeric_Categoria.Value = Convert.ToDecimal(_proyecto.Categoria); numeric_MaximaAltura.Value = Convert.ToDecimal(_proyecto.Maxima_Altura); _projectManagementForm = this; var _locales = new DB_PLANTILLA().GetAllRecords <T_Local>(); foreach (var item in _locales) { cmb_LocalTipo.Items.Add(item.Key_Name); } //var _desgloses = new DB_BIM().GetElements<Desglose>(x => x.Proyecto == _proyecto.Id); var _desgloses = new DB_BIM().GetElements <Desglose>(x => x.Proyecto == _proyecto.Id).GroupBy(x => x.Value).Select(x => x.FirstOrDefault()).OrderBy(x => x.Value).ToList();; cmb_Desglose.Items.Clear(); foreach (var item in _desgloses) { cmb_Desglose.Items.Add(item.Value); } }
void FillData() { SplashScreenManager.ShowForm(typeof(WaitScreen)); gridControl1.DataSource = CreateColumns(); using (var db = new DB_PLANTILLA()) { var _locales = db.GetAllRecords <T_Local>(); var _subTipos = db.GetAllElements <T_Subsistema_Tipo>(); var _subAreas = db.GetAllElements <T_Subsistema_Area>(); var _coefs = db.GetAllElements <T_CoefArea>(); var _porcientos = db.GetAllElements <T_Porciento_BD>(); foreach (var item in _localesByProject) { gridView1.AddNewRow(); int _rowHandle = gridView1.GetRowHandle(gridView1.DataRowCount); if (gridView1.IsNewItemRow(_rowHandle)) { var _local = new DB_BIM().GetSingleRecord <Local>(x => x.Id == item.Local); gridView1.SetRowCellValue(_rowHandle, gridView1.Columns["RoomID"], _local.RoomId); gridView1.SetRowCellValue(_rowHandle, gridView1.Columns["KeyName"], _local.Key_Name); var _subTipo = new DB_PLANTILLA().GetSingleRecord <T_Subsistema_Tipo>(x => x.Id == _local.SubsistemaTipo); gridView1.SetRowCellValue(_rowHandle, gridView1.Columns["SubTipo"], _subTipo.Value.ToString()); var _subArea = new DB_PLANTILLA().GetSingleRecord <T_Subsistema_Area>(x => x.Id == _local.SubsistemaArea); gridView1.SetRowCellValue(_rowHandle, gridView1.Columns["SubArea"], _subArea.Value.ToString()); var _coefArea = new DB_BIM().GetSingleElement <CoefArea>(x => x.Id == _local.Coef_Area); gridView1.SetRowCellValue(_rowHandle, gridView1.Columns["Coef"], _coefArea.Value); var _porcientoBD = new DB_PLANTILLA().GetSingleRecord <T_Porciento_BD>(x => x.Id == _local.Porciento_BD); gridView1.SetRowCellValue(_rowHandle, gridView1.Columns["PorcientoBD"], _porcientoBD.Value); } } } SplashScreenManager.CloseForm(); }
public static int GetCoefNumHab(this Local local, int cantHab) { var _coef = new DB_BIM().GetSingleElement <CoefArea>(x => x.Id == local.Coef_Area); var _localBase = new DB_PLANTILLA().GetSingleRecord <T_Local>(x => x.RoomId == local.RoomId); if (_coef.Value == null) { _coef.Value = "0"; } if (_localBase == null) { return(cantHab); } if (float.Parse(_coef.Value) < 2 && !_localBase.Key_Name.Contains("Closet")) { return(cantHab); } return(1); }
private void simpleButton1_Click(object sender, EventArgs e) { var _selectedGrid = gridControlPrograma.Visible ? gridPrograma : gridDetalle; var _subsistemasTipo = new DB_PLANTILLA().GetAllRecords <T_Subsistema_Tipo>(); var _subsistemasArea = new DB_PLANTILLA().GetAllRecords <T_Subsistema_Area>(); var _grupoLocales = new DB_PLANTILLA().GetAllRecords <T_Grupo_Locales>(); var _porcientos = new DB_PLANTILLA().GetAllRecords <T_Porciento_BD>(); var _coefAreas = new DB_PLANTILLA().GetAllRecords <T_CoefArea>(); var _locales = new DB_PLANTILLA().GetAllRecords <T_Local>(); for (int i = 0; i < _selectedGrid.DataRowCount; i++) { try { _selectedGrid.FocusedRowHandle = i; Local _local = new Local(); Locales_Proyecto _localProyecto = new Locales_Proyecto(); var _subsistemaTipo = ""; var _subsistemaArea = ""; GetSubsistemas(_selectedGrid.GetRowCellValue(i, "Cod2").ToString(), ref _subsistemaTipo, ref _subsistemaArea, _selectedGrid.GetRowCellValue(i, "Cod1").ToString()); //var _subTipoValue = _selectedGrid.GetRowCellValue(i, "Subsistema Tipo").ToString(); _local.SubsistemaTipo = _subsistemasTipo.FirstOrDefault(x => x.Value == _subsistemaTipo).Id; //var _subAreaValue = _selectedGrid.GetRowCellValue(i, "Subsistema Area").ToString(); _local.SubsistemaArea = _subsistemasArea.FirstOrDefault(x => x.Value == _subsistemaArea).Id; var _localTipoValue = _selectedGrid.GetRowCellValue(i, "LocalTipo").ToString(); var _cod1Value = _selectedGrid.GetRowCellValue(i, "Cod1").ToString().Replace(',', '.'); var _grupoLocal = _grupoLocales.FirstOrDefault(x => x.Cod1.Contains(_cod1Value)).Id; LocalTipo _localTipo = new LocalTipo() { Grupo_Locales = _grupoLocal, Value = _localTipoValue }; var _porcientoBD = double.Parse(_selectedGrid.GetRowCellValue(i, "PorcientoBD").ToString()); //_porcientoBD = _porcientoBD / 100; _local.Porciento_BD = _porcientos.FirstOrDefault(x => x.Value == _porcientoBD).Id; var _areaUtil = _selectedGrid.GetRowCellValue(i, "AreaLocal").ToString() == "" ? 0.00 : double.Parse(_selectedGrid.GetRowCellValue(i, "AreaLocal").ToString()); CoefArea _coef = new CoefArea() { Area_Local = _areaUtil }; var _desgloseValue = _selectedGrid.GetRowCellValue(i, "Desglose").ToString(); var _desglose = new DB_BIM().GetSingleElement <Desglose>(x => x.Value == _desgloseValue && x.Proyecto == _proyecto.Id); if (_desglose != null) { _local.Desglose = _desglose.Id; } else { Desglose _newDesglose = new Desglose() { Value = _desgloseValue, Proyecto = _proyecto.Id }; _local.Desglose1 = _newDesglose; } var _localID = _locales.FirstOrDefault(x => x.Key_Name == _selectedGrid.GetRowCellValue(i, "RoomID").ToString()); var keyName = _selectedGrid.GetRowCellValue(i, "Local").ToString(); var localesProyecto = new DB_BIM().GetElements <Locales_Proyecto>(x => x.Proyecto == _proyecto.Id); var realLocal = localesProyecto.FirstOrDefault( x => x.Local1.Desglose == _local.Desglose && x.Local1.LocalTipo == _localTipo && x.Local1.Key_Name == keyName); if (realLocal != null) { LocalController.UpdateLocalesProyecto(realLocal); } else { _local.RoomId = _localID.RoomId; _local.CoefArea = _coef; _local.CoefArea.Value = _coefAreas.FirstOrDefault(x => x.Id == _localID.Coef_Area).Value; _local.LocalTipo = _localTipo; _local.Key_Name = keyName; _local.Ambiente1 = _localID.T_Ambiente.ToProject(); _local.Comunicaciones_Tv1 = _localID.T_Comunicaciones_Tv.ToProject(); _local.Climatizacion1 = _localID.T_Climatizacion.ToProject(); _localProyecto.Local1 = _local; _localProyecto.Proyecto = _proyecto.Id; _localProyecto.Cantidad = _selectedGrid.GetRowCellValue(i, "Hab") == null ? 0 : int.Parse(_selectedGrid.GetRowCellValue(i, "Hab").ToString()); new DB_BIM().AddElemento <Locales_Proyecto>(typeof(Locales_Proyecto), _localProyecto); } } catch (Exception ex) { Excepciones.Excepciones.EnviarCorreo(ex); //throw; } } MessageBox.Show("Completado!"); }
public static void FormatTable(ref GridView gridview) { gridview.GridControl.DataSource = MakeColumns(); gridview.OptionsView.GroupFooterShowMode = GroupFooterShowMode.VisibleAlways; GridGroupSummaryItem _summaryAreaLocal = new GridGroupSummaryItem(); _summaryAreaLocal.FieldName = "AreaLocal"; //_summaryAreaLocal.SummaryType = SummaryItemType.Custom; _summaryAreaLocal.SummaryType = SummaryItemType.Sum; _summaryAreaLocal.DisplayFormat = "Total: {0:0.00}"; _summaryAreaLocal.ShowInGroupColumnFooter = gridview.Columns["AreaLocal"]; gridview.GroupSummary.Add(_summaryAreaLocal); GridGroupSummaryItem _summaryAreaCalculo = new GridGroupSummaryItem(); _summaryAreaCalculo.FieldName = "AreaCalculo"; _summaryAreaCalculo.SummaryType = SummaryItemType.Sum; _summaryAreaCalculo.DisplayFormat = "Total: {0:0.00}"; _summaryAreaCalculo.ShowInGroupColumnFooter = gridview.Columns["AreaCalculo"]; gridview.GroupSummary.Add(_summaryAreaCalculo); GridGroupSummaryItem _summaryHab = new GridGroupSummaryItem(); _summaryHab.FieldName = "Hab"; _summaryHab.SummaryType = SummaryItemType.Sum; //_summaryHab.SummaryType = SummaryItemType.Custom; _summaryHab.DisplayFormat = "Total: {0}"; _summaryHab.ShowInGroupColumnFooter = gridview.Columns["Hab"]; gridview.GroupSummary.Add(_summaryHab); gridview.Columns["AreaLocal"].FieldName = "AreaLocal"; gridview.Columns["AreaLocal"].UnboundType = UnboundColumnType.Decimal; RepositoryItemComboBox _repository = new RepositoryItemComboBox(); var _allPorcientos = new DB_PLANTILLA().GetAllRecords <T_Porciento_BD>(); foreach (var item in _allPorcientos) { _repository.Items.Add(item.Value); } gridview.Columns["PorcientoBD"].ColumnEdit = _repository; //gridview.Columns["PorcientoBD"].FieldName = "PorcientoBD"; //gridview.Columns["PorcientoBD"].UnboundType = UnboundColumnType.Decimal; //gridview.Columns["RoomID"].Visible = false; gridview.Columns["AreaCalculo"].OptionsColumn.AllowEdit = false; gridview.Columns["Cod2"].OptionsColumn.AllowEdit = false; gridview.Columns["Cod3"].OptionsColumn.AllowEdit = false; gridview.Columns["Desglose"].GroupIndex = 1; gridview.Columns["LocalTipo"].GroupIndex = 2; gridview.GroupLevelStyle += (s, e) => { if (e.Level == 0) { e.LevelAppearance.ForeColor = Color.WhiteSmoke; e.LevelAppearance.BackColor = Color.Gray; } if (e.Level == 1) { e.LevelAppearance.ForeColor = Color.Black; e.LevelAppearance.BackColor = Color.LightGray; } }; }
void GenerateTable() { SplashScreenManager.ShowForm(typeof(WaitScreen)); if (gridControl1.DataSource != null) { gridControl1.DataSource = null; } gridControl1.DataSource = CreateColumns(); gridView1.Columns["SubsistemaTipo"].OptionsColumn.AllowEdit = false; gridView1.Columns["SubsistemaArea"].OptionsColumn.AllowEdit = false; gridView1.Columns["LocalTipo"].OptionsColumn.AllowEdit = false; gridView1.Columns["Cod1"].OptionsColumn.AllowEdit = false; gridView1.Columns["Cod1"].Width = 45; gridView1.Columns["Cod2"].OptionsColumn.AllowEdit = false; gridView1.Columns["Cod2"].Width = 40; gridView1.Columns["Cod3"].OptionsColumn.AllowEdit = false; gridView1.Columns["Cod3"].Width = 40; gridView1.Columns["Local"].OptionsColumn.AllowEdit = false; gridView1.Columns["Local"].Width = 200; //gridView1.Columns["Hab"].OptionsColumn.AllowEdit = false; //gridView1.Columns["Coef/Area"].OptionsColumn.AllowEdit = false; gridView1.Columns["Coef/Num.Habitaciones"].OptionsColumn.AllowEdit = false; gridView1.Columns["Área Útil [m²]"].OptionsColumn.AllowEdit = false; //gridView1.Columns["Promedio de % Base Diseño"].OptionsColumn.AllowEdit = false; gridView1.Columns["Áreas De Cálculo [m²]"].OptionsColumn.AllowEdit = false; RepositoryItemComboBox _repository = new RepositoryItemComboBox(); var _allPorcientos = new DB_PLANTILLA().GetAllRecords <T_Porciento_BD>(); foreach (var item in _allPorcientos) { _repository.Items.Add(item.Value); } gridView1.Columns["Promedio de % Base Diseño"].ColumnEdit = _repository; gridView1.Columns["RoomID"].OptionsColumn.AllowEdit = false; gridView1.Columns["RoomID"].Visible = false; gridView1.Columns["ID"].OptionsColumn.AllowEdit = false; gridView1.Columns["ID"].Visible = false; gridView1.Columns["Obj. Obra"].GroupIndex = 1; gridView1.Columns["LocalTipo"].GroupIndex = 2; gridView1.GroupLevelStyle += (s, e) => { if (e.Level == 0) { e.LevelAppearance.ForeColor = Color.WhiteSmoke; e.LevelAppearance.BackColor = Color.Gray; } if (e.Level == 1) { e.LevelAppearance.ForeColor = Color.Black; e.LevelAppearance.BackColor = Color.LightGray; } }; GridGroupSummaryItem _summaryAreaLocal = new GridGroupSummaryItem { FieldName = "Área Útil [m²]", SummaryType = SummaryItemType.Sum, DisplayFormat = "Total: {0:0.00}", ShowInGroupColumnFooter = gridView1.Columns["Área Útil [m²]"] }; gridView1.GroupSummary.Add(_summaryAreaLocal); GridGroupSummaryItem _summaryAreaCalculo = new GridGroupSummaryItem { FieldName = "Áreas De Cálculo [m²]", SummaryType = SummaryItemType.Sum, DisplayFormat = "Total: {0:0.00}", ShowInGroupColumnFooter = gridView1.Columns["Áreas De Cálculo [m²]"] }; gridView1.GroupSummary.Add(_summaryAreaCalculo); GridGroupSummaryItem _summaryHabitaciones = new GridGroupSummaryItem { FieldName = "Hab", SummaryType = SummaryItemType.Sum, DisplayFormat = "Total: {0}", ShowInGroupColumnFooter = gridView1.Columns["Hab"] }; gridView1.GroupSummary.Add(_summaryHabitaciones); _localesByProject = new DB_BIM().GetElements <Locales_Proyecto>(x => x.Proyecto == _proyecto.Id); foreach (var item in _localesByProject) { AddGridViewRow(item); } SplashScreenManager.CloseForm(); }
public static string CalcularCod2(this T_Local local) { var _cod2 = ""; var _subsistemaTipo = new DB_PLANTILLA().GetSingleRecord <T_Subsistema_Tipo>(x => x.Id == local.SubsistemaTipo).Value; var _subsistemaArea = new DB_PLANTILLA().GetSingleRecord <T_Subsistema_Area>(x => x.Id == local.SubsistemaArea).Value; switch (_subsistemaTipo) { case "Alojamiento": _cod2 += "A"; break; case "Gastronomía": _cod2 += "G"; break; case "Público-Comercial": _cod2 += "PC"; break; case "Recreacion en Interiores": _cod2 += "R"; break; case "Recreación en Exteriores": _cod2 += "R"; break; case "Administrativo": _cod2 += "A"; break; case "Otras Areas Exteriores": _cod2 += "R"; break; default: _cod2 += ""; break; } switch (_subsistemaArea) { case "Huéspedes": _cod2 += "H"; break; case "Público": _cod2 += "P"; break; case "Servicios": _cod2 += "S"; break; case "Administrativo": _cod2 += ""; break; case "Varios": _cod2 += ""; break; default: _cod2 += ""; break; } return(_cod2); }
private void btn_ExportExcel_Click(object sender, EventArgs e) { /*//MessageBox.Show(Directory.GetFiles(@"\\10.72.221.18\02-PROYECTOS\").ToString()); * var _path = @"Z:\02-PROYECTOS"; * var _folders = Directory.GetDirectories(_path, "*", SearchOption.TopDirectoryOnly); * * var _this = ""; * foreach (var item in _folders) * { * var _depth1 = Directory.GetDirectories(Path.Combine(_path, item), "*", SearchOption.TopDirectoryOnly); * foreach (var item2 in _depth1) * { * if (item2.Contains("P70")) * _this += item2 + "\n"; * } * } * * MessageBox.Show(_this);*/ SaveFileDialog _dialog = new SaveFileDialog(); _dialog.RestoreDirectory = true; _dialog.InitialDirectory = @"Z:\02-PROYECTOS"; _dialog.Filter = "Excel File|*.xls"; _dialog.FileName = _proyecto.Cod + "_" + "BaseDatos.xlsx"; _dialog.Title = @"Guardar en: ...\01 Doc graficos\01 BIM\20_Recursos\02_Datos\"; DialogResult _result = _dialog.ShowDialog(); if (_result == DialogResult.OK) { //var _filepath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/" + _proyecto.Cod + "_" + "BaseDatos.xlsx"; var _filepath = _dialog.FileName; var _file = new FileInfo(_filepath); using (var _excelPackage = new ExcelPackage(_file)) { if (_excelPackage.Workbook.Worksheets.FirstOrDefault(x => x.Name == "BaseDatos") != null) { _excelPackage.Workbook.Worksheets.Delete("BaseDatos"); } ExcelWorksheet _worksheet = _excelPackage.Workbook.Worksheets.Add("BaseDatos"); _worksheet.Cells["A1:AK10000"].AutoFilter = true; #region Encabezados //Encabezados //RoomID MakeHeader(ref _worksheet, 1, "RoomID"); //Cod0 MakeHeader(ref _worksheet, 2, "Cod0"); //Cod1 MakeHeader(ref _worksheet, 3, "Cod1"); //Cod2 MakeHeader(ref _worksheet, 4, "Cod2"); //KeyName MakeHeader(ref _worksheet, 5, "Key Name"); //Name MakeHeader(ref _worksheet, 6, "Name"); //Coef/Area MakeHeader(ref _worksheet, 7, "CoeficienteArea"); //Coef/NumHab MakeHeader(ref _worksheet, 8, "CoeficienteNumHab"); //PorcientoBD MakeHeader(ref _worksheet, 9, "PorcientoBD"); //Habitacion MakeHeader(ref _worksheet, 10, "Habitacion"); //Modulo MakeHeader(ref _worksheet, 11, "Modulo"); //TipoEdificio MakeHeader(ref _worksheet, 12, "TipoEdificio"); //SubsistemaTipo MakeHeader(ref _worksheet, 13, "SubsistemaTipo"); //SubsistemaArea MakeHeader(ref _worksheet, 14, "SubsistemaArea"); //LocalTipo MakeHeader(ref _worksheet, 15, "LocalTipo"); //AmbienteClave MakeHeader(ref _worksheet, 16, "AmbienteClave"); //Floor MakeHeader(ref _worksheet, 17, "Floor"); //Rodapie MakeHeader(ref _worksheet, 18, "Rodapie"); //WallFinish MakeHeader(ref _worksheet, 19, "WallFinish"); //CeilingFinish MakeHeader(ref _worksheet, 20, "CeilingFinish"); //BaseFinish MakeHeader(ref _worksheet, 21, "BaseFinish"); //Tratamiento MakeHeader(ref _worksheet, 22, "Tratamiento"); //Equipamiento MakeHeader(ref _worksheet, 23, "Equipamiento"); //Criterio[m²/ kW] MakeHeader(ref _worksheet, 24, "Criterio[m²/ kW]"); //Criterio [W/m²] MakeHeader(ref _worksheet, 25, "Criterio [W/m²]"); //Aire Fresco [m³/h*m²] MakeHeader(ref _worksheet, 26, "Aire Fresco [m³/h*m²]"); //Aire Fresco [m³/h*personas] MakeHeader(ref _worksheet, 27, "Aire Fresco [m³/h*personas]"); //Renovaciones[Cambios / hr] MakeHeader(ref _worksheet, 28, "Renovaciones[Cambios / hr]"); //W_Aire MakeHeader(ref _worksheet, 29, "W_Aire"); //TF MakeHeader(ref _worksheet, 30, "TF"); //TD MakeHeader(ref _worksheet, 31, "TD"); //TD_POS MakeHeader(ref _worksheet, 32, "TD_POS"); //UPSC MakeHeader(ref _worksheet, 33, "UPSC"); //UPSI MakeHeader(ref _worksheet, 34, "UPSI"); //TT_TV MakeHeader(ref _worksheet, 35, "TT_TV"); //DI MakeHeader(ref _worksheet, 36, "DI"); //ALTV MakeHeader(ref _worksheet, 37, "ALTV"); #endregion var _locales = new DB_PLANTILLA().GetAllRecords <T_Local>(); var _grupoLocales = new DB_PLANTILLA().GetAllRecords <T_Grupo_Locales>(); var _porcientos = new DB_PLANTILLA().GetAllRecords <T_Porciento_BD>(); var _suelos = new DB_PLANTILLA().GetAllRecords <T_Catalogo_Suelo>(); var _rodapie = new DB_PLANTILLA().GetAllRecords <T_Catalogo_Rodapie>(); var _pared = new DB_PLANTILLA().GetAllRecords <T_Catalogo_Pared>(); var _techos = new DB_PLANTILLA().GetAllRecords <T_Catalogo_Techo>(); var _impermeables = new DB_PLANTILLA().GetAllRecords <T_Catalogo_Impermeable>(); SplashScreenManager.ShowForm(typeof(WaitScreen)); for (int i = 0; i < _localesByProject.Count; i++) { var _local = _locales.FirstOrDefault(x => x.RoomId == _localesByProject[i].Local1.RoomId); _worksheet.Cells[i + 2, 1].Value = _localesByProject[i].Local1.RoomId; var _cod1 = _grupoLocales.FirstOrDefault(x => x.Id == _localesByProject[i].Local1.LocalTipo.Grupo_Locales).Cod1; _worksheet.Cells[i + 2, 2].Value = _cod1.Split('.').First(); _worksheet.Cells[i + 2, 3].Value = _cod1; _worksheet.Cells[i + 2, 4].Value = _localesByProject[i].Local1.CalcularCod2(); _worksheet.Cells[i + 2, 5].Value = _local.Key_Name; _worksheet.Column(5).AutoFit(); _worksheet.Cells[i + 2, 6].Value = _localesByProject[i].Local1.Key_Name; _worksheet.Column(6).AutoFit(); _worksheet.Cells[i + 2, 7].Value = _localesByProject[i].Local1.CoefArea.Value; _worksheet.Cells[i + 2, 8].Value = _localesByProject[i].Local1.GetCoefNumHab(_proyecto.Cant_Habitaciones.GetValueOrDefault()); _worksheet.Cells[i + 2, 9].Value = _porcientos.FirstOrDefault(x => x.Id == _localesByProject[i].Local1.Porciento_BD).Value.GetValueOrDefault().ToString("#,##"); _worksheet.Cells[i + 2, 10].Value = _local.Habitacion.GetValueOrDefault() ? "1" : "0"; _worksheet.Cells[i + 2, 11].Value = _local.Mod.GetValueOrDefault(); _worksheet.Cells[i + 2, 12].Value = _local.T_Tipo_Edificio.Value; _worksheet.Column(12).AutoFit(); _worksheet.Cells[i + 2, 13].Value = _local.T_Subsistema_Tipo.Value; _worksheet.Column(13).AutoFit(); _worksheet.Cells[i + 2, 14].Value = _local.T_Subsistema_Area.Value; _worksheet.Column(14).AutoFit(); _worksheet.Cells[i + 2, 15].Value = _localesByProject[i].Local1.LocalTipo.Value; _worksheet.Column(15).AutoFit(); _worksheet.Cells[i + 2, 16].Value = _localesByProject[i].Local1.Ambiente1.Nombre; _worksheet.Column(16).AutoFit(); _worksheet.Cells[i + 2, 17].Value = _suelos.FirstOrDefault(x => x.Id == _localesByProject[i].Local1.Ambiente1.Suelo).Cod; _worksheet.Cells[i + 2, 18].Value = _rodapie.FirstOrDefault(x => x.Id == _localesByProject[i].Local1.Ambiente1.Rodapie).Cod; _worksheet.Cells[i + 2, 19].Value = _pared.FirstOrDefault(x => x.Id == _localesByProject[i].Local1.Ambiente1.Pared).Cod; _worksheet.Cells[i + 2, 20].Value = _techos.FirstOrDefault(x => x.Id == _localesByProject[i].Local1.Ambiente1.Techo).Cod; _worksheet.Cells[i + 2, 21].Value = _impermeables.FirstOrDefault(x => x.Id == _localesByProject[i].Local1.Ambiente1.Impermeable).Cod; _worksheet.Cells[i + 2, 22].Value = _localesByProject[i].Local1.Climatizacion1.Tratamiento1.Value; _worksheet.Cells[i + 2, 23].Value = _localesByProject[i].Local1.Climatizacion1.Equipamiento1.Value; var _criterio = _localesByProject[i].Local1.Climatizacion1.Criterio1.Value == "-" ? 0 : float.Parse(_localesByProject[i].Local1.Climatizacion1.Criterio1.Value); _worksheet.Cells[i + 2, 24].Value = _criterio; _worksheet.Cells[i + 2, 25].Value = _criterio / 1000; _worksheet.Cells[i + 2, 26].Value = _localesByProject[i].Local1.Climatizacion1.Aire_Fresco1.AF_Metro_Cuadrado.Value; _worksheet.Cells[i + 2, 27].Value = _localesByProject[i].Local1.Climatizacion1.Aire_Fresco1.AF_Persona.Value; _worksheet.Cells[i + 2, 28].Value = _localesByProject[i].Local1.Climatizacion1.Renovaciones1.Value; _worksheet.Cells[i + 2, 28].Value = _localesByProject[i].Local1.Climatizacion1.W_Aire1.Value; _worksheet.Cells[i + 2, 29].Value = _localesByProject[i].Local1.Comunicaciones_Tv1.TF1.Value; _worksheet.Cells[i + 2, 30].Value = _localesByProject[i].Local1.Comunicaciones_Tv1.TD1.Value; _worksheet.Cells[i + 2, 31].Value = _localesByProject[i].Local1.Comunicaciones_Tv1.TD_Pos1.Value; _worksheet.Cells[i + 2, 32].Value = _localesByProject[i].Local1.Comunicaciones_Tv1.UPSC1.Value; _worksheet.Cells[i + 2, 33].Value = _localesByProject[i].Local1.Comunicaciones_Tv1.UPSI1.Value; _worksheet.Cells[i + 2, 34].Value = _localesByProject[i].Local1.Comunicaciones_Tv1.TT_TV1.Value; _worksheet.Cells[i + 2, 35].Value = _localesByProject[i].Local1.Comunicaciones_Tv1.DI1.Value; _worksheet.Cells[i + 2, 36].Value = _localesByProject[i].Local1.Comunicaciones_Tv1.ALTV1.Value; } if (_excelPackage.Workbook.Worksheets.FirstOrDefault(x => x.Name == DateTime.Now.ToString("yyyyMMdd") + "-Programa") != null) { _excelPackage.Workbook.Worksheets.Delete(DateTime.Now.ToString("yyyyMMdd") + "-Programa"); } _worksheet = _excelPackage.Workbook.Worksheets.Add(DateTime.Now.ToString("yyyyMMdd") + "-Programa"); MakeHeader(ref _worksheet, 1, "Cod1"); MakeHeader(ref _worksheet, 2, "Cod2"); MakeHeader(ref _worksheet, 3, "Cod3"); MakeHeader(ref _worksheet, 4, "Obj. Obra"); MakeHeader(ref _worksheet, 5, "Local Tipo"); MakeHeader(ref _worksheet, 6, "Nombre"); MakeHeader(ref _worksheet, 7, "Cantidad"); MakeHeader(ref _worksheet, 8, "Área Útil"); MakeHeader(ref _worksheet, 9, "Porciento BD"); MakeHeader(ref _worksheet, 10, "Área Calculo"); var orderedList = _localesByProject.OrderBy(l => l.Local1.Desglose1.Value).ThenBy(l => l.Local1.LocalTipo.Value).ToList(); var desglose = ""; var localTipo = ""; for (int i = 0; i < orderedList.Count; i++) { _worksheet.Cells[i + 2, 1].Value = _locales.FirstOrDefault(l => l.RoomId == orderedList[i].Local1.RoomId).T_Grupo_Locales.Cod1;; _worksheet.Cells[i + 2, 2].Value = orderedList[i].Local1.CalcularCod2(); _worksheet.Cells[i + 2, 3].Value = orderedList[i].Local1.CalcularCod3(); _worksheet.Cells[i + 2, 4].Value = orderedList[i].Local1.Desglose1.Value.ToUpper(); _worksheet.Cells[i + 2, 5].Value = orderedList[i].Local1.LocalTipo.Value.ToUpper(); _worksheet.Cells[i + 2, 6].Value = orderedList[i].Local1.Key_Name; _worksheet.Cells[i + 2, 6].AutoFitColumns(); _worksheet.Cells[i + 2, 7].Value = orderedList[i].Cantidad; float coefArea = float.Parse(orderedList[i].Local1.CoefArea.Value); var areaUtil = orderedList[i].Local1.CalcularArea(_proyecto.Cant_Habitaciones.GetValueOrDefault()); _worksheet.Cells[i + 2, 8].Value = areaUtil; double porcientos = double.Parse(_porcientos.FirstOrDefault(p => p.Id == orderedList[i].Local1.Porciento_BD).Value.ToString()); _worksheet.Cells[i + 2, 9].Value = ModificarPorcientos(_porcientos.FirstOrDefault(p => p.Id == orderedList[i].Local1.Porciento_BD).Value.ToString().Replace('.', ',')); var areaCalculo = areaUtil * porcientos; _worksheet.Cells[i + 2, 10].Value = areaCalculo; #region codigo viejo //if (orderedList[i].Local1.Desglose1.Value == desglose) //{ // if (orderedList[i].Local1.LocalTipo.Value == localTipo) // { // _worksheet.Cells[i + 1, 1].Value = _locales.FirstOrDefault(l => l.RoomId == orderedList[i].Local1.RoomId).T_Grupo_Locales.Cod1; ; // _worksheet.Cells[i + 1, 2].Value = orderedList[i].Local1.CalcularCod2(); // _worksheet.Cells[i + 1, 3].Value = orderedList[i].Local1.CalcularCod3(); // _worksheet.Cells[i + 1, 5].Value = orderedList[i].Local1.Key_Name; // _worksheet.Cells[i + 1, 5].AutoFitColumns(); // _worksheet.Cells[i + 1, 6].Value = orderedList[i].Cantidad; // float coefArea = float.Parse(orderedList[i].Local1.CoefArea.Value); // var areaUtil = orderedList[i].Local1.CalcularArea(_proyecto.Cant_Habitaciones.GetValueOrDefault()); // //_worksheet.Cells[i + 1, 7].Value = coefArea; // _worksheet.Cells[i + 1, 7].Value = areaUtil; // double porcientos = double.Parse(_porcientos.FirstOrDefault(p => p.Id == orderedList[i].Local1.Porciento_BD).Value.ToString()); // _worksheet.Cells[i + 1, 8].Value = ModificarPorcientos(_porcientos.FirstOrDefault(p => p.Id == orderedList[i].Local1.Porciento_BD).Value.ToString().Replace('.',',')); // //var areaUtil = coefArea*porcientos; // var areaCalculo = areaUtil * porcientos; // _worksheet.Cells[i + 1, 9].Value = areaCalculo; // } // else // { // localTipo = orderedList[i].Local1.LocalTipo.Value; // _worksheet.Cells[i + 1, 4].Value = localTipo.ToUpper(); // } //} //else //{ // desglose = orderedList[i].Local1.Desglose1.Value; // _worksheet.Cells[i + 1, 4].Value = desglose.ToUpper(); //} #endregion } SplashScreenManager.CloseForm(); _excelPackage.Save(); MessageBox.Show("¡Exportado con éxito!"); } } }
public static void CleanAllTemplates() { using (var dbp = new DB_PLANTILLA()) { try { dbp.DeleteAllRecords <T_Local>(); //Acabados dbp.DeleteAllRecords <T_Ambiente>(); dbp.DeleteAllRecords <T_Catalogo_Techo>(); dbp.DeleteAllRecords <T_Catalogo_Pared>(); dbp.DeleteAllRecords <T_Catalogo_Rodapie>(); dbp.DeleteAllRecords <T_Catalogo_Suelo>(); dbp.DeleteAllRecords <T_Catalogo_Impermeable>(); //Climatizacion dbp.DeleteAllRecords <T_Climatizacion>(); dbp.DeleteAllRecords <T_Aire_Fresco>(); dbp.DeleteAllRecords <T_AF_Persona>(); dbp.DeleteAllRecords <T_AF_Metro_Cuadrado>(); dbp.DeleteAllRecords <T_Tratamiento>(); dbp.DeleteAllRecords <T_Equipamiento>(); dbp.DeleteAllRecords <T_Criterio>(); dbp.DeleteAllRecords <T_Renovaciones>(); dbp.DeleteAllRecords <T_W_Aire>(); //TT_TV dbp.DeleteAllRecords <T_Comunicaciones_Tv>(); dbp.DeleteAllRecords <T_TF>(); dbp.DeleteAllRecords <T_TD>(); dbp.DeleteAllRecords <T_TD_Pos>(); dbp.DeleteAllRecords <T_UPSC>(); dbp.DeleteAllRecords <T_TT_TV>(); dbp.DeleteAllRecords <T_DI>(); dbp.DeleteAllRecords <T_ALTV>(); dbp.DeleteAllRecords <T_UPSI>(); //Alojamiento dbp.DeleteAllRecords <T_Alojamiento_Tipo>(); dbp.DeleteAllRecords <T_Alojamiento>(); //Otros dbp.DeleteAllRecords <T_CoefArea>(); dbp.DeleteAllRecords <T_Mod>(); dbp.DeleteAllRecords <T_Tipo_Edificio>(); dbp.DeleteAllRecords <T_Porciento_BD>(); dbp.DeleteAllRecords <T_LocalTipo>(); dbp.DeleteAllRecords <T_Grupo_Locales>(); dbp.DeleteAllRecords <T_Subsistema_Area>(); dbp.DeleteAllRecords <T_Subsistema_Tipo>(); //Reiniciar los contadores de todas las tablas (local y ambiente no tienen autoincremento por lo que no se incluyen) dbp.ReseedTable(typeof(T_Catalogo_Techo)); dbp.ReseedTable(typeof(T_Catalogo_Pared)); dbp.ReseedTable(typeof(T_Catalogo_Rodapie)); dbp.ReseedTable(typeof(T_Catalogo_Suelo)); dbp.ReseedTable(typeof(T_Catalogo_Impermeable)); dbp.ReseedTable(typeof(T_Climatizacion)); dbp.ReseedTable(typeof(T_Aire_Fresco)); dbp.ReseedTable(typeof(T_AF_Persona)); dbp.ReseedTable(typeof(T_AF_Metro_Cuadrado)); dbp.ReseedTable(typeof(T_Tratamiento)); dbp.ReseedTable(typeof(T_Equipamiento)); dbp.ReseedTable(typeof(T_Criterio)); dbp.ReseedTable(typeof(T_Renovaciones)); dbp.ReseedTable(typeof(T_W_Aire)); dbp.ReseedTable(typeof(T_Comunicaciones_Tv)); dbp.ReseedTable(typeof(T_TF)); dbp.ReseedTable(typeof(T_TD)); dbp.ReseedTable(typeof(T_TD_Pos)); dbp.ReseedTable(typeof(T_UPSC)); dbp.ReseedTable(typeof(T_TT_TV)); dbp.ReseedTable(typeof(T_DI)); dbp.ReseedTable(typeof(T_ALTV)); dbp.ReseedTable(typeof(T_UPSI)); dbp.ReseedTable(typeof(T_CoefArea)); dbp.ReseedTable(typeof(T_Alojamiento_Tipo)); dbp.ReseedTable(typeof(T_Alojamiento)); dbp.ReseedTable(typeof(T_Mod)); dbp.ReseedTable(typeof(T_Tipo_Edificio)); dbp.ReseedTable(typeof(T_Porciento_BD)); dbp.ReseedTable(typeof(T_Grupo_Locales)); dbp.ReseedTable(typeof(T_LocalTipo)); dbp.ReseedTable(typeof(T_Subsistema_Area)); dbp.ReseedTable(typeof(T_Subsistema_Tipo)); } catch (Exception ex) { throw; } } //Reimportando todo ImportarExcel.Singleton(); ReinsertarAcabados.AdicionarAll <T_Catalogo_Suelo>(); ReinsertarAcabados.AdicionarAll <T_Catalogo_Pared>(); ReinsertarAcabados.AdicionarAll <T_Catalogo_Techo>(); ReinsertarAcabados.AdicionarAll <T_Catalogo_Impermeable>(); ReinsertarAcabados.AdicionarAll <T_Catalogo_Rodapie>(); ReinsertarAcabados.AdicionarAmbientes(); ReinsertarSubsistemas.InsertarSubsistemas <T_Subsistema_Tipo>(); ReinsertarSubsistemas.InsertarSubsistemas <T_Subsistema_Area>(); ReinsertarAlojamientos.InsertarAlojamiento(); ReinsertarLocal.InsertarParametros <T_Tratamiento>(22); ReinsertarLocal.InsertarParametros <T_Equipamiento>(23); ReinsertarLocal.InsertarParametros <T_Criterio>(24); ReinsertarLocal.InsertarParametros <T_AF_Metro_Cuadrado>(26); ReinsertarLocal.InsertarParametros <T_AF_Persona>(27); ReinsertarLocal.InsertarParametros <T_Renovaciones>(28); ReinsertarLocal.InsertarParametros <T_W_Aire>(29); ReinsertarLocal.InsertarAireFresco(); ReinsertarLocal.InsertarParametros <T_TF>(30); ReinsertarLocal.InsertarParametros <T_TD>(31); ReinsertarLocal.InsertarParametros <T_TD_Pos>(32); ReinsertarLocal.InsertarParametros <T_UPSC>(33); ReinsertarLocal.InsertarParametros <T_UPSI>(34); ReinsertarLocal.InsertarParametros <T_TT_TV>(35); ReinsertarLocal.InsertarParametros <T_DI>(36); ReinsertarLocal.InsertarParametros <T_ALTV>(37); ReinsertarGrupoLocales.InsertarGrupoLocales(); ReinsertarGrupoLocales.InsertarLocalesTipo(); ReinsertarLocal.InsertarParametroInt <T_Mod>(11); ReinsertarLocal.InsertarParametroFloat <T_Porciento_BD>(9); ReinsertarLocal.InsertarParametros <T_Tipo_Edificio>(12); ReinsertarLocal.InsertarLocales(); MessageBox.Show("Completado!"); }