我在将CSV导入到包含自定义DAC的自定义网格时遇到了问题。
我已经成功地获得了导入功能,并使进程只导入文件中的第一行。我不明白为什么缓存只包含文件中的一个条目。
我的代码:
图表:
public class MyClassProcess : PXGraph<MyClassProcess>, PXImportAttribute.IPXPrepareItems
{
[PXImport(typeof(MyDAC))]
public PXSelect<MyDAC> CustomersView;
public MyClassProcess()
{
PXCache entry = CustomersView.Cache;
PXUIFieldAttribute.SetVisible<MyDAC.id>(entry, null, false);
entry.AllowInsert = true;
entry.AllowUpdate = true;
entry.AllowDelete = true;
}
protected virtual IEnumerable customersView()
{
List<MyDAC> list = new List<MyDAC>();
foreach (MyDACitem in CustomersView.Cache.Inserted)
{
list.Add(item);
}
return list;
}发援会:
[Serializable]
public class MyDAC: IBqlTable
{
#region Id
public abstract class id : IBqlField { }
protected int? _ID;
[PXDBInt(IsKey = true)]
[PXUIField(DisplayName = "ID")]
public virtual int? ID { get; set; }
#endregion
#region Selected
public abstract class selected : IBqlField
{
}
protected bool? _Selected = false;
[PXDBBool()]
[PXDefault(false, PersistingCheck = PXPersistingCheck.Nothing)]
[PXUIField(DisplayName = "Selected")]
public virtual bool? Selected
{
get
{
return _Selected;
}
set
{
_Selected = value;
}
}
#endregion
#region CustomerID
public abstract class customerID : IBqlField { }
protected string _CustomerID;
[PXDBString(20, IsFixed = true, IsUnicode = true, InputMask = "")]
[PXUIField(DisplayName = "Account ID")]
public virtual String CustomerID { get; set; }
#endregion
#region CustomerCD
public abstract class customerCD : IBqlField { }
protected string _CustomerCD;
[PXDBString(50, IsFixed = true, IsUnicode = true, InputMask = "")]
[PXUIField(DisplayName = "Account Name")]
public virtual String CustomerCD { get; set; }
#endregion
#region PaymentMethodID
public abstract class paymentMethodID : IBqlField { }
protected string _PaymentMethodID;
[PXDBString(10, IsFixed = true, IsUnicode = true, InputMask = "")]
[PXUIField(DisplayName = "Payment method")]
public virtual String PaymentMethodID { get; set; }
#endregion
#region Cashaccount
public abstract class cashaccount : IBqlField { }
protected int? _CashAccount;
[PXDBInt()]
[PXUIField(DisplayName = "Cashaccount")]
public virtual int? Cashaccount { get; set; }
#endregion
#region Currency
public abstract class currency : IBqlField { }
protected string _Currency;
[PXDBString(10, IsFixed = true, IsUnicode = true, InputMask = "")]
[PXUIField(DisplayName = "Currency")]
public virtual String Currency { get; set; }
#endregion
}Aspx:
<asp:Content ID="cont1" ContentPlaceHolderID="phDS" Runat="Server">
<px:PXDataSource ID="ds" runat="server" Visible="True" Width="100%"
TypeName="MyNamespace.MyClassProcess"
PrimaryView="CustomersView"
>
<CallbackCommands>
</CallbackCommands>
</px:PXDataSource>
</asp:Content>
<asp:Content ID="cont2" ContentPlaceHolderID="phL" runat="Server">
<px:PXGrid ID="grid" runat="server" DataSourceID="ds" Width="100%" Height="150px" SkinID="Primary" AllowAutoHide="false">
<Levels>
<px:PXGridLevel DataMember="CustomersView">
<Columns>
<px:PXGridColumn Type="CheckBox" TextAlign="Center" DataField="Selected" Width="60" ></px:PXGridColumn>
<px:PXGridColumn DataField="ID" Width="90" ></px:PXGridColumn>
<px:PXGridColumn DataField="CustomerID" Width="90" ></px:PXGridColumn>
<px:PXGridColumn DataField="CustomerCD" Width="150" ></px:PXGridColumn>
<px:PXGridColumn DataField="PaymentMethodID" Width="90" ></px:PXGridColumn>
<px:PXGridColumn DataField="Cashaccount" Width="90" ></px:PXGridColumn>
<px:PXGridColumn DataField="Currency" Width="70" ></px:PXGridColumn>
<%--<px:PXGridColumn DataField="CurrentBal" Width="70" ></px:PXGridColumn>--%>
</Columns>
</px:PXGridLevel>
</Levels>
<AutoSize Container="Window" Enabled="True" MinHeight="150" />
<ActionBar >
</ActionBar>
<Mode AllowUpload="True" /></px:PXGrid>
数据:
ID,帐户ID,帐户名称,支付方法,现金帐户,货币ID
1,C001,客户名称1,EFT,8405,ZAR
2,C002,Customer2,EFT,8405,ZAR
3,C003,Customer 3,EFT,8405,ZAR
所有客户、支付方式、现金账户、货币都存在于系统中。
我有一张名叫MyDAC的桌子。
PXCache entry = CustomersView.Cache;和
foreach (MyDACitem in CustomersView.Cache.Inserted)
{
list.Add(item);
}即使文件中有两行,也只显示1行插入。它成功地将这一行导入到我的网格中,但不能导入其他行。
我错过了什么。
发布于 2018-01-30 12:38:19
你在发援会上漏掉了一个IsKey=true吗?
https://stackoverflow.com/questions/48520792
复制相似问题