照着论坛的插件操作例子
public override void BeforeExecuteOperationTransaction(BeforeExecuteOperationTransaction e)
{
base.BeforeExecuteOperationTransaction(e);
foreach (ExtendedDataEntity extended in e.SelectedRows)
{
DynamicObject dy = extended.DataEntity;
DynamicObjectCollection docPriceEntity = dy["SAL_OUTSTOCKENTRY"] as DynamicObjectCollection;
DynamicObject doPriceEntityItem = null;
int iAllCount = 0;
iAllCount = docPriceEntity.Count;
for (int i = 0; i < iAllCount; i++)
{
doPriceEntityItem = docPriceEntity[i];
if (!File.Exists("D:\\K3文件\\test1.txt"))
{
FileStream fs1 = new FileStream("D:\\K3文件\\test1.txt", FileMode.Create, FileAccess.Write);//创建写入文件
StreamWriter sw = new StreamWriter(fs1);
sw.WriteLine(doPriceEntityItem.ToString());//开始写入值
sw.Close();
fs1.Close();
}
else
{
FileStream fs = new FileStream("D:\\K3文件\\test1.txt", FileMode.Open, FileAccess.Write);
StreamWriter sr = new StreamWriter(fs);
sr.WriteLine(doPriceEntityItem.ToString());//开始写入值
sr.Close();
fs.Close();
}
if (doPriceEntityItem["Lot_Text"] == null)//Lot_Text是批号标志
{
docPriceEntity.Remove(doPriceEntityItem);
}
}
}
}
因为我想看看备注没有填Remove一下,但是不知道备注的doPriceEntityItem[""]的名称,而其实批号的
都不是["Lot_Text"] ,于是我想打出来doPriceEntityItem["Lot_Text"] 的对象doPriceEntityItem来看看,写入TXT文本,
if (!File.Exists("D:\\K3文件\\test1.txt"))
{
FileStream fs1 = new FileStream("D:\\K3文件\\test1.txt", FileMode.Create, FileAccess.Write);//创建写入文件
StreamWriter sw = new StreamWriter(fs1);
sw.WriteLine(doPriceEntityItem.ToString());//开始写入值
sw.Close();
fs1.Close();
}
else
{
FileStream fs = new FileStream("D:\\K3文件\\test1.txt", FileMode.Open, FileAccess.Write);
StreamWriter sr = new StreamWriter(fs);
sr.WriteLine(doPriceEntityItem.ToString());//开始写入值
sr.Close();
fs.Close();
}
但是没有效果,不成功,这个方式不行么,还是我的写法有问题,另外批号的["Lot_Text"] ,这种,其他字段的如何获取,谢谢!
推荐阅读