Beispiel #1
0
        public bool AnularDB(ct_Distribucion_Info info)
        {
            try
            {
                using (SqlConnection connection = new SqlConnection(ConexionERP.GetConnectionString()))
                {
                    connection.Open();
                    SqlCommand command = new SqlCommand();
                    command.Connection  = connection;
                    command.CommandText = "UPDATE [dbo].[ct_Distribucion]"
                                          + " SET [Estado] = 0"
                                          + " ,[IdUsuarioAnulacion] = '" + info.IdUsuario + "'"
                                          + " ,[FechaAnulacion] = GETDATE()"
                                          + " WHERE IdEmpresa = " + info.IdEmpresa.ToString() + " AND IdDistribucion = " + info.IdDistribucion.ToString() + ";";

                    decimal IdCbteCble_rev = 0;
                    odatact.ReversoCbteCble(info.IdEmpresa,
                                            info.IdCbteCble,
                                            info.IdTipoCbte,
                                            1,
                                            ref IdCbteCble_rev,
                                            ref MensajeError,
                                            info.IdUsuario,
                                            info.IdUsuario
                                            );

                    command.ExecuteNonQuery();
                }
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public Boolean ReversoCbteCble(int IdEmpresa, decimal idcbtecble, int idtipocble, int idtipocble_rev,
                                       ref decimal idcbtecble_rev, ref string msg, string user, string MotivoAnulacion = "")
        {
            try
            {
                Boolean respuesta = true;

                ct_cbtecble_Reversado_Data _dataReversado = new ct_cbtecble_Reversado_Data();
                ct_cbtecble_Reversado_Info _InfoReversado = new ct_cbtecble_Reversado_Info();

                _InfoReversado = _dataReversado.Get_CbteCble_Reversado_Info(IdEmpresa, idtipocble, idcbtecble);

                if (_InfoReversado.IdCbteCble_Anu == 0)//no esta reversado se puede reversar
                {
                    respuesta = data.ReversoCbteCble(IdEmpresa, idcbtecble, idtipocble, idtipocble_rev, ref idcbtecble_rev,
                                                     ref msg, param.IdUsuario, MotivoAnulacion, param.Fecha_Transac.ToString());
                }
                else
                {
                    respuesta = true;
                }

                return(respuesta);
            }
            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("", "ReversoCbteCble", ex.Message), ex)
                      {
                          EntityType = typeof(ct_Cbtecble_Bus)
                      };
            }
        }
        public in_movi_inve_x_ct_cbteCble_Info Anular_reversar_Diario_x_Movi_Inven
            (int IdEmpresa, int idsucursal, int idbodega, int idmovi_inven_tipo, decimal idNum_Movi, int IdTipoCbteCble_x_anulacion
            , ref decimal IdCbteCble_Reverso)
        {
            try
            {
                EntitiesInventario entity = new EntitiesInventario();
                in_movi_inve_x_ct_cbteCble_Info Info_Movi = new in_movi_inve_x_ct_cbteCble_Info();

                var Select = from q in entity.in_movi_inve_x_ct_cbteCble
                             where q.IdEmpresa_ct == IdEmpresa && q.IdSucursal == idsucursal &&
                             q.IdBodega == idbodega && q.IdMovi_inven_tipo == idmovi_inven_tipo &&
                             q.IdNumMovi == idNum_Movi
                             select q;


                foreach (var item in Select)
                {
                    Info_Movi.IdEmpresa         = item.IdEmpresa;
                    Info_Movi.IdSucursal        = item.IdSucursal;
                    Info_Movi.IdBodega          = item.IdBodega;
                    Info_Movi.IdMovi_inven_tipo = item.IdMovi_inven_tipo;
                    Info_Movi.IdNumMovi         = item.IdNumMovi;

                    Info_Movi.IdEmpresa_ct = item.IdEmpresa_ct;
                    Info_Movi.IdTipoCbte   = item.IdTipoCbte;
                    Info_Movi.IdCbteCble   = item.IdCbteCble;
                    Info_Movi.Observacion  = item.Observacion;
                }

                string mensaje = "";

                ct_Cbtecble_Data Cbte_Data = new ct_Cbtecble_Data();
                Cbte_Data.ReversoCbteCble(Info_Movi.IdEmpresa_ct, Info_Movi.IdCbteCble, Info_Movi.IdTipoCbte
                                          , IdTipoCbteCble_x_anulacion, ref IdCbteCble_Reverso, ref mensaje, "sys");



                return(Info_Movi);
            }
            catch (Exception ex)
            {
                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.ToString() + " " + ex.Message;
                throw new Exception(ex.ToString());
            }
        }