You are on page 1of 4

Namespaces

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web.Script.Serialization;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;
using GyCSmart.Datos.Entidades;
using GyCSmart.Datos.Entidades.Ics;
using GyCSmart.Negocio.Logica;







function clic_menu2(fila, dato) {
//Crear negociacion
window.dParametrosJsonWebMethod = { };
EstablecerWebMethod_A_Ejecutar(40,
"frmClientesObligacion.aspx/ValidarSiTienePermisoParaConsultar",
dParametrosJsonWebMethod);
}


[WebMethod]
public static string ConsultaObligacionesNegociar()
{
var list = new List<Dictionary<string, object>>();

foreach (DataRow row in _localDataTable.Rows)
{
var dict = new Dictionary<string, object>();

if (row["CPAGOTO"].ToString() != "0.00")
{
foreach (DataColumn col in _localDataTable.Columns)
{
dict[col.ColumnName] = row[col];
}
list.Add(dict);

}
}
var serializer = new JavaScriptSerializer();

return serializer.Serialize(list);

//return _localDataTable;
}




function EstablecerWebMethod_A_Ejecutar(opcion, urlMethod, parametrosJson) {
_type = "POST";
Url = urlMethod;
Data = JSON.stringify(parametrosJson);
ContentType = "application/json; charset=utf-8";
DataType = "json";
ProcessData = false;
callService(opcion);
}


function callService(opcion) {
$.ajax({
type: _type, //GET or POST or PUT or DELETE verb
url: Url, // Location of the service
data: Data, //Data sent to server
async: false,
contentType: ContentType, // content type sent to server
dataType: DataType, //Expected data format from server
processdata: ProcessData, //True or False
success: function (resul) { //On Successfull service call
ProcesaRespuestaWebService(resul,opcion);
},
error: function (xhr) {
serviceFailed(xhr, opcion);
} // When Service call fails
});
}










Ejemplo
HTML
dParametrosJsonWebMethod = { "customerId": _customerSeleccionado,"responseId":
efectoSeleccionado };

EstablecerWebMethod_A_Ejecutar(14,
"frmClientesObligacion.aspx/TraeContacto", dParametrosJsonWebMethod);

WebMethod
[WebMethod]
public static List<CONTACT> TraeContacto(string customerId, string
responseId)
{
var logicaIcs = new LogicaNegociacionesIcs(InfoSesion.ObtenerLogin());
return logicaIcs.TraerListaContacto(customerId, responseId);
}

Negocio

public List<CONTACT> TraerListaContacto(string customerId, string
responseId)
{
var repositorio = new NegociacionesIcsRepositorio(ContextoIcs);
var resultado = repositorio.ObtenerListaContacto(customerId,
responseId);
return resultado;
}


Datos

public List<CONTACT> ObtenerListaContacto(string customerId, string responseId)
{
/* TRAE EL CONTACTO SEGUN EL EFECTO SELECCIONADO */
var contacto = (from c in Contexto.CONTACT
join rc in Contexto.RESPONSE_CONTACT on c.CONTACT_ID equals
rc.CONTACT_ID
where c.LANGUAGE_ID == "ESPANOL"
&& c.CUSTOMER_ID == customerId
&& rc.RESPONSE_ID == responseId
&& rc.CUSTOMER_ID == customerId
orderby c.DESCRIPTION
select c).ToList();
return contacto;
}

WebMethod2

[WebMethod]
public static string ObtenerProgresoWorkflowStep(int workflowId, int
negociacionId)
{
var logicaDwh = new LogicaNegociacionesDwh(InfoSesion.ObtenerLogin());
var stepsWorkflow = logicaDwh.ObtenerProgresoWorkflowStep(workflowId,
negociacionId);

var list = new List<Dictionary<string, object>>();

foreach (DataRow row in stepsWorkflow.Rows)
{
var dict = new Dictionary<string, object>();

foreach (DataColumn col in stepsWorkflow.Columns)
{
if (col.ColumnName == "FECHA_INICIO" || col.ColumnName ==
"FECHA_FINALIZADO")
{
if (row[col].ToString() != string.Empty)
{
dict[col.ColumnName] = row[col].ToString().Substring(0,
10);
}
}
else
{
dict[col.ColumnName] = row[col];
}
}
list.Add(dict);
}
var serializer = new JavaScriptSerializer();
return serializer.Serialize(list);
}

You might also like