예제 #1
0
        protected void CmdAtender_Click(object sender, EventArgs e)
        {
            JavaScriptSerializer js = new JavaScriptSerializer();

            try
            {
                string sCodigoTicket = dvAtencionTickets.SelectedRow.Cells[1].Text;
                string sRespuesta    = this.txtRespuesta.Text;
                string sDniEmpleado  = this.ddlEmpleado.SelectedValue.ToString();

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost:36485/Tickets.svc/AtenderTicket/" + sCodigoTicket + "/" + sRespuesta + "/" + sDniEmpleado);
                request.Method        = "POST";
                request.ContentType   = "application/json";
                request.ContentLength = 0;

                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                StreamReader    reader   = new StreamReader(response.GetResponseStream());

                string tramaJson      = reader.ReadToEnd();
                Ticket oTicketMensaje = js.Deserialize <Ticket>(tramaJson);
                this.lblMensaje.Text   = "Se envió la respuesta correctamente.";
                this.txtRespuesta.Text = "";
            }
            catch (WebException ex)
            {
                HttpStatusCode    codigo    = ((HttpWebResponse)ex.Response).StatusCode;
                StreamReader      reader    = new StreamReader(ex.Response.GetResponseStream());
                string            tramaJson = reader.ReadToEnd();
                RepetidoException error     = js.Deserialize <RepetidoException>(tramaJson);
                this.lblMensaje.Text = error.Codigo + "  " + error.Descripcion;
                //    Assert.AreEqual(HttpStatusCode.Conflict, codigo);
                //    Assert.AreEqual("El Cliente ya existe", error.Descripcion);
            }
        }
예제 #2
0
        protected void cmdGrabar_Click(object sender, EventArgs e)
        {
            if (ValidarExistenciaCliente(this.txtRucCliente.Text) == false)
            {
                this.lblMensaje.Text = "No se grabaron los datos. No se encontro el Cliente";
                return;
            }

            JavaScriptSerializer js = new JavaScriptSerializer();

            Ticket oTicket = new Ticket();

            oTicket.RucCliente         = Convert.ToInt64(this.txtRucCliente.Text);
            oTicket.Descripcion        = this.txtDescripcion.Text;
            oTicket.CodigoEspecialidad = ddlEspecialidad.SelectedValue.ToString();
            oTicket.Estado             = "Generado";
            oTicket.Fecha        = DateTime.Now;
            oTicket.DniEmpleado  = 0;
            oTicket.CodigoTicket = 0;

            string postdata = js.Serialize(oTicket);

            byte[]         data    = Encoding.UTF8.GetBytes(postdata);
            HttpWebRequest request = (HttpWebRequest)WebRequest.
                                     Create("http://localhost:36485/Tickets.svc/RegistrarTickets");

            request.Method        = "POST";
            request.ContentLength = data.Length;
            request.ContentType   = "application/json";

            var requestStream = request.GetRequestStream();

            requestStream.Write(data, 0, data.Length);
            HttpWebResponse response = null;

            try
            {
                response = (HttpWebResponse)request.GetResponse();
                StreamReader reader    = new StreamReader(response.GetResponseStream());
                string       tramaJson = reader.ReadToEnd();

                Ticket TicketCreado = js.Deserialize <Ticket>(tramaJson);
                this.lblMensaje.Text = "Se grabo correctamente. Codigo Ticket : " + TicketCreado.CodigoTicket.ToString();
                Limpiar();
                Listar();
                this.txtRucCliente.Focus();
            }
            catch (WebException ex)
            {
                HttpStatusCode    codigo    = ((HttpWebResponse)ex.Response).StatusCode;
                StreamReader      reader    = new StreamReader(ex.Response.GetResponseStream());
                string            tramaJson = reader.ReadToEnd();
                RepetidoException error     = js.Deserialize <RepetidoException>(tramaJson);
                this.lblMensaje.Text = error.Codigo + "  " + error.Descripcion;
                //    Assert.AreEqual(HttpStatusCode.Conflict, codigo);
                //    Assert.AreEqual("El Ticket ya existe", error.Descripcion);
            }
        }
