我无法将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;
}
DAC:
[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,帐户名称,付款方式,Cashaccount,货币ID
1,C001,客户名称1,EFT,8405,ZAR
2,C002,顾客2,EFT,8405,ZAR
3,C003,客户3,EFT,8405,ZAR
系统中存在所有客户,付款方式,cashaccounts,货币。
我有一张与MyDAC相同的表格。
PXCache entry = CustomersView.Cache;
和
foreach (MyDACitem in CustomersView.Cache.Inserted)
{
list.Add(item);
}
即使文件中有两行,也只显示插入的1行。它将这一行成功导入我的网格,但不导入其他行。
我错过了什么。
答案 0 :(得分:0)
你在DAC中错过了IsKey = true吗?