Exemplo n.º 1
0
        public FacturaE CrearFactura([FromBody] FacturaE value)
        {
            result = FacturaN.SetFactura(new Object[] {
                new SqlParameter("@Accion", "INSERT"),
                new SqlParameter("@NUME_DOC", value.NUME_DOC),
                new SqlParameter("@CODI_ESTADO", value.CODI_ESTADO),
                new SqlParameter("@VALOR_FAC", value.VALOR_FAC),
                new SqlParameter("@FECHA_FAC", value.FECHA_FAC)
            });


            return(result);
        }
Exemplo n.º 2
0
        protected void btnRuc_Click(object sender, ImageClickEventArgs e)
        {
            FacturaN objFac = new FacturaN();

            try
            {
                btnRuc.Enabled     = false;
                Transportista.Text = "";
                txtllegada.Text    = "";
                txtDireccion.Text  = "";
                Transportista.Attributes.Add("readonly", "true");
                txtllegada.Attributes.Add("readonly", "true");
                txtDireccion.Attributes.Add("readonly", "true");

                string ruc = txtRuc.Text.Trim();

                if (ruc == "")
                {
                    throw new Exception("Por favor ingrese el RUC a consultar");
                }
                else
                {
                    if (ruc.Length != 11)
                    {
                        throw new Exception("El RUC ingresado no es válido. Debe ser de 11 dígitos");
                    }
                }

                // verificar si existe en la tabla tbSunat
                FacturaEn empresa = new FacturaEn();
                empresa = objFac.fun_buscar_proveedor_xRuc(ruc);

                if (empresa.razonSocial != null)
                {
                    Transportista.Text = empresa.razonSocial;
                    txtllegada.Text    = empresa.razonSocial;
                    txtDireccion.Text  = empresa.direccion;
                    if (empresa.direccion == "" || empresa.direccion == "-")
                    {
                        txtDireccion.Attributes.Remove("readonly");
                    }
                }
                else
                {
                    //Mi api token personal sunat Jholy
                    string token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjRhMjc5YzM1YWIzN2FiYjUyYjVkZWIyYTcwYmY3ZjAyODZkMTRiYzVhZjNjNWI2Mzk2YmFlN2Y5NWQ4ZGE5ODBjN2Q1NzYzNzAxMDliN2ZlIn0.eyJhdWQiOiIxIiwianRpIjoiNGEyNzljMzVhYjM3YWJiNTJiNWRlYjJhNzBiZjdmMDI4NmQxNGJjNWFmM2M1YjYzOTZiYWU3Zjk1ZDhkYTk4MGM3ZDU3NjM3MDEwOWI3ZmUiLCJpYXQiOjE1NTM1MzE5ODQsIm5iZiI6MTU1MzUzMTk4NCwiZXhwIjoxNTg1MTU0Mzg0LCJzdWIiOiIyNzA1Iiwic2NvcGVzIjpbInVzZS1zdW5hdCJdfQ.dfvZ-onl8Hn6m-LjnQ8qVwFBe0Ii8k1w8qdKgq7vbL4UdGyziMyL5bWVgZ7anXEeyxlJEV1-Q6m_kRA7SJSD2S0j2VBtTyyAdSDuNefEi-CnS-b5aqbmRDp1bBBlsfQdav5EZyHDUkP1xVgeX_0bjgQhCWB72nOmqG7FUZqGJWvpPE1E2g8rY4leLcZeQC4ULsKNVZUuOTIq_wvJUOHu9FxHEM5p2R3dXWTOHDJCV4GRCFhyMrenA7SV40BcfmZiT_3hAf4FEKf8M-FXWxWa-p4Ry5BBYCBuoy4VdO7ADpoTvV-_TEdgV4giREjuTzDBvx6mANy2Rc-MHfElrr4ApgvdeYTgK2dUOSr1hmQ5O1MMgCVHla8QhV2LDwwE9zML-KVXHUkSmmCzKMC8dBXex271nhLrN9cZ55Kf8OZ3p78iwpsiLt-B-a8IWszOyIbi27TkbUCPDL8OygAo3rsS-ST2Os8bsmcPxBQDEuzXMs0myTEKAkO-LFP40V1JK-CRp-6d5AoCgbWj1aSOiBx6ECKrd4T0TeTBdrFRQnL37DZNgcm6puMb5l2YVyKoRYEYJL3c8U8HAMU99XYitKQEQHaQ03bPMbrhwmnFLWuWGpZN9ujm3EDmJjrlEZHBHg5NoX8-dMhYxlqgAUTEbq_EkJ29ZPnR9Tx5Gh-vfhar4Xk";

                    System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                    var client = new RestClient("https://consulta.pe/");

                    var request = new RestRequest("api/sunat/query/ruc ", Method.POST);
                    request.AddParameter("ruc", ruc);

                    // agregando Headers
                    request.AddHeader("Accept", "application/json");
                    request.AddHeader("Authorization", "Bearer " + token);

                    // ejecutando el request
                    IRestResponse response         = client.Execute(request);
                    var           content          = response.Content; // raw content as string
                    Tecactus.Api.Sunat.Company emp = new Tecactus.Api.Sunat.Company();

                    try
                    {
                        emp = JsonConvert.DeserializeObject <Tecactus.Api.Sunat.Company>(content);
                    }
                    catch (Exception)
                    {
                        string error = JsonConvert.DeserializeObject <string>(content);
                        Transportista.Attributes.Remove("readonly");
                        txtDireccion.Attributes.Remove("readonly");
                        throw new Exception(error);
                    }

                    if (emp.estado_contribuyente != "ACTIVO")
                    {
                        txtRuc.Focus();
                        txtRuc.BackColor = System.Drawing.Color.Yellow;
                        throw new Exception("Por favor, ingrese número de RUC válido");
                    }

                    Transportista.Text = emp.razon_social;

                    if (emp.direccion == "" || emp.direccion == "-")
                    {
                        txtDireccion.Attributes.Remove("readonly");
                    }
                    else
                    {
                        txtDireccion.Text = emp.direccion;
                    }

                    // registrar empresa en la tabla tbSunat y la consulta en la tabla auditoria
                    empresa.ruc         = ruc;
                    empresa.razonSocial = emp.razon_social;
                    empresa.direccion   = txtDireccion.Text.Trim();
                    empresa.usuReg      = Session["usuario"].ToString();
                    empresa.pc          = Request.UserHostAddress;

                    objFac.pr_registrar_empresa_api(empresa);
                    //objFac.pr_registrar_consulta_api(sede, Session["usuario"].ToString(), "ListarLogistica.aspx", ruc, Session["ip"].ToString());
                }
                txtRuc.Enabled   = true;
                txtRuc.BackColor = System.Drawing.Color.White;
                btnRuc.Enabled   = true;
                btnRuc.Enabled   = true;
                dvError.Visible  = false;
            }
            catch (Exception ex)
            {
                btnRuc.Enabled = true;
                //objFac.pr_registrar_consulta_api(sede, Session["usuario"].ToString(), "ListarLogistica.aspx", txtRuc.Text, Session["ip"].ToString());
                mostrarError(ex);

                dvError.InnerHtml = ex.Message;
                dvError.Visible   = true;
            }
        }
