Monday, November 23, 2009

How To Convert ArrayList to String

ArrayList ar =new arrayList();
string jj=string .Empty;
jj=string.Join(“,”, (string []) ar.ToArray(typeof(string)))

How To Hide Some Class from New Button List/Navigation Item in XAF

public partial class HideItemsControll : WinNewObjectViewController
{
public HideItemsControll()
{
InitializeComponent();
RegisterActions(components);
}
protected override void OnActivated()
{
base.OnActivated();
CollectCreatableItemTypes += new EventHandler(HideItemsControll_CollectCreatableItemTypes);
}
void HideItemsControll_CollectCreatableItemTypes(object sender, CollectTypesEventArgs e)
{
CustomizeList(e.Types);

}
public void CustomizeList(ICollection types)
{
//Get the ShowNavigationItemController, then get its ShowNavigationItemAction
SingleChoiceAction showNavigationItemAction = Frame.GetController().ShowNavigationItemAction;
//Get the item selected in the navigation control
ChoiceActionItem selectedItem = showNavigationItemAction.SelectedItem;
ChoiceActionItem currentGroup = null;
if (selectedItem != null)
{
//Get the selected item's parent group
currentGroup = selectedItem.ParentItem;
List unusableTypes = new List();
//Collect the types that must be deleted
foreach (Type type in types)
{
//bool deletionRequired = true;
if (type.Name.Equals("BillByBill"))
{
unusableTypes.Add(type);
}
if (type.Name.Equals("AccountIntrest"))
{
unusableTypes.Add(type);
}
foreach (Type type in unusableTypes)
types.Remove(type);
}}}

How to Find ObjectSpace

ObjectSpace os=ObjectSpace.FindObjectSpace(Object)
Here we can see the unit of work

How To Find Type of a Property/Member

memberName=amont;

ITypeInfo TypeInfo= XafTypesInfo.Instance.FindTypeInfo();
IMemberInfo iminfo = TypeInfo.FindMember(memberName);
If (iminfo.MemberTypeInfo.Type == typeof(double)){}

The Default View Only Populate After a Search has been done and Not Automatically Populate the View at Startup

Here ListView Data Will Not be Populated on Activated , Data Will be Populated when
You search anything

namespace FilterListView.Module
{
public partial class ViewController1 : ViewController
{
public ViewController1()
{
InitializeComponent();
RegisterActions(components);
}
protected override void OnActivated()
{
base.OnActivated();
if (View is ListView && View.ObjectTypeInfo.Type == typeof(ContactA))
{
ListView lv = (ListView)View;
lv.CollectionSource.CollectionChanged += new EventHandler(CollectionSource_CollectionChanged); }
}

void CollectionSource_CollectionChanged(object sender, EventArgs e)
{
ListView listView = (ListView)View ;
if (listView.CollectionSource.Collection.Count > 0)
{
if (!listView.CollectionSource.Criteria.ContainsKey("EmptyCollectionCriteria")) {
listView.CollectionSource.Criteria.Add("EmptyCollectionCriteria", CollectionSource.EmptyCollectionCriteria);
}
listView.CollectionSource.Criteria.Changed += new EventHandler(Criteria_Changed);
}
}
void Criteria_Changed(object sender, EventArgs e)
{
ListView listView = (ListView)View;
listView.CollectionSource.Criteria.Remove("EmptyCollectionCriteria");
}
}
}

Associassion Through Module Base with the help of Interface

Here I have two modules Xpert.Account and Xpert.Statutory. In Account Modules.cs I
have to add two Properties
FormsToIssue, FormsToRecieve in a Class which have Implemented ICST Interface
public sealed partial class InModule : ModuleBase
{
public InModule()
{
InitializeComponent();
}

public override void CustomizeTypesInfo(DevExpress.ExpressApp.DC.ITypesInfo typesInfo)
{
base.CustomizeTypesInfo(typesInfo);
if (Application == null || Application.XPDictionary == null) return;
XPDictionary xpDCT = XafTypesInfo.XpoTypeInfoSource.XPDictionary;
foreach (XPClassInfo item in Application.XPDictionary.Classes)
{
if (item.ClassType != null && XafTypesInfo.Instance.FindTypeInfo(item.ClassType).ImplementsICST())
{
classInfo = item;
if (XafTypesInfo.Instance.FindTypeInfo(classInfo.ClassType).ImplementsICST())
{
if (classInfo.FindMember(classInfo.ClassType.Name) == null && classInfo.BaseClass.FindMember(classInfo.ClassType.Name) == null)
{
classInfo.CreateMember("FormsToIssue", typeof(StatutoryForms), new VisibleInListViewAttribute(false), new VisibleInLookupListViewAttribute(false));
classInfo.CreateMember("FormsToRecieve", typeof(StatutoryForms), new VisibleInListViewAttribute(false), new VisibleInLookupListViewAttribute(false));
}
XafTypesInfo.Instance.RefreshInfo(classInfo.ClassType);
}}}}}}
Here ICST is a Interface that is attached with various Class in that class two
property will be added

