コード例 #1
0
 public void registrar_reparacion_det(ReparacionDetEn det)
 {
     try
     {
         using (SqlConnection cn = new SqlConnection(objCn.conex("activos")))
         {
             cn.Open();
             SqlCommand cmd = new SqlCommand("usp_ReparacionDetalle_ins", cn);
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@idReparacion", det.idReparacion);
             cmd.Parameters.AddWithValue("@codigo", det.codigo);
             cmd.Parameters.AddWithValue("@nroFactura", det.nroFactura);
             cmd.Parameters.AddWithValue("@fecReparacion", det.fecReparacion);
             cmd.Parameters.AddWithValue("@tiempoGar", det.tiempoGar);
             cmd.Parameters.AddWithValue("@fecFinGar", det.fecFinGar);
             cmd.Parameters.AddWithValue("@costo", det.costo);
             cmd.Parameters.AddWithValue("@motivo", det.motivo);
             cmd.Parameters.AddWithValue("@trabRealizado", det.trabRealizado);
             cmd.Parameters.AddWithValue("@transportista", det.transportista);
             cmd.ExecuteNonQuery();
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
コード例 #2
0
        //protected void btnRuc_Click(object sender, ImageClickEventArgs e)
        //{
        //    FacturaN objFac = new FacturaN();

        //    try
        //    {
        //        btnRuc.Enabled = false;
        //        txtProveedor.Text = "";
        //        //txtDireccion.Text = "";
        //        txtProveedor.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)
        //        {
        //            txtProveedor.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);
        //                txtProveedor.Attributes.Remove("readonly");
        //                //txtDireccion.Attributes.Remove("readonly");
        //                throw new Exception(error);
        //            }

        //            if (emp.estado_contribuyente != "ACTIVO")
        //            {
        //                throw new Exception("El estado del contribuyente es inactivo ante la SUNAT");
        //            }

        //            txtProveedor.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 = false;
        //        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;
        //    }
        //}

        protected void BtnRegistrar_Click(object sender, EventArgs e)
        {
            try
            {
                validarFechas(txtFecReparacion);
                validar_campos();

                transacciones          objTrans = new transacciones();
                ReparacionEn           rep      = new ReparacionEn();
                List <ReparacionDetEn> detalle  = new List <ReparacionDetEn>();
                int    x     = 0;
                double total = 0.00;

                foreach (GridViewRow row in gvRepara.Rows)
                {
                    ReparacionDetEn det = new ReparacionDetEn();
                    TextBox         txtCosto, txtMotivo, txtTrabajo = new TextBox();
                    txtCosto   = (TextBox)gvRepara.Rows[x].FindControl("txtCosto");
                    txtMotivo  = (TextBox)gvRepara.Rows[x].FindControl("txtMotivo");
                    txtTrabajo = (TextBox)gvRepara.Rows[x].FindControl("txtTrabajo");

                    // validar
                    if (String.IsNullOrWhiteSpace(txtCosto.Text))
                    {
                        throw new Exception("Ingrese Costo");
                    }
                    if (String.IsNullOrWhiteSpace(txtMotivo.Text))
                    {
                        throw new Exception("Ingrese Motivo");
                    }
                    if (String.IsNullOrWhiteSpace(txtTrabajo.Text))
                    {
                        throw new Exception("Ingrese Trabajo Realizado");
                    }
                    // -----------------------------------------------------

                    det.codigo        = row.Cells[0].Text;
                    det.nroFactura    = txtNroFactura.Text;
                    det.fecReparacion = DateTime.Parse(txtFecReparacion.Text);
                    det.tiempoGar     = int.Parse(txtTiempo.Text);
                    det.fecFinGar     = DateTime.Parse(txtFechaFin.Text);
                    det.transportista = txtProveedor.Text;
                    det.costo         = double.Parse(txtCosto.Text);
                    det.motivo        = txtMotivo.Text;
                    det.trabRealizado = txtTrabajo.Text;

                    detalle.Add(det);
                    total += det.costo;
                    x++;
                }

                // cabecera
                txtTotal.Text = total.ToString();
                rep.idGuia    = xidGuia;
                rep.total     = total;
                rep.observ    = txtObservacion.Text.Trim();

                // datos guia
                GuiaCabeceraEn guia = new GuiaCabeceraEn();
                guia.IdGuia          = xidGuia;
                guia.IdLoginRecibido = int.Parse(Session["rpta"].ToString());
                guia.FechaRecepcion  = DateTime.Parse(txtFecha.Text);
                guia.ip = Request.UserHostAddress;

                if (objTrans.fun_registrar_reparacion(rep, detalle, guia))
                {
                    //Response.Write("listo");
                    this.Page.Response.Write("<script language ='JavaScript'>window.alert('Se registró la Recepción del Activo'); </script>");

                    BtnRegistrar.Enabled = false;
                    BtnImprimir.Enabled  = true;
                }
            }
            catch (Exception ex)
            {
                Response.Write("<script language ='JavaScript'>window.alert('" + ex.Message + "');</script>");
            }
        }