BO.Sort for date


Author
Message
Chan
Chan
Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)
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();


Reply
Chan
Chan
Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)
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

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Chan - 18 Years Ago
Chan - 18 Years Ago
Trent L. Taylor - 18 Years Ago
                 Hi,
Thank you for reply.
I have tried myBO.Sort =...
Chan - 18 Years Ago
Trent L. Taylor - 18 Years Ago
                         Hi, Yes, I have set lvPrices.PopulateDataSourceSettings to...
Chan - 18 Years Ago
                             Yes,you have to use the CopyDataFrom(DataTable,..) rather than the...
Trent L. Taylor - 18 Years Ago
                                 Hi, OK, the sorting works. Thank you. However, I hit the strange...
Chan - 18 Years Ago
StrataFrame Team - 18 Years Ago
             You saved my life!!!! Thank you
Chan - 18 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search