예제 #3
0
        protected void cmdGrabar_Click(object sender, EventArgs e)
        {
            JavaScriptSerializer js = new JavaScriptSerializer();

            Empleado oEmpleado = new Empleado();

            oEmpleado.dni                = int.Parse(this.txtDni.Text);
            oEmpleado.Nombre             = this.TxtNombre.Text;
            oEmpleado.Estado             = this.ddlEstado.Text;
            oEmpleado.Edad               = int.Parse(this.TxtEdad.Text);
            oEmpleado.CodigoEspecialidad = ddlEspecialidad.SelectedValue.ToString();
            oEmpleado.Certificado        = this.ChkCertificado.Checked;

            string postdata = js.Serialize(oEmpleado);

            byte[]         data    = Encoding.UTF8.GetBytes(postdata);
            HttpWebRequest request = (HttpWebRequest)WebRequest.
                                     Create("http://localhost:36485/Empleados.svc/Empleados");

            request.Method        = "POST";
            request.ContentLength = data.Length;
            request.ContentType   = "application/json";

            var requestStream = request.GetRequestStream();

            requestStream.Write(data, 0, data.Length);
            HttpWebResponse response = null;

            try
            {
                response = (HttpWebResponse)request.GetResponse();
                StreamReader reader    = new StreamReader(response.GetResponseStream());
                string       tramaJson = reader.ReadToEnd();

                Empleado EmpleadoCreado = js.Deserialize <Empleado>(tramaJson);
                this.lblMensaje.Text = "Se grabo correctamente. DNI : " + EmpleadoCreado.dni.ToString();
                Limpiar();
                this.txtDni.Focus();
            }
            catch (WebException ex)
            {
                HttpStatusCode    codigo    = ((HttpWebResponse)ex.Response).StatusCode;
                StreamReader      reader    = new StreamReader(ex.Response.GetResponseStream());
                string            tramaJson = reader.ReadToEnd();
                RepetidoException error     = js.Deserialize <RepetidoException>(tramaJson);
                this.lblMensaje.Text = error.Codigo + "  " + error.Descripcion;
                //    Assert.AreEqual(HttpStatusCode.Conflict, codigo);
                //    Assert.AreEqual("El empleado ya existe", error.Descripcion);
            }
        }
예제 #4
0
        protected void cmdGrabar_Click(object sender, EventArgs e)
        {
            JavaScriptSerializer js = new JavaScriptSerializer();

            Cliente oCliente = new Cliente();

            oCliente.Ruc         = Convert.ToInt64(this.txtRuc.Text);
            oCliente.Razonsocial = this.TxtNombre.Text;
            oCliente.Estado      = this.ddlEstado.Text;


            string postdata = js.Serialize(oCliente);

            byte[]         data    = Encoding.UTF8.GetBytes(postdata);
            HttpWebRequest request = (HttpWebRequest)WebRequest.
                                     Create("http://localhost:36485/Clientes.svc/Clientes");

            request.Method        = "POST";
            request.ContentLength = data.Length;
            request.ContentType   = "application/json";

            var requestStream = request.GetRequestStream();

            requestStream.Write(data, 0, data.Length);
            HttpWebResponse response = null;

            try
            {
                response = (HttpWebResponse)request.GetResponse();
                StreamReader reader    = new StreamReader(response.GetResponseStream());
                string       tramaJson = reader.ReadToEnd();

                Cliente ClienteCreado = js.Deserialize <Cliente>(tramaJson);
                this.lblMensaje.Text = "Se grabo correctamente. RUC : " + ClienteCreado.Ruc.ToString();
                Limpiar();
                this.txtRuc.Focus();
            }
            catch (WebException ex)
            {
                HttpStatusCode    codigo    = ((HttpWebResponse)ex.Response).StatusCode;
                StreamReader      reader    = new StreamReader(ex.Response.GetResponseStream());
                string            tramaJson = reader.ReadToEnd();
                RepetidoException error     = js.Deserialize <RepetidoException>(tramaJson);
                this.lblMensaje.Text = error.Codigo + "  " + error.Descripcion;
                //    Assert.AreEqual(HttpStatusCode.Conflict, codigo);
                //    Assert.AreEqual("El Cliente ya existe", error.Descripcion);
            }
        }