bhavanisankarnimmala

export RPT Which related ESRI Data - export

Blog Post created by bhavanisankarnimmala on May 14, 2018

instance emcpDS = new instance();

DataTable dt = emcpDS.Tables["Cable"];

IObject feat = null;

while ((feat = fcur.NextFeature()) != null)

{

int refID_index = feat.Fields.FindField("Ref_Id");

string GemsRefID = feat.get_Value(refID_index).ToString();

ArcMap.Application.StatusBar.set_Message(0, "Processing for facility Electricity, GEMS Ref: " + GemsRefID + "Please wait....");

IRelationshipClass relationshipClass = GetRelationshipClass(nameofRel_Cable, fclass);

ISet pSet = relationshipClass.GetObjectsRelatedToObject(feat as IObject);

pSet.Reset();

object pFeature = pSet.Next();

if (pFeature != null)

{

DataRow datarow = dt.NewRow();

string valueClientRefId = feat.get_Value(feat.Fields.FindField("Client_Ref_Id")).ToString();

string valueRefId = feat.get_Value(feat.Fields.FindField("Ref_Id")).ToString();

string valueDateReceived = feat.get_Value(feat.Fields.FindField("Date_Received")).ToString();

string valueTitle = feat.get_Value(feat.Fields.FindField("Title")).ToString();

IRow pRow = pFeature as IRow;

string valueAttn = pRow.get_Value(pRow.Fields.FindField("Attn")).ToString();

string valuePostalCode = pRow.get_Value(pRow.Fields.FindField("Postal_Code")).ToString();

string valueName = pRow.get_Value(pRow.Fields.FindField("Name")).ToString();

string valueAddress1 = pRow.get_Value(pRow.Fields.FindField("Address1")).ToString();

string valueAddress2 = pRow.get_Value(pRow.Fields.FindField("Address2")).ToString();

string valueAddress3 = pRow.get_Value(pRow.Fields.FindField("Address3")).ToString();

datarow["Client_Ref_Id"] = valueClientRefId;

datarow["Ref_Id"] = valueRefId;

datarow["Date_Received"] = valueDateReceived;

datarow["Title"] = valueTitle;

datarow["Attn"] = valueAttn;

datarow["Postal_Code"] = valuePostalCode;

datarow["Name"] = valueName;

datarow["Address1"] = valueAddress1;

datarow["Address2"] = valueAddress2;

datarow["Address3"] = valueAddress3;

dt.Rows.Add(datarow);

}

}

 

#region Export RPT from ReportViewer sample

CMRdraft cablerpt = new CMRdraft();

cablerpt.Database.Tables["Cable"].SetDataSource(emcpDS.Tables["Cable"]);

Globals.cablerpt = cablerpt;

Globals.facility = "Cable";

RPT_ReportViewer RPTViewer = new RPT_ReportViewer();

RPTViewer.ShowDialog();

dt.Dispose();

emcpDS.Dispose();

cablerpt.Dispose();

#endregion

 

 

//RPT_ReportViewer form Code

private void RPT_ReportViewer_Load(object sender, EventArgs e)

{

if (Globals.facility == "Cable")

{

crystalReportViewer1.ReportSource = Globals.cablerpt;

crystalReportViewer1.Refresh();

}

}

Outcomes