public Boolean AnularDB(in_Ing_Egr_Inven_Info info, ref string msgs)
        {
            try
            {
                in_Ing_Egr_Inven_det_Bus BusDeta_Ing_Egr_Inven = new in_Ing_Egr_Inven_det_Bus();
                Boolean Respuesta_anulacion            = false;
                Boolean Respuesta_anulacion_Inventario = false;

                in_movi_inven_tipo_Info info_movi_inven_tipo = new in_movi_inven_tipo_Info();
                in_movi_inven_tipo_Bus  bus_movi_inven_tipo  = new in_movi_inven_tipo_Bus();
                info_movi_inven_tipo = bus_movi_inven_tipo.Get_Info_movi_inven_tipo(info.IdEmpresa, info.IdMovi_inven_tipo);

                in_Motivo_Inven_Info info_motivo_inven = new in_Motivo_Inven_Info();
                in_Motivo_Inven_Bus  bus_motivo_inven  = new in_Motivo_Inven_Bus();
                info_motivo_inven = bus_motivo_inven.Get_Info_Motivo_Inven(info.IdEmpresa, info.IdMotivo_Inv == null ? 0 : Convert.ToInt32(info.IdMotivo_Inv));

                string genero_movi = info_movi_inven_tipo.Genera_Movi_Inven == true && info_motivo_inven.Genera_Movi_Inven == "S" ? "S" : "N";

                if (info.listIng_Egr.Count() > 0)
                {
                    info.IdEstadoAproba = info.listIng_Egr.Max(q => q.IdEstadoAproba);
                }

                if (info.IdEstadoAproba == "APRO")
                {
                    odata.Reversar_Aprobacion(info.IdEmpresa, info.IdSucursal, info.IdMovi_inven_tipo, info.IdNumMovi, genero_movi);
                }
                info.IdusuarioUltAnu = param.IdUsuario;
                Respuesta_anulacion  = odata.AnularDB(info, ref msgs);

                if (Respuesta_anulacion)
                {
                    Respuesta_anulacion_Inventario = true;
                }

                //Agrupo lista de ordenes de compra
                var lst_oc = (from q in info.listIng_Egr
                              where q.IdOrdenCompra != null
                              group q by new { q.IdEmpresa_oc, q.IdSucursal_oc, q.IdOrdenCompra }
                              into grouping
                              select new { grouping.Key.IdEmpresa_oc, grouping.Key.IdSucursal_oc, grouping.Key.IdOrdenCompra }
                              ).ToList();

                BusDeta_Ing_Egr_Inven.Modificar_Enserar_Campos_OC(info.listIng_Egr);

                foreach (var item in lst_oc)
                {
                    bus_oc.Modificar_Estado_Cierre(Convert.ToInt32(item.IdEmpresa_oc), Convert.ToInt32(item.IdSucursal_oc), Convert.ToInt32(item.IdOrdenCompra), "ABI");
                }

                return(Respuesta_anulacion && Respuesta_anulacion_Inventario);
            }
            catch (Exception ex)
            {
                Core.Erp.Info.Log_Exception.LoggingManager.Logger.Log(Core.Erp.Info.Log_Exception.LoggingCategory.Error, ex.Message);
                throw new Core.Erp.Info.Log_Exception.DalException(string.Format("", "AnularDB", ex.Message), ex)
                      {
                          EntityType = typeof(in_Ing_Egr_Inven_Bus)
                      };
            }
        }
        public Boolean AnularDB(in_Ing_Egr_Inven_Info info, ref string msgs)
        {
            try
            {
                in_Ing_Egr_Inven_det_Bus         BusDeta_Ing_Egr_Inven     = new in_Ing_Egr_Inven_det_Bus();
                List <in_Ing_Egr_Inven_det_Info> ListDet_Ing_Egr_Inven_det = new List <in_Ing_Egr_Inven_det_Info>();
                Boolean Respuesta_anulacion            = false;
                Boolean Respuesta_anulacion_Inventario = false;



                Respuesta_anulacion = odata.AnularDB(info, ref msgs);

                if (Respuesta_anulacion)
                {
                    ListDet_Ing_Egr_Inven_det = BusDeta_Ing_Egr_Inven.Get_List_Ing_Egr_Inven_det_x_Num_Movimiento(info.IdEmpresa, info.IdSucursal, info.IdMovi_inven_tipo, info.IdNumMovi);

                    in_movi_inve_Bus  BusMovi_Inven           = new in_movi_inve_Bus();
                    in_movi_inve_Info Info_movi_inve_a_Anular = new in_movi_inve_Info();

                    foreach (var item in ListDet_Ing_Egr_Inven_det)
                    {
                        if (item.IdNumMovi_inv != null)
                        {
                            Info_movi_inve_a_Anular = new in_movi_inve_Info();

                            Info_movi_inve_a_Anular = BusMovi_Inven.Get_Info_Movi_inven(Convert.ToInt32(item.IdEmpresa_inv), Convert.ToInt32(item.IdSucursal_inv), Convert.ToInt32(item.IdBodega_inv), Convert.ToInt32(item.IdMovi_inven_tipo_inv), Convert.ToDecimal(item.IdNumMovi_inv));
                            if (Info_movi_inve_a_Anular != null)
                            {
                                if (Info_movi_inve_a_Anular.IdEmpresa != 0)
                                {
                                    Respuesta_anulacion_Inventario = BusMovi_Inven.AnularDB(Info_movi_inve_a_Anular, DateTime.Now, ref msgs);
                                }
                                else
                                {
                                    Respuesta_anulacion_Inventario = true;//por que puede q no haya movi invent
                                }
                            }
                        }
                        else
                        {
                            Respuesta_anulacion_Inventario = true;
                        }
                    }
                }

                //Agrupo lista de ordenes de compra
                var lst_oc = (from q in ListDet_Ing_Egr_Inven_det
                              where q.IdOrdenCompra != null
                              group q by new { q.IdEmpresa_oc, q.IdSucursal_oc, q.IdOrdenCompra }
                              into grouping
                              select new { grouping.Key.IdEmpresa_oc, grouping.Key.IdSucursal_oc, grouping.Key.IdOrdenCompra }
                              ).ToList();

                BusDeta_Ing_Egr_Inven.Modificar_Enserar_Campos_OC(ListDet_Ing_Egr_Inven_det);

                foreach (var item in lst_oc)
                {
                    bus_oc.Modificar_Estado_Cierre(Convert.ToInt32(item.IdEmpresa_oc), Convert.ToInt32(item.IdSucursal_oc), Convert.ToInt32(item.IdOrdenCompra), "ABI");
                }

                return(Respuesta_anulacion && Respuesta_anulacion_Inventario);
            }
            catch (Exception ex)
            {
                Core.Erp.Info.Log_Exception.LoggingManager.Logger.Log(Core.Erp.Info.Log_Exception.LoggingCategory.Error, ex.Message);
                throw new Core.Erp.Info.Log_Exception.DalException(string.Format("", "AnularDB", ex.Message), ex)
                      {
                          EntityType = typeof(in_Ing_Egr_Inven_Bus)
                      };
            }
        }