public JsonResult guardarNota(NotaCreditoHeader nota, List <PedidosFacturadosDetalle> detalle) { var seguridad = new PedidosManager(); return(Json(new { Success = "OK", Result = seguridad.guardarNota( nota, detalle, (long)HttpContext.Session["IdSesion"] ) })); }
public string guardarNota(NotaCreditoHeader _nota, List <PedidosFacturadosDetalle> _detalle, long idsesion) { try { string Sp = "dbo.GuardarNotaDeCredito"; SqlParameter[] Parametros = new SqlParameter[9]; Parametros[0] = new SqlParameter("@IdPedido", _nota.IdPedido); Parametros[1] = new SqlParameter("@IdClienteFactura", _nota.IdClienteFactura); Parametros[2] = new SqlParameter("@UsoCfdi", _nota.UsoCfdi); Parametros[3] = new SqlParameter("@TipoDeDocumento", _nota.TipoDeDocumento); Parametros[4] = new SqlParameter("@SubTotal", _nota.SubTotal); Parametros[5] = new SqlParameter("@Iva", _nota.Iva); Parametros[6] = new SqlParameter("@Total", _nota.Total); Parametros[7] = new SqlParameter("@TasaIva", _nota.TasaIva); Parametros[8] = new SqlParameter("@IdSesion", idsesion); string _valor = new Datos().RegresaValor(Sp, Parametros); foreach (PedidosFacturadosDetalle _det in _detalle) { this.guardarDetalleNota(_det, idsesion, int.Parse(_valor)); } if (_nota.CfdiRelacionado == null) { _nota.CfdiRelacionado = string.Empty; } _nota.CfdiRelacionado = _nota.CfdiRelacionado.Trim(); if (_nota.CfdiRelacionado != string.Empty) { string[] _cfdis = _nota.CfdiRelacionado.Split('\n'); foreach (string _cfd in _cfdis) { if (_cfd.Trim() != string.Empty) { string _rel = this.guardarDetalleCfdiRelacionado(int.Parse(_valor), _nota.IdPedido, _cfd.Trim(), idsesion); } } } var Respuesta = new NotaDeCreditoTxtManager().GenerarTxtNotaDeCredito(int.Parse(_valor)); return(_valor); } catch (Exception Error) { throw Error; } }