-CSV betöltés kifejlesztése
-Action beállítása (kép is)
This commit is contained in:
@@ -13,6 +13,13 @@ using DevExpress.ExpressApp.Templates;
|
||||
using DevExpress.ExpressApp.Utils;
|
||||
using DevExpress.Persistent.Base;
|
||||
using DevExpress.Persistent.Validation;
|
||||
using DevExpress.Xpo;
|
||||
using Microsoft.VisualBasic.FileIO;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
using DevExpress.ExpressApp.Xpo;
|
||||
|
||||
namespace Nuvolar.Module.Win.CSharp.Controllers
|
||||
{
|
||||
@@ -23,6 +30,8 @@ namespace Nuvolar.Module.Win.CSharp.Controllers
|
||||
{
|
||||
InitializeComponent();
|
||||
// Target required Views (via the TargetXXX properties) and create their Actions.
|
||||
this.aGIROInfo_ImportCSV.TargetObjectType = typeof(GIROInfo);
|
||||
this.aGIROInfo_ImportCSV.TargetViewType = ViewType.ListView;
|
||||
}
|
||||
protected override void OnActivated()
|
||||
{
|
||||
@@ -39,5 +48,58 @@ namespace Nuvolar.Module.Win.CSharp.Controllers
|
||||
// Unsubscribe from previously subscribed events and release other references and resources.
|
||||
base.OnDeactivated();
|
||||
}
|
||||
|
||||
private void aGIROInfo_ImportCSV_Execute(object sender, SimpleActionExecuteEventArgs e)
|
||||
{
|
||||
XPObjectSpace _onew = Application.CreateObjectSpace() as XPObjectSpace;
|
||||
OpenFileDialog _OpenFileDialog = new OpenFileDialog();
|
||||
|
||||
Nuvolar.Module.Win.WaitFormClass _WaitFormClass = new WaitFormClass();
|
||||
|
||||
_OpenFileDialog.Filter = "csv Files (*.csv)|*.csv";
|
||||
_OpenFileDialog.FilterIndex = 1;
|
||||
|
||||
if (_OpenFileDialog.ShowDialog() == DialogResult.OK && (!String.IsNullOrEmpty(_OpenFileDialog.FileName)))
|
||||
{
|
||||
StreamReader _textStreamReader = new StreamReader(_OpenFileDialog.FileName,Encoding.Default);
|
||||
string _StrBuffer;
|
||||
|
||||
_StrBuffer = _textStreamReader.ReadToEnd();
|
||||
using (TextFieldParser parser = new TextFieldParser(new StringReader(_StrBuffer)))
|
||||
{
|
||||
parser.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited;
|
||||
parser.SetDelimiters(";");
|
||||
|
||||
_WaitFormClass.Initwork(1, 1, 4652);
|
||||
while (!parser.EndOfData)
|
||||
{
|
||||
try
|
||||
{
|
||||
string[] columns = parser.ReadFields();
|
||||
|
||||
GIROInfo _GIROInfo = _onew.FindObject<GIROInfo>(CriteriaOperator.Parse("GIROID=?",columns[0]));
|
||||
if (_GIROInfo == null)
|
||||
{
|
||||
_GIROInfo = _onew.CreateObject<GIROInfo>();
|
||||
}
|
||||
|
||||
_GIROInfo.GIROID = columns[0];
|
||||
_GIROInfo.ShortName = columns[1];
|
||||
_GIROInfo.Address = columns[2];
|
||||
|
||||
_onew.CommitChanges();
|
||||
_WaitFormClass.DoWork();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
_WaitFormClass.FinalWork();
|
||||
}
|
||||
}
|
||||
_WaitFormClass.FinalWork();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user