大连融科 WMS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

133 lines
3.7 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;
namespace SiaSun.LMS.WPFClient.GOODS
{
/// <summary>
/// PLAN_IMPORT.xaml 的交互逻辑
/// </summary>
public partial class GOODS_IMPORT : AvalonDock.DocumentContent
{
public GOODS_IMPORT()
{
InitializeComponent();
}
/// <summary>
/// 加载窗体
/// </summary>
private void DocumentContent_Loaded(object sender, RoutedEventArgs e)
{
}
/// <summary>
/// 按钮点击事件
/// </summary>
private void WrapPanel_Click(object sender, RoutedEventArgs e)
{
Button btn = e.OriginalSource as Button;
if (btn != null)
{
switch (btn.Name)
{
case "btnOpen":
this.ImportExcel();
break;
case "btnSave":
this.Save();
break;
case "btnRefresh":
this.gridImport.ItemsSource = null;
break;
}
}
}
/// <summary>
/// 导入EXCEL数据
/// </summary>
private void ImportExcel()
{
using (System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog())
{
//openFileDialog.Filter = "Excel 2007文件|*.xlsx|Excel 2003|*.xls";
if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string fileName = openFileDialog.FileName;
if (string.IsNullOrEmpty(fileName))
{
MainApp._MessageDialog.ShowDialog("请选择Excel文件");
return;
}
this.gridImport.ItemsSource = new SiaSun.LMS.Common.Excel().ImportToDataTable(fileName, true).DefaultView;
}
//Dialog.ImportExcelDialog winImport = new Dialog.ImportExcelDialog(false, "GOODS_MAIN_IMPORT");
//if (winImport.ShowDialog() == true)
//{
// this.gridImport.ItemsSource = winImport.dsImport.Tables[0].DefaultView;
// winImport.Close();
//}
}
}
/// <summary>
/// 保存
/// </summary>
private void Save()
{
string mesResult = string.Empty;
string sResult = string.Empty;
bool bResult = true;
try
{
DataTable dtImport = (this.gridImport.ItemsSource as DataView).Table;
if (dtImport.Rows.Count == 0)
{
MainApp._MessageDialog.Show(false, "不存在导入的数据源");
return;
}
dtImport.TableName = "ExcelImport";
bResult = MainApp._I_BaseService.Invoke("PlanImport", "GoodsCreate", new object[] { dtImport,2 }, out sResult);
if (bResult)
{
this.gridImport.ItemsSource = null;
}
MainApp._MessageDialog.Show(bResult, sResult);
}
catch (Exception ex)
{
MainApp._MessageDialog.ShowException(ex);
}
}
}
}