示例#1
0
        public Boolean GuardarDB(List <fa_registro_unidades_x_equipo_det_ini_x_Af_Info> Lista)
        {
            try
            {
                using (Entity_Facturacion_FJ Context = new Entity_Facturacion_FJ())
                {
                    foreach (var item in Lista)
                    {
                        fa_registro_unidades_x_equipo_det_ini_x_Af Entity = new fa_registro_unidades_x_equipo_det_ini_x_Af();
                        Entity.IdEmpresa           = item.IdEmpresa;
                        Entity.IdRegistro          = item.IdRegistro;
                        Entity.IdUnidadFact_cat    = item.IdUnidadFact_cat;
                        Entity.IdActivoFijo        = item.IdActivoFijo;
                        Entity.Af_ValorUnidad_Actu = item.Af_ValorUnidad_Actu;
                        Context.fa_registro_unidades_x_equipo_det_ini_x_Af.Add(Entity);
                        Context.SaveChanges();
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                string MensajeError = "";
                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 MensajeError);
                MensajeError = ex.ToString();
                throw new Exception(ex.ToString());
            }
        }
        public Boolean ModificarDB(List <fa_registro_unidades_x_equipo_det_ini_x_Af_Info> Lista)
        {
            try
            {
                using (Entity_Facturacion_FJ Context = new Entity_Facturacion_FJ())
                {
                    foreach (var item in Lista)
                    {
                        fa_registro_unidades_x_equipo_det_ini_x_Af Entity = Context.fa_registro_unidades_x_equipo_det_ini_x_Af.FirstOrDefault(q => q.IdEmpresa == item.IdEmpresa && q.IdRegistro == item.IdRegistro && q.IdActivoFijo == item.IdActivoFijo);
                        if (Entity != null)
                        {
                            Entity.IdEmpresa_hn  = item.IdEmpresa_hn;
                            Entity.IdSucursal_hn = item.IdSucursal_hn;
                            Entity.IdBodega_hn   = item.IdBodega_hn;
                            Entity.IdCbteVta_hn  = item.IdCbteVta_hn;

                            Entity.IdEmpresa_he  = item.IdEmpresa_he;
                            Entity.IdSucursal_he = item.IdSucursal_he;
                            Entity.IdBodega_he   = item.IdBodega_he;
                            Entity.IdCbteVta_he  = item.IdCbteVta_he;
                            Context.SaveChanges();
                        }
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                string MensajeError = "";
                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 MensajeError);
                MensajeError = ex.ToString();
                throw new Exception(ex.ToString());
            }
        }