public Boolean AnularDB(Af_Activo_fijo_x_ct_centro_costo_sub_centro_costo_Info info) { try { using (EntitiesActivoFijo_FJ Context = new EntitiesActivoFijo_FJ()) { Af_Activo_fijo_x_ct_centro_costo_sub_centro_costo Entity = Context.Af_Activo_fijo_x_ct_centro_costo_sub_centro_costo.FirstOrDefault(q => q.IdActivoFijo_AF == info.IdActivoFijo_AF && q.IdEmpresa_AF == info.IdEmpresa_AF && q.Estado == true); if (Entity != null) { Entity.Estado = false; Context.SaveChanges(); } } return(true); } catch (Exception ex) { string mensaje = ""; string arreglo = ToString(); tb_sis_Log_Error_Vzen_Data oDataLog = new tb_sis_Log_Error_Vzen_Data(); tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); mensaje = ex.InnerException + " " + ex.Message; throw new Exception(ex.InnerException.ToString()); } }
public Boolean GuardarDB(Af_Activo_fijo_x_ct_centro_costo_sub_centro_costo_Info info) { try { using (EntitiesActivoFijo_FJ Context = new EntitiesActivoFijo_FJ()) { Af_Activo_fijo_x_ct_centro_costo_sub_centro_costo Entity = new Af_Activo_fijo_x_ct_centro_costo_sub_centro_costo(); Entity.IdEmpresa_AF = info.IdEmpresa_AF; Entity.IdActivoFijo_AF = info.IdActivoFijo_AF; Entity.IdEmpresa_Scc = info.IdEmpresa_Scc; Entity.IdCentroCosto_Scc = info.IdCentroCosto_Scc; Entity.IdCentroCosto_sub_centro_costo_Scc = info.IdCentroCosto_sub_centro_costo_Scc; Entity.Estado = true; Context.Af_Activo_fijo_x_ct_centro_costo_sub_centro_costo.Add(Entity); Context.SaveChanges(); } return(true); } catch (Exception ex) { string mensaje = ""; string arreglo = ToString(); tb_sis_Log_Error_Vzen_Data oDataLog = new tb_sis_Log_Error_Vzen_Data(); tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); mensaje = ex.InnerException + " " + ex.Message; throw new Exception(ex.InnerException.ToString()); } }
public List <Af_Activo_fijo_x_ct_centro_costo_sub_centro_costo_Info> Get_List_Af_x_SCC(int idEmpresa, string idCentro_costo, string idCentro_costo_sub_centro_costo) { try { List <Af_Activo_fijo_x_ct_centro_costo_sub_centro_costo_Info> Lista = new List <Af_Activo_fijo_x_ct_centro_costo_sub_centro_costo_Info>(); using (EntitiesActivoFijo_FJ Context = new EntitiesActivoFijo_FJ()) { var lst = from q in Context.vwAf_Activo_fijo_x_ct_centro_costo where idEmpresa == q.IdEmpresa && idCentro_costo == q.IdCentroCosto && q.IdCentroCosto_sub_centro_costo == idCentro_costo_sub_centro_costo select q; foreach (var item in lst) { Af_Activo_fijo_x_ct_centro_costo_sub_centro_costo_Info info = new Af_Activo_fijo_x_ct_centro_costo_sub_centro_costo_Info(); info.IdEmpresa_AF = item.IdEmpresa; info.IdActivoFijo = item.IdActivoFijo; info.IdActivoFijo_AF = item.IdActivoFijo; info.IdEmpresa_Scc = item.IdEmpresa_cc == null? idEmpresa : (int)item.IdEmpresa_cc; info.IdCentroCosto_Scc = item.IdCentroCosto; info.IdCentroCosto_sub_centro_costo_Scc = item.IdCentroCosto_sub_centro_costo_Scc; info.Estado = item.Estado_Ubicacion == null ? false : (bool)item.Estado_Ubicacion; info.Af_Nombre = item.Af_Nombre; info.IdUnidadFact_cat = item.IdUnidadFact_cat; info.Af_ValorUnidad_Actu = item.Af_ValorUnidad_Actu; info.IdCentroCosto = item.IdCentroCosto; info.nom_punto_cargo = item.nom_punto_cargo; info.Estado_Ubicación = item.Estado_Ubicacion; info.IdEmpresa_cli = item.IdEmpresa_cli; info.IdCliente_cli = item.IdCliente_cli; info.pe_nombreCompleto = item.pe_nombreCompleto; info.IdEmpresa_PC = item.IdEmpresa_PC; info.IdPunto_cargo_PC = item.IdPunto_cargo_PC; info.nom_Centro_costo = item.nom_Centro_costo; info.nom_UnidadFact = item.nom_UnidadFact; info.Asignado = true; info.Af_DescripcionCorta = item.Af_DescripcionCorta; Lista.Add(info); } } return(Lista); } catch (Exception ex) { string mensaje = ""; string arreglo = ToString(); tb_sis_Log_Error_Vzen_Data oDataLog = new tb_sis_Log_Error_Vzen_Data(); tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); mensaje = ex.InnerException + " " + ex.Message; throw new Exception(ex.InnerException.ToString()); } }
private Boolean Validar_Registro_det(fa_registro_unidades_x_equipo_det_Info info_det) { try { List <fa_registro_unidades_x_equipo_det_Info> lst_Detalles_x_Activo = new List <fa_registro_unidades_x_equipo_det_Info>(); info_ActF_x_CC = list_ActF_x_CC.FirstOrDefault(q => q.IdEmpresa_AF == info_det.IdEmpresa && q.IdActivoFijo_AF == info_det.IdActivoFijo); if (info_det.Valor <= info_ActF_x_CC.Af_ValorUnidad_Actu) { MessageBox.Show("El valor ingresado es menor al valor actual del equipo " + info_ActF_x_CC.Af_DescripcionCorta + ", por favor ingrese un valor mayor.", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } lst_Detalles_x_Activo = info_Registro.Lst_det.Where(q => q.IdEmpresa == info_det.IdEmpresa && q.IdActivoFijo == info_det.IdActivoFijo).ToList(); foreach (var item in lst_Detalles_x_Activo) { if (item.IdFecha < info_det.IdFecha) { if (item.Valor > info_det.Valor) { MessageBox.Show("Existe un registro de menor fecha con un valor mayor al que ha ingresado, por favor ingrese un valor mayor.", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } } else { if (item.Valor < info_det.Valor) { MessageBox.Show("Existe un registro de mayor fecha con un valor menor al que ha ingresado, por favor ingrese un valor menor.", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } } } return(true); } catch (Exception ex) { string NameMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name; MessageBox.Show(param.Get_Mensaje_sys(enum_Mensajes_sys.Error_comunicarse_con_sistemas) + ex.Message + " ", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Error); Log_Error_bus.Log_Error(NameMetodo + " - " + ex.ToString()); return(false); } }
public Boolean AnularDB(Af_Activo_fijo_x_ct_centro_costo_sub_centro_costo_Info info) { try { return(oData.AnularDB(info)); } catch (Exception ex) { string mensaje = ""; string arreglo = ToString(); tb_sis_Log_Error_Vzen_Data oDataLog = new tb_sis_Log_Error_Vzen_Data(); tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); mensaje = ex.InnerException + " " + ex.Message; throw new Exception(ex.InnerException.ToString()); } }
private void gridViewRegistros_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { try { Af_Activo_fijo_x_ct_centro_costo_sub_centro_costo_Info info_activo = new Af_Activo_fijo_x_ct_centro_costo_sub_centro_costo_Info(); if (e.Column != gridViewRegistros.Columns["Fecha"] && e.Column != gridViewRegistros.Columns["Día"]) { if (info_Registro.Lst_det == null) { info_Registro.Lst_det = new List <fa_registro_unidades_x_equipo_det_Info>(); } int IdFecha = Convert.ToInt32(gridViewRegistros.GetRowCellValue(e.RowHandle, gridViewRegistros.Columns["IdFecha"])); string CodActivoFijo = e.Column.ToString(); info_activo = list_ActF_x_CC.Where(v => v.Af_DescripcionCorta == CodActivoFijo).FirstOrDefault(); double Valor = get_Valor(e.Value.ToString()); info_Registro_det = info_Registro.Lst_det.FirstOrDefault(q => q.IdActivoFijo == info_activo.IdActivoFijo && q.IdFecha == IdFecha); if (info_Registro_det == null) { if (Valor != 0) { info_Registro_det = new fa_registro_unidades_x_equipo_det_Info(); info_Registro_det.IdEmpresa = param.IdEmpresa; info_Registro_det.IdFecha = IdFecha; info_Registro_det.IdActivoFijo = info_activo.IdActivoFijo; info_Registro_det.Valor = Valor; info_Registro_det.IdPeriodo = ucCon_Periodo1.Get_Periodo_Info().IdPeriodo; if (Validar_Registro_det(info_Registro_det)) { info_Registro.Lst_det.Add(info_Registro_det); } else { info_ActF_x_CC = list_ActF_x_CC.FirstOrDefault(q => q.IdEmpresa_AF == param.IdEmpresa && q.IdActivoFijo_AF == info_activo.IdActivoFijo); gridViewRegistros.SetRowCellValue(e.RowHandle, info_ActF_x_CC.Af_DescripcionCorta, null); } } } else if (Valor != 0 && Valor != null) { info_Registro_det.Valor = Valor; if (Validar_Registro_det(info_Registro_det)) { info_Registro.Lst_det.FirstOrDefault(q => q.IdActivoFijo == info_activo.IdActivoFijo && q.IdFecha == IdFecha).Valor = Valor; } else { info_ActF_x_CC = list_ActF_x_CC.FirstOrDefault(q => q.IdEmpresa_AF == param.IdEmpresa && q.IdActivoFijo_AF == info_activo.IdActivoFijo); gridViewRegistros.SetRowCellValue(e.RowHandle, info_ActF_x_CC.Af_DescripcionCorta, null); } } else { info_Registro.Lst_det.Remove(info_Registro.Lst_det.FirstOrDefault(q => q.IdActivoFijo == info_activo.IdActivoFijo && q.IdFecha == IdFecha)); } } } catch (Exception ex) { string NameMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name; MessageBox.Show(param.Get_Mensaje_sys(enum_Mensajes_sys.Error_comunicarse_con_sistemas) + ex.Message + " ", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Error); Log_Error_bus.Log_Error(NameMetodo + " - " + ex.ToString()); } }