How To Find Method of Other Modules

Here PurchaseUtils is a Class and have a Static Method ClosingBalance with Three
Argument in a Different Modules Xpert.Procurement
And this method is Used in AccountModules Xpert.Account and we can not used
Xpert.Procurement This DLL in Account Module because AccountModules is Top Level
So we used this Method by this way as given below…..
First here we find the class in which Method is defined here method is defined in
PurchaseUtils Class
Now find the Method and Pass Parameter……

Type TP = ReflectionHelper.FindType("PurchaseUtils");
MethodInfo MI = TP.GetMethod("ClosingBalance");
object[] parameters = new object[3];
parameters[0] = Session;
XPCollection x = new XPCollection(ReflectionHelper.FindType("ItemDetails"));
parameters[1] = DateTime.Now;
parameters[2] = DateTime.Now;
_Amount = (double)(MI.Invoke(null, parameters));

Wednesday, November 11, 2009

How To Set Column Width in AspxGridView in C#

There are Two Class Ledger and AccountGroup ,There is a XpCollection of Ledger on AccountGroup and its one part is on Ledger
Now Find Ledger Property From AccountGroup and Find its ListView and then Find the Column whose width you have to Change.
if (View is DetailView && View.ObjectTypeInfo.Type == typeof(AccountGroup))
{
DetailView dv = (DetailView)View;
ListPropertyEditor lv = (ListPropertyEditor)dv.FindItem("Ledger");
ListView Lv = (ListView)lv.ListView;
ASPxGridListEditor editor = (ASPxGridListEditor)lv.ListView.Editor;
ASPxGridControl gridView = editor.Grid;
gridView.SettingsBehavior.ColumnResizeMode = ColumnResizeMode.Control;
gridView.Columns["Name"].Width = new System.Web.UI.WebControls.Unit(350);
}

Monday, November 9, 2009

How To Backup a Database in C#

XpertData is Source Folder that we have to take Backup and store it on E:\Web string sourceDir = @"D:\XpertData";
string backupDir = @"E:\web";
try
{
string[] picList = Directory.GetFiles(sourceDir, "*.mdb");
string[] txtList = Directory.GetFiles(sourceDir, "*.ldb");

foreach (string f in picList)
{
string fName = f.Substring(sourceDir.Length + 1);
File.Copy(Path.Combine(sourceDir, fName), Path.Combine(backupDir, fName), true);
}
foreach (string f in txtList)
{

string fName = f.Substring(sourceDir.Length + 1);
try
{
File.Copy(Path.Combine(sourceDir, fName), Path.Combine(backupDir, fName));
}

catch (IOException copyError)
{
Console.WriteLine(copyError.Message);v }
}
}
catch (DirectoryNotFoundException dirNotFound)
{
Console.WriteLine(dirNotFound.Message);
}

Followers

Visitor No

click for free hit counter
Download a free hit counter here.