Kamis, 21 Februari 2008

Adding validation and business rule on DataTable

Open Dataset Designer , right click on the DataTable you wanted.
it will create partial class YourDataTableName.
and then on the
Create your Validation Sub
For instance
void CheckWorkTypeID(DirectCostRow directcostrow)
{
if (directcostrow.WorkTypeID == 0 || directcostrow.WorkTypeID == DBNull.Value)
{
directcostrow.SetColumnError("WorkTypeID", "Please Input A WorkTypeID");
}
}

Rabu, 20 Februari 2008

Why My table doesn't appear on Local Data Chace Designer

1.Are not in the user’s default schema.

Note:
To determine which schema is being displayed, inspect the text above the list of tables. The text appears in the following format: Tables on 'DatabaseName.SchemaName'. The SchemaName listed is the current default schema. For information about default schemas, see User-Schema Separation in SQL Server 2005 Books Online.


2.Table Doensn't have a primary key defined.

3.Have names longer than 118 characters.

4.Contain columns with data types that are not supported by SQL Server Compact 3.5.

Handle Data Conflicts and Errors ADO.NET Synchronization

partial class LocalDataCache1ServerSyncProvider
{
protected override void OnChangesSelected(ChangesSelectedEventArgs value)
{
base.OnChangesSelected(value);


}
public override SyncContext GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession)
{
return base.GetChanges(groupMetadata, syncSession);
MessageBox.Show(groupMetadata.BatchCount + " Change");
}
protected override void OnSelectingChanges(SelectingChangesEventArgs value)
{
base.OnSelectingChanges(value);

}
protected override void OnApplyChangeFailed(Microsoft.Synchronization.Data.ApplyChangeFailedEventArgs value)
{
DataTable clientchanges = value.Conflict.ClientChange;
DataTable serverchanges = value.Conflict.ServerChange;
if(value.Conflict.ConflictType==ConflictType.ClientUpdateServerDelete)
{


value.Action = ApplyAction.RetryWithForceWrite;


}
if (value.Conflict.ConflictType == ConflictType.ClientInsertServerInsert)
{
value.Action = ApplyAction.RetryWithForceWrite;
}

if (value.Conflict.ConflictType == ConflictType.ClientUpdateServerUpdate)
{
//Logic goes here.
Form1 a = new Form1();
a.ultraGrid1.DataSource = serverchanges;
a.ultraGrid2.DataSource = clientchanges;
a.ultraStatusBar1.Text = "Data has been changed by other user since your last synchronization";
a.ShowDialog();
value.Action = a.action;
}

if (value.Conflict.ConflictType == ConflictType.ErrorsOccurred)
{
//Logic goes here.
MessageBox.Show(value.Conflict.ErrorMessage, "UnKnown Error Happened:Continuing");

}

}
protected override void OnApplyingChanges(ApplyingChangesEventArgs value)
{
DataSet clientchanges = value.Changes;
}
}

Ado.net Synchronize

Hmmm...
i've try the sync one.
you just add new item localchace and
set where the Server reside.
and it will generate you everything including the client sql server compact.
you just say NameofYourChaceSyncAgent.Synchronize

and add this extracode for your localcache

partial class NameofYourChaceServerSyncProvider
{
protected override void OnApplyChangeFailed(Microsoft.Synchronization.Data.ApplyChangeFailedEventArgs value)
{
DataTable clientchanges = value.Conflict.ClientChange;
DataTable serverchanges = value.Conflict.ServerChange;
value.Action = ApplyAction.RetryWithForceWrite;
}
protected override void OnApplyingChanges(ApplyingChangesEventArgs value)
{
DataSet clientchanges = value.Changes;
}
}

Selasa, 19 Februari 2008

Datarow state

Sync FrameWork

After seeing the video ,
I wish that i can use this kind of products in project

on the video seems to good to be true.

Serialize Dataset Using Binary Formatter and XML

How to Serialize to XMl
MyDataSet.writexml(path,xmlwritemode.ignoreschema)
If you want to keep the original datarow object information for later syncrhonized with database
MyDataSet.writexml(path,xmlwritemode.Diffgram)
DiffGram contains all of the DataRowVersion information as shown in the following XML

How to DeSerialize from XMl
MyDataSet.Readxml(path,xmlreadmode.Ignoreschema);
MyDataSet.Readxml(path,xmlreadmode.Diffgram);

How to Serialize to Binary
FileStream fs=new FileStream(
@"c:\MyDataset.bin",FileMode.Create);
BinaryFormatter fmt= newBinaryFormatter();
fmt.Serialize(fs, MyDataset);
fs.Close();

How to Deserialize from Binary
DataSetvendorData;
FileStream fs=new FileStream(
@"c:\MyDataset.bin", FileMode.Open);
BinaryFormatter fmt= newBinaryFormatter();
MyDataset=(DataSet)fmt.Deserialize(fs);
fs.Close();

Senin, 18 Februari 2008

Binding to Listobject display no data

hmmm. i've encountered this problema .
what ever you bind whether ICOLLECTION, or DATATABLE.
Please do not fill it first then bind.
You bind it first then you fill/add the item
Whoallah it appears
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=137631&SiteID=1

Hey i found another solution
it is because you dont' set the propety
AutoSetDataBoundColumnHeader to TRUE

Ribbon and Custom Task Panes

