Mini Kabibi Habibi
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using DevExpress.Xpo;
namespace DevExpress.Xpo.Demos {
public partial class MSSQLServer : TutorialControl {
public override bool SetNewWhatsThisPadding { get { return true; } }
string dataProvider = ".NET Framework Data Provider for OLE DB";
//<gridControl1>
static string connectionString = "packet size=4096;" + "user id=sa;data source=(local);persist security info=True;initial catalog=XPOProjects;password=;connection timeout=2";
public MSSQLServer() {
InitializeComponent();
using(Session session = new Session()) {
session.ConnectionString = connectionString;
try {
session.Connect();
session.Disconnect();
this.unitOfWork1.ConnectionString = connectionString;
dataProvider = ".NET Framework Data Provider for SQL Server";
}
catch(DevExpress.Xpo.DB.Exceptions.UnableToOpenDatabaseException) {
}
}
}
//</gridControl1>
#region Editors Initialization
private void InitEditors() {
this.repositoryItemImageComboBox1.Items.AddRange(new object[] {
new DevExpress.XtraEditors.Controls.ImageComboBoxItem("Fixed", ProjectStatus.Fixed, 0),
new DevExpress.XtraEditors.Controls.ImageComboBoxItem("New", ProjectStatus.New, 1),
new DevExpress.XtraEditors.Controls.ImageComboBoxItem("Postponed", ProjectStatus.Postponed, 2),
new DevExpress.XtraEditors.Controls.ImageComboBoxItem("Rejected", ProjectStatus.Rejected, 3)});
this.repositoryItemImageComboBox2.Items.AddRange(new object[] {
new DevExpress.XtraEditors.Controls.ImageComboBoxItem("Bug", ProjectType.Bug, 0),
new DevExpress.XtraEditors.Controls.ImageComboBoxItem("Request", ProjectType.Request, 1)});
textEdit1.Text = dataProvider;
}
#endregion
private void MSSQLServer_Load(object sender, System.EventArgs e) {
InitEditors();
if(xpProjects.Count == 0) {
CreateProjects(unitOfWork1);
xpProjects.Reload();
}
if(unitOfWork1.ConnectionString == connectionString)
DevExpress.XtraEditors.XtraMessageBox.Show("You have successfully connected to your local MS SQL Server.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
else
DevExpress.XtraEditors.XtraMessageBox.Show("You have failed to connect to your local MS SQL Server.\nXPO uses the MS Access OLEDB provider instead.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
private void bSave_Click(object sender, System.EventArgs e) {
SaveChanges(unitOfWork1);
}
public override void ReloadData() {
xpProjects.Reload();
}
}
}