Exemplo n.º 3
0
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            if (gvDetalle.Rows.Count == 0)
            {
                this.Page.Response.Write("<script language ='JavaScript'>window.alert('No existen activos agregados en la lista de la guía. Verifique por favor.');</script>");
                return;
            }


            if (String.IsNullOrEmpty(Transportista.Text))
            {
                this.Page.Response.Write("<script language ='JavaScript'>window.alert('Ingrese Transportista.');</script>");
                Transportista.Focus();

                return;
            }
            if (ddlMotivoTrasldo.SelectedIndex == 0)
            {
                this.Page.Response.Write("<script language ='JavaScript'>window.alert('Seleccione Motivo de Traslado.');</script>");
                ddlMotivoTrasldo.Focus();
                return;
            }

            if (ddlPuntoPartida.SelectedIndex == 0)
            {
                this.Page.Response.Write("<script language ='JavaScript'>window.alert('Seleccione Punto de Partida.');</script>");
                ddlPuntoPartida.Focus();
                return;
            }
            if (ddlPuntoLlegada.SelectedIndex == 0)
            {
                this.Page.Response.Write("<script language ='JavaScript'>window.alert('Seleccione Punto de Llegada.');</script>");
                ddlPuntoLlegada.Focus();
                return;
            }

            if (ddlPuntoLlegada.SelectedItem.ToString() == "Otros")
            {
                if (txtllegada.Text == "")
                {
                    this.Page.Response.Write("<script language ='JavaScript'>window.alert('Especifique Punto de Llegada.');</script>");
                    txtllegada.Focus();
                    return;
                }
            }

            GuiaCabeceraEn       ObjInsertGuia = new GuiaCabeceraEn();
            GuiaDetalleActivosEn ObjInsertDet  = new GuiaDetalleActivosEn();

            ObjInsertGuia.IdLogin = int.Parse(Session["rpta"].ToString().ToUpper());

            ObjInsertGuia.SedePartida          = ddlPuntoPartida.SelectedValue;
            ObjInsertGuia.SedeLlegada          = ddlPuntoLlegada.SelectedValue;
            ObjInsertGuia.OrigenDestinoExterno = txtllegada.Text;

            ObjInsertGuia.Fecha            = DateTime.Now; //DateTime.Parse(TxtFecha.Text);
            ObjInsertGuia.Transportista    = Transportista.Text;
            ObjInsertGuia.IdMotivoTraslado = int.Parse(ddlMotivoTrasldo.SelectedValue);
            ObjInsertGuia.Activos          = 1;
            ObjInsertGuia.IdEstado         = int.Parse(txtEstado.Text);
            ObjInsertGuia.observ           = txtObserv.Text.Trim();
            ObjInsertGuia.ip = Request.UserHostAddress;
            GuiaCabeceraN objGC = new GuiaCabeceraN();


            string rpta = "";

            rpta            = objGC.InsertarGuiaCabecera(ObjInsertGuia);
            hdnIdGuia.Value = rpta;

            //Session["rpta"]=rpta;
            GuiaDetalleActivoN objDetalle       = new GuiaDetalleActivoN();
            FacturaEn          ObjInsertFactura = new FacturaEn();//**//
            FacturaN           ObjFacGuia       = new FacturaN();

            //adicionar temporal  activos
            ObjInsertDet.IdGuia = int.Parse(rpta);
            //                ObjInsertDet.IdUnidadMedida = int.Parse(ddlUnidadMedida.SelectedValue);
            int cant = 0;

            cant = gvDetalle.Rows.Count;
            for (int i = 0; i < cant; i += 1)
            {
                ObjInsertFactura.IdLogistica = int.Parse(gvDetalle.Rows[i].Cells[0].Text);//**//
                ObjInsertFactura.Ruc         = txtRuc.Text.Trim();
                ObjInsertFactura.Proveedor   = Transportista.Text.Trim();
                ObjInsertFactura.Direccion   = txtDireccion.Text.Trim();
                ObjFacGuia.pr_registrar_factura_guia(ObjInsertFactura);//**//

                ObjInsertDet.IdLogistica = int.Parse(gvDetalle.Rows[i].Cells[0].Text);
                //gvEmpleados.DataKeys[e.NewSelectedIndex].Values
                //    int id = Convertir .ToInt32 (GridView1.DataKeys [e.Row.RowIndex] .values [0]);
                //   int id = Convert.ToInt32(gvDetalle.DataKeys[i].Values[0]);
                ObjInsertDet.IdUnidadMedida = Convert.ToInt32(gvDetalle.DataKeys[i].Values[0]);
                objDetalle.InsertarGuiaDetalleActivos(ObjInsertDet);
            }
            ObjInsertGuia.IdGuia = int.Parse(rpta);
            objGC.pr_registrar_auditoria_guia(ObjInsertGuia);

            this.Page.Response.Write("<script language ='JavaScript'>window.alert('Guia registrada correctamente.');</script>");
            //vaciar tabla temporal
            //     GuiaTemporalN guia = new GuiaTemporalN();
            //     gvDetalle.DataSource = guia.EliminarGuiaTemporal();
            //     limpiar();
            //rpta captura el id de la guia
            //prueba de consulta
            hdIdGuia.Value        = rpta;
            gvconsulta.DataSource = objDetalle.BuscarGuiaActivos(rpta);
            //string login = gvconsulta.Rows[0].Cells[2].Text;
            hdusuario.Value = Session["Usuario"].ToString().ToUpper();
            gvconsulta.DataBind();
            btnNuevo.Enabled    = true;
            btnGuardar.Enabled  = false;
            btnImprimir.Enabled = true;
            Bloquear();
        }
Exemplo n.º 4
0
 public List <ConsultaFacturaE> GetFacturas()
 {
     return(FacturaN.GetConsultaFactura(new Object[] {
         new SqlParameter("@Accion", "CONSULTA")
     }));
 }