to add custom task pane. on ThisWorkBook.cs
private void ThisWorkbook_Startup(object sender, System.EventArgs e)
{
this.ActionsPane.Controls.Add(new ActionsPaneControl1());
}
to add custom ribbon RIght click project ->add new item->ribbon visual designer.
Everything you add there will be on the Addins Menu when you F5(run).
You can eliminate any other menu on the sheet/workbook. By setting your custom ribbon property ->Start From Scratch ->TRUE
so there's only your menu showed up.
Whualla .. piece of cake

Minggu, 17 Februari 2008

VSTO

Wew, Vsto can host any control, you can host any control on excel. including infragistics

A song Depicts Jakarta's Road

hmm .. after a series of rain. and none of the roads seems to be fix. i always across many big holes on jakarta's road today.
and this morning i've found a song for it.
it comes from the old mcdonald song.
so here we goes.
"Jakarta has Some Roads"
Iya Iya yooooo
"And in on these road they has Some Holes"
Iya Iya yooooo
"at slipi holes, at menceng holes, at kemang holes"
Iya Iya Yooooo
"Jakarta is a big damn Holes"
Iya Iya Yooooo* upps watch out.... the hole.

Thank You

Kamis, 14 Februari 2008

Towards the End of The World?

Well, Yesterday i saw that MTV commercial. About the Green House effect, 2050 there will be 30 Million people starving, all the big cities will be whelmed by this issue.

And the Glitzer or the ice mountain on the north/south pole will be all melt on 100 years if i'm not hearing it wrong.

Human will be the servant of money. won't care about each other.
I know why.. It's because when we do good deeds , and then we are done browned/deceifed.
so we won't do good deeds anymore, and our heart become a bitter.

if you see the disaster ,etc, will we still be survive in another 100 year?

Rabu, 13 Februari 2008

SPK AbbaLove

Now, this is a pretty awkward(strange) teaching in churches called AbbaLove.
They said "We don't Recognize about Dating, In the Bible said nothing about Dating, there's only Marriage". So many of the cell group community especially girl, dump their sinful boyfriend which have those sin hand :) . So most of them said, "next time if somebody like me, i'd ask him if he's serious with me and jump to marriage".
My girlfriend is in one of their churches. After she said about this, I said " Bloody Hell, What the? are you crazy? People Dating because they want to know each other Character cause you'll be living with that character for the next of your live And a relationship is based on understanding and need more adjustment than you can even think". Relationship will go nothing further with out any effort, even a dog need to take care of, treat right, not to mention HUMAN. her bos which is christian disagree with this too, and most of the guys i think LOL.

I said also "THere's CAN NOT be that BIBLE written about Maria and josef going for a date in somewhere doing this and that??", "or Some Prophets Took His wife for a romantic dinner in some restaurant" Would'nt it?

This is what you called, not mature Mind Set, and social Life.
Which comes from Indonesian perspectives. "Hide those Sex things or Everything refers to it or smell like it undercover, it's taboo"

Senin, 11 Februari 2008

Creating Unit Test with VS 2005 teamsuite

Hey it's easy.
Just Right Click on the method you want to test
Choose Create Test Unit

And wualla the magic is creating new project for testing, and you are just coding on the What params to pass,
and then the Assert.

one thing about Assert is that if the result is false it Throw FAILED.
if true and it keep passing through.
common one:
Assert.EQUAL
ex:Assert.AreEqual(6, actual.Count, "Hey it should return just 6 member");
Assert.isnull
assert.notequal
and etc

Object Binding and Search Support

After i followed the video of how to on vbhowto.
i finally realized that an object can be bind ,what most is search,filter support
here is an example of how to add search support, filtered is next


using System.ComponentModel;
namespace SampleObject
{
public class SearchAbleBindingList : BindingList
{
//first override supportsearching core return true
protected override bool SupportsSearchingCore
{
get
{
return true;
}
}
//second override findcore
protected override int FindCore(PropertyDescriptor prop, object key)
{
for(int i=0;i<=Count-1;i++)
{
T item = this[i];
if (prop.GetValue(item).Equals(key)) return i;
}
return -1;
}
}
}

using System.ComponentModel;
namespace SampleObject
{
public class customer
{
private string _name;
private string _adress;

public string name
{
get { return _name; }
set { _name = value; }
}

public string address
{
get { return _adress; }
set { _adress = value; }
}
private BindingList _orders=new BindingList();

public BindingList orders
{
get { return _orders; }
}

public customer(string _name, string _adress)
{
this._name = _name;
this._adress = _adress;
}
}
public class order
{
private int _id;
private string _productname;
private int _quantity;

public int id
{
get { return _id; }
set { _id = value; }
}

public string productname
{
get { return _productname; }
set { _productname = value; }
}

public int quantity
{
get { return _quantity; }
set { _quantity = value; }
}

public order(int _id, string _productname, int _quantity)
{
this._id = _id;
this._productname = _productname;
this._quantity = _quantity;
}
}
}

Kamis, 07 Februari 2008

UltraPopUpControlContainer

This Control is like Contextmenustrip, the difference this can pop any control. with Point where you want to display

Simple Example
private void ultraPopupControlContainer1_Opening(object sender, CancelEventArgs e)
{
ultraPopupControlContainer1.PopupControl = ultraTree1;
}
private void ultraButton1_Click(object sender, EventArgs e)
{
ultraPopupControlContainer1.Show();
}

Selasa, 05 Februari 2008

Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler Could not be created

Add a reference to Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll

Subclassing a WinDataSource to represent a Business Class

http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=7388

Procedure or function has too many arguments specified.

Check Your Store Procedure,
Your Giving too much parameter, than your store proc does