public Factura Obtener(string numero) { Factura facturaEncontrada = null; string sql = "SELECT * FROM FACTURA_CABECERA WHERE NUMERO_DOCUMENTO=@num"; using (SqlConnection con = new SqlConnection(ConexionUtil.Cadena)) { con.Open(); using (SqlCommand com = new SqlCommand(sql, con)) { com.Parameters.Add(new SqlParameter("@num", numero)); using (SqlDataReader resultado = com.ExecuteReader()) { if (resultado.Read()) { facturaEncontrada = new Factura() { Numero = (string)Convert.ToString(resultado["NUMERO_DOCUMENTO"]), Cliente = (string)Convert.ToString(resultado["COD_CLIENTE"]), Fecha = (string)Convert.ToString(resultado["FEC_EMISION"]), ImporteBruto = (string)Convert.ToString(resultado["IMPORTE_TOTAL_BRUTO"]), ImporteVenta = (string)Convert.ToString(resultado["IMPORTE_VALOR_VENTA"]), ImporteIGV = (string)Convert.ToString(resultado["IMPORTE_IGV"]), ImporteTotalVenta = (string)Convert.ToString(resultado["IMPORTE_TOTAL_NETO"]) }; } } } } return facturaEncontrada; }
public Factura CrearFactura(Factura facturaACrear) { if ("11".Equals(facturaACrear.Numero)) { throw new WebFaultException<string>( "Cliente moroso", HttpStatusCode.HttpVersionNotSupported); } return dao.Crear(facturaACrear); }
private void button1_Click(object sender, EventArgs e) { String numero = dataGridView1.CurrentRow.Cells[7].Value.ToString(); String cliente = dataGridView1.CurrentRow.Cells[2].Value.ToString(); String fecha = "01/10/2016"; String importe = dataGridView1.CurrentRow.Cells[5].Value.ToString(); string postdata = "{\"bumero\":\"" + numero + "\",\"Fecha\":\"" + fecha + "\",\"Cliente\":\"" + cliente + "\",\"ImporteBruto\":\"" + importe + "\",\"ImporteVenta\":\"" + importe + "\",\"ImporteIGV\":\"" + importe + "\",\"ImporteTotalVenta\":\"" + importe + "\"}"; //MessageBox.Show(postdata, "Sistema de Pedidos"); try { byte[] data = Encoding.UTF8.GetBytes(postdata); HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://*****:*****@".\private$\facturas"; if (!MessageQueue.Exists(rutaCola)) { MessageQueue.Create(rutaCola); } MessageQueue cola = new MessageQueue(rutaCola); System.Messaging.Message mensaje = new System.Messaging.Message(); mensaje.Label = "Factura " + numero; mensaje.Body = new Factura() { Numero = numero, Cliente = cliente, Fecha = fecha, ImporteBruto = importe, ImporteIGV = importe, ImporteVenta = importe, ImporteTotalVenta = importe }; cola.Send(mensaje); MessageBox.Show("Factura enviada por MSMQ", "Error"); } }
public Factura Crear(Factura facturaGuardar) { Factura facturaCreado = null; string sql = "INSERT INTO FACTURA_CABECERA (NUMERO_DOCUMENTO,FEC_EMISION,COD_CLIENTE,IMPORTE_TOTAL_BRUTO,IMPORTE_VALOR_VENTA,IMPORTE_IGV,IMPORTE_TOTAL_NETO) VALUES (@num,@fec,@cli,@bruto,@venta,@igv,@net);"; using (SqlConnection con = new SqlConnection(ConexionUtil.Cadena)) { con.Open(); using (SqlCommand com = new SqlCommand(sql, con)) { com.Parameters.Add(new SqlParameter("@num", facturaGuardar.Numero)); com.Parameters.Add(new SqlParameter("@fec", facturaGuardar.Fecha)); com.Parameters.Add(new SqlParameter("@cli", facturaGuardar.Cliente)); com.Parameters.Add(new SqlParameter("@bruto", facturaGuardar.ImporteBruto)); com.Parameters.Add(new SqlParameter("@venta", facturaGuardar.ImporteVenta)); com.Parameters.Add(new SqlParameter("@igv", facturaGuardar.ImporteIGV)); com.Parameters.Add(new SqlParameter("@net", facturaGuardar.ImporteTotalVenta)); com.ExecuteNonQuery(); } } facturaCreado = Obtener(facturaGuardar.Numero); EstadoPedido(facturaGuardar.Numero); return facturaCreado; }
public Factura ModificarFactura(Factura facturaAModificar) { throw new NotImplementedException(); }