Showing the data in Gridview.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Services;
using System.ServiceModel.Description;
using System.Net;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using System.Data;
using System.Data.SqlClient;
using Microsoft.Xrm.Sdk.Query;
using System.Configuration;
using Sulekha.Order.CrmSdk;
using System.Linq.Expressions;
using Xrm;
using System.Collections.ObjectModel;
using System.Collections;
using System.Collections.Specialized;
namespace Sulekha.Order
{
public partial class Order_Details : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Order_Accepted();
}
protected void Order_Accepted()
{
ClientCredentials credentials = new ClientCredentials();
credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
Uri OrganizationUri = new Uri("http://smdev-crm/SulekhaCRM/XRMServices/2011/Organization.svc");
Uri HomeRealmUri = null;
using (OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(OrganizationUri, HomeRealmUri, credentials, null))
{
Microsoft.Xrm.Sdk.IOrganizationService service = (Microsoft.Xrm.Sdk.IOrganizationService)serviceProxy;
ConditionExpression condition = new ConditionExpression();
condition.AttributeName = "new_vendername";
condition.Operator = ConditionOperator.Equal;
condition.Values.Add("NXTEL");
FilterExpression filter1 = new FilterExpression();
filter1.Conditions.Add(condition);
QueryExpression query = new QueryExpression("salesorder");
query.ColumnSet.AddColumns("ordernumber", "customerid", "name","new_category","new_actualpurchaseprice","shipto_city","statuscode");
query.Criteria.AddFilter(filter1);
EntityCollection result1 = serviceProxy.RetrieveMultiple(query);
DataSet ds = new DataSet();
DataTable dt = new DataTable();
dt.Columns.Add("Order No");
dt.Columns.Add("Customer Name");
dt.Columns.Add("Product Name");
dt.Columns.Add("Product Category");
dt.Columns.Add("Product Price");
dt.Columns.Add("Order Status");
dt.Columns.Add("Shipped to City");
foreach (Entity entities in result1.Entities)
{
DataRow dr = dt.NewRow();
dr["Order No"] = entities.Attributes["ordernumber"].ToString(); //so.OrderNumber;
EntityReference var1 = (EntityReference)entities.Attributes["customerid"];
dr["Customer Name"] = var1.Name;
dr["Product Name"] = entities.Attributes["name"].ToString();
dr["Product Category"] = entities.Attributes["new_category"].ToString();
dr["Product Price"] = entities.Attributes["new_actualpurchaseprice"].ToString();
OptionSetValue osv = (OptionSetValue)entities.Attributes["statuscode"];
if (osv.Value == 1)
{
dr["Order Status"] = "New";
}
if (osv.Value == 2)
{
dr["Order Status"] = "Pending";
}
//dr["Order Status"] = osv.Value;
//dr["Order Status"] = entities.Attributes["statuscode"].ToString();
dr["Shipped to City"] = entities.Attributes["shipto_city"].ToString();
dt.Rows.Add(dr);
}
ds.Tables.Add(dt);
ordergrid.DataSource = ds;
ordergrid.DataBind();
}
}
}
}
using the session variables:
Session["accountname"]=var1.name; // in first asp.net
string vendor = Session["accountname"].ToString(); //in second asp.net.
Response.redirect("second.aspx");
No comments:
Post a Comment