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.
 
 
 
 

210 lines
7.3 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Stone.Common;
using Stone.Entity;
namespace Stone.WinModule.JISData
{
public partial class frmJISASA : Stone.WinModule.BasicData.frmBaseMain
{
public frmJISASA()
{
InitializeComponent();
this.tlbAdd.Visible = false;
this.tlbAddCopy.Visible = false;
this.tlbEdit.Visible = false;
this.tlbDelete.Visible = false;
this.tlbInput.Visible = false;
this.tlbFilter.Visible = false;
this.txtPackageGroupName.DataSource = new Entity_t_Sys_AppconfigItem().GetData("[Code]='print_group' and [Value1] is not null").Tables[0];
this.txtPackageGroupName.DisplayMember = "Value1";
this.txtPackageGroupName.ValueMember = "Value1";
this.dateTimePicker1.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
this.dateTimePicker2.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);
}
public override void init()
{
this.strWhere = "ID = 0";
try
{
//strWhere = "convert(varchar(10),[SwetTime],120)='" + MyDateTime.Format(MyDateTimeType.Date) + "'";
}
catch { }
base.init();
}
public override void Search(string code)
{
string PackageGroupName = this.txtPackageGroupName.SelectedValue.ToString();
string d1 = this.dateTimePicker1.Value.ToString("yyyy-MM-dd HH:mm:00");
string d2 = this.dateTimePicker2.Value.ToString("yyyy-MM-dd HH:mm:59");
if (code == "")
{
strWhere = "1=1";
}
else
{
strWhere = " [orderNumber] = '" + code + "'";
}
string strPackageGroupName = "";
if (PackageGroupName == "")
{
strPackageGroupName = "1=1";
}
else
{
strPackageGroupName = " [PackageGroupName] = '" + PackageGroupName + "'";
}
strWhere = "[SwetTime]>='" + d1 + "' and [SwetTime]<='" + d2 + "' and (" + strWhere + ")" + " and (" + strPackageGroupName + ")";
}
private void frmJISLog_Load(object sender, EventArgs e)
{
}
private void btnCheck_Click(object sender, EventArgs e)
{
this.btnCheck.Text = "校验中...";
this.btnCheck.Enabled = false;
this.btnCheck.Update();
try
{
if (this.dgrdView.Rows.Count == 0) throw new Exception("请先查询出要校验的数据");
if (this.openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
Entity_t_JIS_Log t_JIS_Log = new Entity_t_JIS_Log();
DataRow drLog = t_JIS_Log.Table.NewRow();
drLog["FileType"] = "导入校验";
drLog["FileName"] = this.openFileDialog1.SafeFileName;
drLog["StartTime"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
drLog = t_JIS_Log.Add(drLog);
try
{
DataTable dtData = ReadData(this.openFileDialog1.FileName);
DataTable dtCheck = (DataTable)this.dgrdView.DataSource;
string msg1 = "";
string msg2 = "";
foreach (DataRow drData in dtData.Rows)
{
string OrderNo = drData["OrderNo"].ToString() + "1";
if (dtCheck.Select("[OrderNumber]='" + OrderNo + "'").Length == 0)
{
msg1 += OrderNo + ",";
}
}
foreach (DataRow drData in dtCheck.Rows)
{
string OrderNumber = drData["OrderNumber"].ToString();
OrderNumber = OrderNumber.Substring(0, OrderNumber.Length - 1);
if (dtData.Select("[OrderNo]='" + OrderNumber + "'").Length == 0)
{
msg2 += OrderNumber + ",";
}
}
if (msg1 == "" && msg2 == "")
{
drLog["ProcessState"] = "Success";
drLog["EndTime"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
t_JIS_Log.Edit(drLog);
MyMessageBox.ShowInfoMessage("校验OK");
}
else
{
string memo1 = msg1;
string memo2 = msg2;
if (memo1.Length > 200) memo1 = memo1.Substring(0, 200) + "...";
if (memo2.Length > 200) memo2 = memo2.Substring(0, 200) + "...";
drLog["ProcessState"] = "Failed";
drLog["Memo"] = "少号:" + memo1 + "\r\n多号:" + memo2;
drLog["EndTime"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
t_JIS_Log.Edit(drLog);
frmJISASA_Input_Info frm = new frmJISASA_Input_Info();
frm.txtMsg1.Text = msg1;
frm.txtMsg2.Text = msg2;
frm.ShowDialog();
frm.Dispose();
}
}
catch (Exception ex)
{
MyMessageBox.ShowErrorMessage(ex.Message);
}
}
}
catch (Exception ex)
{
MyMessageBox.ShowErrorMessage(ex.Message);
}
finally
{
Application.DoEvents();
this.btnCheck.Text = "订单导入校验";
this.btnCheck.Enabled = true;
}
}
private DataTable ReadData(string filename)
{
DataTable dtRet = new DataTable();
dtRet.Columns.Add("OrderNo");
System.IO.StreamReader sr = null;
try
{
sr = new System.IO.StreamReader(filename);
string line;
while ((line = sr.ReadLine()) != null)
{
if (line.Trim() == "") continue;
string[] sp = line.Split(',');
if (sp[8].Trim() == "OrderNo") continue;
DataRow drNew = dtRet.NewRow();
drNew["OrderNo"] = sp[8].Trim();
dtRet.Rows.Add(drNew);
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (sr != null) sr.Close();
}
return dtRet;
}
}
}