public static CENNotaCreditoRptaRegistroNC registrarNC(CENNotaCredito nc) { CLNNotaCredito notacredito = new CLNNotaCredito(); CENNotaCreditoRptaRegistroNC obj = null; try { obj = notacredito.registrarNC(nc); } catch (Exception ex) { throw ex; } return(obj); }
public CENNotaCreditoRptaRegistroNC registrarNC(CENNotaCredito nc) { CADNotaCredito cadNotaCredito = new CADNotaCredito(); CENNotaCreditoRptaRegistroNC obj = null; int ntraVN = 0; try { ntraVN = cadNotaCredito.registrarVentaN(nc); obj = cadNotaCredito.registrarNotaCredito(nc, ntraVN); enviarNCSunat(nc.codVenta, obj.ntraNC, ntraVN, nc.tipo, nc.usuario, nc.ip, nc.mac); } catch (Exception ex) { throw ex; } return(obj); }
public int registrarVentaN(CENNotaCredito nc) { SqlConnection con = null; SqlCommand cmd = null; SqlDataReader dr = null; int ntraVN = 0; CADConexion CadCx = new CADConexion(); string xmlListDetalle = ObjectToXMLGeneric <List <CENListaDevueltos> >(nc.listaDevueltos); //XML de lista de detalles try { con = new SqlConnection(CadCx.CxSQL()); cmd = new SqlCommand("pa_notacredito_registrar_venta_negativo", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@p_codigo", SqlDbType.Int).Value = nc.codVenta; cmd.Parameters.Add("@p_listaDetalles", SqlDbType.Xml).Value = xmlListDetalle; cmd.Parameters.Add("@p_importe", SqlDbType.Money).Value = nc.importe; cmd.Parameters.Add("@p_usuario", SqlDbType.VarChar, 20).Value = nc.usuario; cmd.Parameters.Add("@p_ip", SqlDbType.VarChar, 20).Value = nc.ip; cmd.Parameters.Add("@p_mac", SqlDbType.VarChar, 20).Value = nc.mac; con.Open(); dr = cmd.ExecuteReader(); while (dr.Read()) { ntraVN = Convert.ToInt32(dr["ntraVN"]); } } catch (Exception ex) { throw ex; } finally { con.Close(); } return(ntraVN); }
public CENNotaCreditoRptaRegistroNC registrarNotaCredito(CENNotaCredito nc, int ntraVN) { SqlConnection con = null; SqlCommand cmd = null; SqlDataReader dr = null; CENNotaCreditoRptaRegistroNC objeto = null; CADConexion CadCx = new CADConexion(); DateTime fecha = DateTime.Now; try { con = new SqlConnection(CadCx.CxSQL()); if (nc.tipo == 1) //total { cmd = new SqlCommand("pa_notacredito_registrar_nc_total", con); } else //parcial { cmd = new SqlCommand("pa_notacredito_registrar_nc_parcial", con); } cmd.CommandType = CommandType.StoredProcedure; if (nc.tipo == 1) //total { cmd.Parameters.Add("@p_flagReversion", SqlDbType.Int).Value = nc.flagReversion; } cmd.Parameters.Add("@p_codVenta", SqlDbType.Int).Value = nc.codVenta; cmd.Parameters.Add("@p_codVentaNega", SqlDbType.Int).Value = ntraVN; cmd.Parameters.Add("@p_codMotivo", SqlDbType.Char, 2).Value = nc.codMotivo; fecha = ConvertFechaStringToDate(nc.fecha); cmd.Parameters.Add("@p_fecha", SqlDbType.Date).Value = fecha; cmd.Parameters.Add("@p_tipo", SqlDbType.Int).Value = nc.tipo; cmd.Parameters.Add("@p_importe", SqlDbType.Money).Value = nc.importe; cmd.Parameters.Add("@p_usuario", SqlDbType.VarChar, 20).Value = nc.usuario; cmd.Parameters.Add("@p_ip", SqlDbType.VarChar, 20).Value = nc.ip; cmd.Parameters.Add("@p_mac", SqlDbType.VarChar, 20).Value = nc.mac; cmd.Parameters.Add("@p_codSucursal", SqlDbType.Int).Value = nc.codSucursal; cmd.Parameters.Add("@p_codUsuario", SqlDbType.Int).Value = nc.codUsuario; con.Open(); dr = cmd.ExecuteReader(); while (dr.Read()) { string a; objeto = new CENNotaCreditoRptaRegistroNC(); objeto.ntraNC = Convert.ToInt32(dr["ntraNC"]); a = dr["msje"].ToString(); } } catch (Exception ex) { throw ex; } finally { con.Close(); } return(objeto); }