Group: Forum Members
Posts: 533,
Visits: 2K
|
Hi, I try to sort my data in my BO using the code below. However, it doesn't work. Listview always show the records using PK order. I have listview.sorting = none as well. Any ideas? this.itemPricesBO.FillByParentPrimaryKey(this.itemsBO.ItemID); this.itemPricesBO.Sort = "FromDate ASC"; this.lvItemPrices.Requery();
|
Group: Forum Members
Posts: 533,
Visits: 2K
|
Hi, Yes, I have set lvPrices.PopulateDataSourceSettings to CopyDataFrom(BusinessLayerBase, BusinessCloneDataType) lvPrice.PopulateOnFormLoad = 'Manual' I also have these code private void ItemPriceMaintenance_Load(object sender, EventArgs e) { this.itemPricesBO.FillByParentPrimaryKey(this.itemsBO.ItemID); this.itemPricesBO.Sort = "fromdate"; this.lvItemPrices.Requery(); }
I also faced very strange things here. If I set something to sort property, my changes to one record would affect the next record also. private void tsbEdit_Click(object sender, EventArgs e) { bool llSuccess; this.itemPricesBO.NavigateToPrimaryKey(this.lvItemPrices.SelectedItems[0].Tag); this.itemPricesBO.Edit(); llSuccess = (this.ItemPricechildFormDialog.ShowDialog() == DialogResult.OK); if (!llSuccess) { this.itemPricesBO.Undo(MicroFour.StrataFrame.Business.BusinessUndoType.CurrentRowOnly); } else { _LastPrice = 0; this.lvItemPrices.Requery(); } Childform OK button private void cmdOK_Click(object sender, EventArgs e) { if (this.itemPricesBO.CheckRulesOnRow()) { DialogResult = DialogResult.OK; } } I try to set expression to currentview.sort directory and view the data, it doesnt sort also. this.itemPricesBO.CurrentView.Sort this.itemPricesBO.CurrentView.Table.Rows[0].ItemArray[2] Any ideas?
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 7K
|
Yes, you have to use the CopyDataFrom(DataTable,..) rather than the CopyDataFrom(BusinessLayerBase,...) because of how you are trying to do your sort. Then when you provide the first parameter in the ListPopulating event you will provide the CurrentView like this: e.Parameters(0).Value = MyBO.CurrentView.ToTable() This will populate using your sort.
|
Group: Forum Members
Posts: 533,
Visits: 2K
|
Hi, OK, the sorting works. Thank you. However, I hit the strange behavour. I have price list record as shown below. I select the highlighted record and call myBO.Edit(). 
If I make changes to "from date" that would cause sorting position changed, the next record "from date" value also would be changed 
//Code for screen above. using System; using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using JK.Inventory.BusinessObject.Product;namespace JK.Inventory.UI.Windows.Forms.Product{ public partial class ItemPriceMaintenance : MicroFour.StrataFrame.UI.Windows.Forms.StandardForm{ private decimal _LastPrice;public ItemPriceMaintenance(){ InitializeComponent(); } private void cmdOK_Click(object sender, EventArgs e){ if (this.itemPricesBO.Save() == MicroFour.StrataFrame.Data.SaveUndoResult.Success){ DialogResult = DialogResult.OK;} } private void cmdCancel_Click(object sender, EventArgs e){ this.itemPricesBO.Undo(MicroFour.StrataFrame.Business.BusinessUndoType.AllRows);DialogResult = DialogResult.Cancel;} private void tsbAdd_Click(object sender, EventArgs e){ bool llSuccess;this.itemPricesBO.Add();llSuccess = ( this.ItemPricechildFormDialog.ShowDialog() == DialogResult.OK);if (!llSuccess){ this.itemPricesBO.Undo(MicroFour.StrataFrame.Business.BusinessUndoType.CurrentRowOnly);} else{ this.lvItemPrices.Requery();} } private void tsbEdit_Click(object sender, EventArgs e){ bool llSuccess;this.itemPricesBO.NavigateToPrimaryKey(this.lvItemPrices.SelectedItems[0].Tag);this.itemPricesBO.Edit();llSuccess = ( this.ItemPricechildFormDialog.ShowDialog() == DialogResult.OK);if (!llSuccess){ this.itemPricesBO.Undo(MicroFour.StrataFrame.Business.BusinessUndoType.CurrentRowOnly);} else{ _LastPrice = 0; this.lvItemPrices.Requery();} } private void tsbRemove_Click(object sender, EventArgs e){ this.itemPricesBO.SeekToPrimaryKey(this.lvItemPrices.SelectedItems[0].Tag);this.itemPricesBO.DeleteCurrentRow(true);this.lvItemPrices.Requery();} private void ItemPriceMaintenance_Load(object sender, EventArgs e){ this.itemPricesBO.FillByParentPrimaryKey(this.itemsBO.ItemID);this.itemPricesBO.Sort = "FromDate";this.lvItemPrices.Requery();} private void lvItemPrices_ListPopulating(MicroFour.StrataFrame.UI.ListPopulatingEventArgs e){ e.Parameters[0].Value = this.itemPricesBO.CurrentView.ToTable(); //this.itemPricesBO;e.Parameters[1].Value = MicroFour.StrataFrame.Business. BusinessCloneDataType.ClearAndFillFromCompleteTable;} private void lvItemPrices_RowPopulating(MicroFour.StrataFrame.UI.Windows.Forms.RowPopulatingEventArgs e){ ItemPricesBO loItemPriceBO = ((ItemPricesBO)e.BusinessObject);if (loItemPriceBO.Price > _LastPrice){ e.ImageIndex = 0; } else if (loItemPriceBO.Price < _LastPrice){ e.ImageIndex = 1; } _LastPrice = loItemPriceBO.Price; e.Values[0].DisplayValue = loItemPriceBO.FromDate.ToShortDateString(); //e.Values[1].DisplayValue = loItemPriceBO.ToDate.ToShortDateString();e.Values[1].DisplayValue = loItemPriceBO.Price.ToString( "###,###,##0.00");e.Values[2].DisplayValue = loItemPriceBO.MinPrice.ToString( "###,###,##0.00");e.Values[3].DisplayValue = loItemPriceBO.MaxPrice.ToString( "###,###,##0.00");/*e.Values[0].DisplayValue = loItemPriceBO.FromDate.ToShortDateString();e.Values[1].DisplayValue = loItemPriceBO.Price.ToString("###,###,##0.00"); e.Values[2].DisplayValue = loItemPriceBO.MinPrice.ToString("###,###,##0.00"); e.Values[3].DisplayValue = loItemPriceBO.MaxPrice.ToString("###,###,##0.00"); */ } private void itemPricesBO_ParentFormLoading(){ } } } //Code in my editor form. using System; using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace JK.Inventory.UI.Windows.Forms.Product{ public partial class ItemPriceEditor : JK.Inventory.UI.Windows.Forms.Product.PriceEditorBase{ public ItemPriceEditor(){ InitializeComponent(); } private void cmdOK_Click(object sender, EventArgs e){ if (this.itemPricesBO.CheckRulesOnRow()){ DialogResult = DialogResult.OK;} } private void cmdCancel_Click(object sender, EventArgs e){ DialogResult = DialogResult.Cancel;} } } I did anything wrong? Sorry, I am new to .NET. Thank you
|