Mini Kabibi Habibi
using System.Collections.Generic;
using System.Data;
using System;
using DevExpress.Utils;
namespace DashboardMainDemo {
public static class DataLoader {
static string GetRelativePath(string name) {
name = "Data\\" + name;
string path = System.Windows.Forms.Application.StartupPath;
string s = "\\";
for(int i = 0; i <= 10; i++) {
if(System.IO.File.Exists(path + s + name))
return (path + s + name);
else
s += "..\\";
}
path = Environment.CurrentDirectory;
s = "\\";
for(int i = 0; i <= 10; i++) {
if(System.IO.File.Exists(path + s + name))
return (path + s + name);
else
s += "..\\";
}
return "";
}
static DataSet LoadData(string fileName) {
string path = GetRelativePath(string.Format("{0}.xml", fileName));
DataSet ds = new DataSet();
ds.ReadXml(path, XmlReadMode.ReadSchema);
return ds;
}
public static DataSet LoadSales() {
return LoadData("DashboardSales");
}
public static DataSet LoadEmployees() {
return LoadData("DashboardEmployeesAndDepartments");
}
public static DataSet LoadCustomerSupport() {
return LoadData("DashboardCustomerSupport");
}
}
}