Ejemplo n.º 1
0
        public Boolean GrabarDB(cp_orden_giro_Info Info_OrdenGiro, ref decimal idCbteCble, ref string mensaje)
        {
            Boolean res = false;

            try
            {
                //validar serie y #Documento Factura



                if (Validar_y_corregir_objeto(Info_OrdenGiro, ref mensaje))
                {
                    if (data.ExisteFacturaPorProveedor(Info_OrdenGiro.IdEmpresa, Info_OrdenGiro.IdProveedor, Info_OrdenGiro.co_serie, Info_OrdenGiro.co_factura))
                    {
                        mensaje = "La Factura#: " + Info_OrdenGiro.co_serie + "-" + Info_OrdenGiro.co_factura + ". Ya se encuentra ingresada";
                        res     = false;
                        return(false);
                    }


                    if (!CbteCble_B.GrabarDB(Info_OrdenGiro.Info_CbteCble_x_OG, ref idCbteCble, ref mensaje))
                    {
                        mensaje = "No se pudo Ingresar el Cbte Cble de la Factura Proveedor \n Comuníquese con sistema por favor" + mensaje; return(false);
                    }
                    else
                    {
                        Info_OrdenGiro.IdCbteCble_Ogiro = idCbteCble;
                        if (!data.GrabarDB(Info_OrdenGiro, ref mensaje))
                        {
                            mensaje = "No se pudo Ingresar la Factura Proveedor \n Comuníquese con sistema por favor" + mensaje; return(false);
                        }


                        if (Info_OrdenGiro.lst_formasPagoSRI != null)
                        {
                            if (Info_OrdenGiro.lst_formasPagoSRI.Count != 0)
                            {
                                if (!pagoSRI_B.GuardarDB(Info_OrdenGiro.lst_formasPagoSRI, Info_OrdenGiro.IdEmpresa, Info_OrdenGiro.IdTipoCbte_Ogiro, Info_OrdenGiro.IdCbteCble_Ogiro, ref mensaje))
                                {
                                    mensaje = "No se pudo Ingresar la(s) Forma(s) de Pago \n Comuníquese con sistema por favor" + mensaje; return(false);
                                }
                            }
                        }

                        if (Info_OrdenGiro.Info_cuotas_x_doc.lst_cuotas_det.Count != 0)
                        {
                            Info_OrdenGiro.Info_cuotas_x_doc.IdEmpresa_ct = Info_OrdenGiro.IdEmpresa;
                            Info_OrdenGiro.Info_cuotas_x_doc.IdTipoCbte   = Info_OrdenGiro.IdTipoCbte_Ogiro;
                            Info_OrdenGiro.Info_cuotas_x_doc.IdCbteCble   = Info_OrdenGiro.IdCbteCble_Ogiro;
                            bus_cuotas_x_doc.GuardarDB(Info_OrdenGiro.Info_cuotas_x_doc);
                        }

                        if (Info_OrdenGiro.Info_Retencion != null && Info_OrdenGiro.Info_Retencion.Info_CbteCble_x_RT != null)
                        {
                            if (Info_OrdenGiro.Info_Retencion.IdEmpresa != 0)
                            {
                                Info_OrdenGiro.Info_Retencion.IdCbteCble_Ogiro = Info_OrdenGiro.IdCbteCble_Ogiro = idCbteCble;


                                //grabando la retencion

                                if (Bus_Retencion.Graba_CbteCble_Ret_FactProveedor(Info_OrdenGiro.Info_Retencion, Info_OrdenGiro.Info_Retencion.Info_CbteCble_x_RT, ref mensaje))
                                {
                                    //actualizando el suencial de la retencion serie y #retencion
                                    Bus_Retencion.Modificar_Num_Retencion(Info_OrdenGiro.Info_Retencion, ref mensaje);
                                }
                                else
                                {
                                    mensaje = "Hubo un inconveniente al ingresar la retención comuniquese con sistemas.." + mensaje; res = false;
                                }
                            }
                        }

                        decimal IdCbteCble = 0; IdCbteCble = idCbteCble;
                    }
                }
                else
                {
                    res = false;
                    return(false);
                }


                res = true;
            }
            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("", "GrabarFactProveedor", ex.Message), ex)
                      {
                          EntityType = typeof(cp_orden_giro_Bus)
                      };
            }
            return(res);
        }