一直在想法子找点兼职做,多赚money。
好了不废话了,就最近做的这个小系统的感触。
1。幸好我使用了BaseForm
这样,就可以通过一个外观控制器DevExpress的,来控制系统的整体外观。
其次,可以通过这个来增加一些通用的方法,比如从DevExpress的GridContro里面获取选择列的某一个Key,或者写一些设置某些枚举类型,比如 支付类型 等等的下拉框
还有,实现BaseForm的Key_Press事件,这样每个窗体都默认会实现回车跳转下一个的功能。还有,比如把GridControl的数据保存成Excel Text Html都是可以的。
2。使用了逻辑和界面分离,比较核心的,比如 ,商品入库的同时需要库存增加
这样,即使以后要做成Remoting/WebService也是可行的。
3。还有就是给她安装了以后,后来因为需求的变化,需要增加字段,但是又要保留原来的数据,给她安装的是MSDE,没有SQL企业管理器。
无可奈何,至少上网七找八找,终于找到了恢复数据库+执行SQL语句的方法,
后来又由于用TM,不能在DOS输入,只好使用 osql -E -i c:\clearn.sql的形式来执行
sql语句。
获取GridView的选择行的对应的某单元的值:GetGridControlSelectValue#region 获取GridView的选择行的对应的某单元的值:GetGridControlSelectValue
/**//// <summary>
/// 获取GridView的选择行的对应的某单元的值:GetGridControlSelectValue
/// </summary>
/// <param name="gridView"></param>
/// <param name="dataColumnName"></param>
/// <returns></returns>
public object GetGridControlSelectValue(DevExpress.XtraGrid.Views.Grid.GridView gridView,string dataColumnName)
{
if (gridView.SelectedRowsCount > 0)
{
return gridView.GetDataRow(gridView.GetSelectedRows()[0])[dataColumnName];
}
else
return null;
}
#endregion
打开文件#region 打开文件
/**//// <summary>
/// 打开文件
/// </summary>
/// <param name="fileName">文件名</param>
public void OpenFile(string fileName)
{
if(MessageBox.Show("是否想要打开这个文件?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
try
{
Process process = new Process();
process.StartInfo.FileName = fileName;
process.StartInfo.Verb = "Open";
process.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
process.Start();
}
catch
{
MessageBox.Show(this, "您的系统不能打开该类型的文件!.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
#endregion
把GridControl的数据输出#region 把GridControl的数据输出
/**//// <summary>
/// 把GridControl的数据输出
/// </summary>
/// <param name="provider">输出提供者</param>
/// <param name="gridView1">DevExpress GridView</param>
public void ExportTo(IExportProvider provider,GridView gridView1)
{
Cursor currentCursor = Cursor.Current;
Cursor.Current = Cursors.WaitCursor;
BaseExportLink link = gridView1.CreateExportLink(provider);
(link as GridViewExportLink).ExpandAll = false;
link.ExportTo(true);
Cursor.Current = currentCursor;
}
/**//// <summary>
/// 把GridControl的数据输出输出成Html
/// </summary>
/// <param name="provider"></param>
/// <param name="gridView1"></param>
public void ExportToHtml(GridView gridView1)
{
string fileName = ShowSaveFileDialog("HTML 文档", "HTML 文档|*.html");
if(fileName != "")
{
ExportTo(new ExportHtmlProvider(fileName),gridView1);
OpenFile(fileName);
}
}
/**//// <summary>
/// 把GridControl的数据输出输出成Xml
/// </summary>
/// <param name="gridView1"></param>
public void ExportToXml(GridView gridView1)
{
string fileName = ShowSaveFileDialog("Xml 文档", "Xml 文档|*.xml");
if(fileName != "")
{
ExportTo(new ExportXmlProvider(fileName),gridView1);
OpenFile(fileName);
}
}
/**//// <summary>
/// 把GridControl的数据输出输出成Excel
/// </summary>
/// <param name="gridView1"></param>
public void ExportToExcel(GridView gridView1)
{
string fileName = ShowSaveFileDialog("Excel 文档", "Excel 文档|*.xls");
if(fileName != "")
{
ExportTo(new ExportXlsProvider(fileName),gridView1);
OpenFile(fileName);
}
}
/**//// <summary>
/// 把GridControl的数据输出输出成Text文本
/// </summary>
/// <param name="gridView1"></param>
public void ExportToText(GridView gridView1)
{
string fileName = ShowSaveFileDialog("Text 文档", "Text 文档|*.txt");
if(fileName != "")
{
ExportTo(new ExportTxtProvider(fileName),gridView1);
OpenFile(fileName);
}
}
#endregion
提示保存窗口#region 提示保存窗口
/**//// <summary>
/// 提示保存窗口
/// </summary>
/// <param name="title"></param>
/// <param name="filter"></param>
/// <returns></returns>
public string ShowSaveFileDialog(string title, string filter)
{
SaveFileDialog dlg = new SaveFileDialog();
string name = Application.ProductName;
int n = name.LastIndexOf(".") + 1;
if(n > 0) name = name.Substring(n, name.Length - n);
dlg.Title = "Export To " + title;
dlg.FileName = name;
dlg.Filter = filter;
if(dlg.ShowDialog() == DialogResult.OK) return dlg.FileName;
return "";
}
#endregion
/**//// <summary>
/// 获取GridView的选择行的对应的某单元的值:GetGridControlSelectValue
/// </summary>
/// <param name="gridView"></param>
/// <param name="dataColumnName"></param>
/// <returns></returns>
public object GetGridControlSelectValue(DevExpress.XtraGrid.Views.Grid.GridView gridView,string dataColumnName)
{
if (gridView.SelectedRowsCount > 0)
{
return gridView.GetDataRow(gridView.GetSelectedRows()[0])[dataColumnName];
}
else
return null;
}
#endregion
打开文件#region 打开文件
/**//// <summary>
/// 打开文件
/// </summary>
/// <param name="fileName">文件名</param>
public void OpenFile(string fileName)
{
if(MessageBox.Show("是否想要打开这个文件?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
try
{
Process process = new Process();
process.StartInfo.FileName = fileName;
process.StartInfo.Verb = "Open";
process.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
process.Start();
}
catch
{
MessageBox.Show(this, "您的系统不能打开该类型的文件!.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
#endregion
把GridControl的数据输出#region 把GridControl的数据输出
/**//// <summary>
/// 把GridControl的数据输出
/// </summary>
/// <param name="provider">输出提供者</param>
/// <param name="gridView1">DevExpress GridView</param>
public void ExportTo(IExportProvider provider,GridView gridView1)
{
Cursor currentCursor = Cursor.Current;
Cursor.Current = Cursors.WaitCursor;
BaseExportLink link = gridView1.CreateExportLink(provider);
(link as GridViewExportLink).ExpandAll = false;
link.ExportTo(true);
Cursor.Current = currentCursor;
}
/**//// <summary>
/// 把GridControl的数据输出输出成Html
/// </summary>
/// <param name="provider"></param>
/// <param name="gridView1"></param>
public void ExportToHtml(GridView gridView1)
{
string fileName = ShowSaveFileDialog("HTML 文档", "HTML 文档|*.html");
if(fileName != "")
{
ExportTo(new ExportHtmlProvider(fileName),gridView1);
OpenFile(fileName);
}
}
/**//// <summary>
/// 把GridControl的数据输出输出成Xml
/// </summary>
/// <param name="gridView1"></param>
public void ExportToXml(GridView gridView1)
{
string fileName = ShowSaveFileDialog("Xml 文档", "Xml 文档|*.xml");
if(fileName != "")
{
ExportTo(new ExportXmlProvider(fileName),gridView1);
OpenFile(fileName);
}
}
/**//// <summary>
/// 把GridControl的数据输出输出成Excel
/// </summary>
/// <param name="gridView1"></param>
public void ExportToExcel(GridView gridView1)
{
string fileName = ShowSaveFileDialog("Excel 文档", "Excel 文档|*.xls");
if(fileName != "")
{
ExportTo(new ExportXlsProvider(fileName),gridView1);
OpenFile(fileName);
}
}
/**//// <summary>
/// 把GridControl的数据输出输出成Text文本
/// </summary>
/// <param name="gridView1"></param>
public void ExportToText(GridView gridView1)
{
string fileName = ShowSaveFileDialog("Text 文档", "Text 文档|*.txt");
if(fileName != "")
{
ExportTo(new ExportTxtProvider(fileName),gridView1);
OpenFile(fileName);
}
}
#endregion
提示保存窗口#region 提示保存窗口
/**//// <summary>
/// 提示保存窗口
/// </summary>
/// <param name="title"></param>
/// <param name="filter"></param>
/// <returns></returns>
public string ShowSaveFileDialog(string title, string filter)
{
SaveFileDialog dlg = new SaveFileDialog();
string name = Application.ProductName;
int n = name.LastIndexOf(".") + 1;
if(n > 0) name = name.Substring(n, name.Length - n);
dlg.Title = "Export To " + title;
dlg.FileName = name;
dlg.Filter = filter;
if(dlg.ShowDialog() == DialogResult.OK) return dlg.FileName;
return "";
}
#endregion