Example #1
0
        public void impresioncomprobante(string tipocomprobante)
        {
            string msg = "ok";
            Negociocomprobantes objcomprobante = new Negociocomprobantes();
            char      estadofactura            = 'P';
            DataTable datacliente = new DataTable();

            datacliente = NegocioCliente.buscarCodigoCliente(idcliente);
            string    nrocomprobante = "0";
            DataRow   row            = datacliente.Rows[0];
            DataTable dt             = detalleventa(row["responsabilidadiva"].ToString());

            if (NegocioConfigEmpresa.confsistema("facturar").ToString() == "True" && txtTipoComprobante.Text == "NOTA DE VENTA")
            {
                //&& tipo_comprobante == "NOTA DE VENTA"
                msg = objcomprobante.factura(NegocioConfigEmpresa.marcafiscal, dt, Convert.ToDouble(txtTotal.Text), NegocioConfigEmpresa.modelofiscal, NegocioConfigEmpresa.puertofiscal,
                                             1, row["razon_social"].ToString(), row["razon_social"].ToString() == "CONSUMIDOR FINAL" ? "99999999999" : row["cuit"].ToString(), row["direccion"].ToString(), "B", row["responsabilidadiva"].ToString(), tipocomprobante);
                if (msg.Substring(0, 2) != "ok")
                {
                    UtilityFrm.mensajeError(msg);
                    UtilityFrm.mensajeConfirm("Se guardara la venta como pendiente de factura la puede encontrar en lista de ventas");
                    estadofactura = 'P';
                }
                else
                {
                    nrocomprobante = msg.Substring(2, 8);
                    if (tipocomprobante == "FACTURA")
                    {
                        estadofactura = 'F';
                    }
                    else
                    {
                        estadofactura = 'N';
                    }
                }
                this.Close();
            }
            else if (txtTipoComprobante.Text == "PRESUPUESTO")
            {
                estadofactura = 'P';
            }
            string mensaje = NegocioVenta.cambiarestadoventa(Convert.ToInt32(txtCodigo.Text), estadofactura, nrocomprobante);

            if (mensaje.Equals("ok"))
            {
                UtilityFrm.mensajeConfirm("La facturación se realizó Correctamente");
            }
            else
            {
                UtilityFrm.mensajeError(mensaje);
            }
        }
        private void menuconfventa_Click(object sender, EventArgs e)
        {
            string mensaje  = "";
            bool   constock = false;

            try
            {
                Negociocaja objcaja = new Negociocaja();

                DataGridViewRow row = dataLista.CurrentRow;
                if (Convert.ToBoolean(row.Cells["caja"].Value) == false)
                {
                    if (objcaja.chequeocaja(this.Name, ref mensaje) == true)
                    {
                        Negociocaja.insertarmovcaja(4110107, Convert.ToSingle(row.Cells["Total"].Value.ToString()), 0, Convert.ToString(DateTime.Now), NegocioConfigEmpresa.usuarioconectado, NegocioConfigEmpresa.idusuario, NegocioConfigEmpresa.turno, "Venta nro : " + row.Cells["codigo"].Value.ToString(), Convert.ToInt64(row.Cells["codigo"].Value.ToString()), true);


                        if (NegocioConfigEmpresa.confsistema("stock").ToString() == this.Name)
                        {
                            DataTable ventas = cargardetallestock(row.Cells["codigo"].Value.ToString());

                            mensaje = NegocioMovStock.insertar(0, DateTime.Today,
                                                               "", row.Cells["codigo"].Value.ToString(), "VENTA", 0, "EMITIDO", "EGRESO", ventas);
                            if (mensaje != "ok")
                            {
                                constock = false;
                                UtilityFrm.mensajeError(mensaje);
                            }
                            else
                            {
                                constock = true;
                            }
                        }
                        NegocioVenta.cambiarestadoventa(Convert.ToInt32(row.Cells["codigo"].Value.ToString()), true, constock);
                    }
                    else
                    {
                        UtilityFrm.mensajeError(mensaje);
                    }
                }
            }
            catch (Exception i)
            {
                UtilityFrm.mensajeError(i.Message);
            }
            buscarPorFecha();
            actualizarTotal();
        }