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.
 
 
 
 

306 lines
12 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;
using Stone.WinBiz.JISAdmin;
namespace Stone.WinModule.JISAdmin.ReOrder
{
public partial class frmEdiPrintReOrderASN : Stone.WinModule.frmBase
{
public frmEdiPrintReOrderASN()
{
InitializeComponent();
}
private void frmEdiPrintReOrderASN_Load(object sender, EventArgs e)
{
this.cbFields.SelectedIndex = 0;
this.timer1.Interval = Convert.ToInt32(MyAppconfig.ReadValue("EDI显示刷新时间")) * 1000;
this.timer1.Enabled = true;
}
private void btnQuery_Click(object sender, EventArgs e)
{
try
{
string Fields = this.cbFields.SelectedItem.ToString();
string value = this.txtKey.Text.Trim();
string d1 = MyDateTime.Format(this.dateTimePicker1.Value, MyDateTimeType.Date) + " 00:00:00";
string d2 = MyDateTime.Format(this.dateTimePicker2.Value, MyDateTimeType.Date) + " 23:59:59";
string strWhere = "[IsPrintPackingList]=1 and [IsPrintASN]={0} and [SwetTime]>='{1}' and [SwetTime]<='{2}' {3}";
object[] obj = new object[10];
obj[0] = rbPrint1.Checked ? "1" : "0";
obj[1] = d1;
obj[2] = d2;
obj[3] = " and " + Fields + "='" + value + "'";
if (value == "") obj[3] = "";
strWhere = string.Format(strWhere, obj);
Entity_t_JIS_Seq5000_ReOrder t_JIS_Seq5000_ReOrder = new Entity_t_JIS_Seq5000_ReOrder();
this.dgrdView1.DataSource = t_JIS_Seq5000_ReOrder.GetData("", strWhere, "[SwetTime], [SequenceNumber] asc").Tables[0];
MyGridViewStyle.SetDataGridRowNumber(this.dgrdView1);
MyGridViewStyle.SetDataGridMenuCommon(this.dgrdView1);
MyGridViewStyle.GetGridViewState(this.dgrdView1, "ReOrderASN");
this.dgrdView1.Columns["ID"].Visible = false;
this.dgrdView1.Columns["SequenceNumber"].HeaderText = "EINSTEIN Seq";
this.lblState.Text = "记录:" + this.dgrdView1.Rows.Count.ToString();
}
catch (Exception ex)
{
this.lblShow.Text = ex.Message;
}
}
private void btnPrintHand_Click(object sender, EventArgs e)
{
this.btnPrintHand.Enabled = false;
this.Update();
try
{
if (!MyMessageBox.ShowQuestion("请按Sift或Ctrl键选择多条要打印的记录,是否要打印?")) return;
if (this.dgrdView1.SelectedRows.Count == 0) throw new Exception("请选择需要打印的多条记录!");
string ids = "";
for (int i = 0; i < this.dgrdView1.SelectedRows.Count; i++)
{
ids += this.dgrdView1.SelectedRows[i].Cells["ID"].Value.ToString() + ",";
}
if (ids.Length > 0) ids = ids.Substring(0, ids.Length - 1);
string strWhere = "[ID] in (" + ids + ")";
this.lblOutput.Text = "正在打印和上传...";
this.Update();
Entity_t_JIS_Seq5000_ReOrder t_JIS_Seq5000_ReOrder = new Entity_t_JIS_Seq5000_ReOrder();
DataSet dsData = t_JIS_Seq5000_ReOrder.GetData("", strWhere, "[SwetTime], [SequenceNumber] ASC");
if (dsData.Tables[0].Select("[IsPrintASN]=1").Length > 0)
throw new Exception("选择的记录中有已经打印的数据,请刷新数据!");
dsData.Tables[0].TableName = "BillHead";
string AsnNumber = F_JIS5000_Print_ReOrder.GetASNNumber();
t_JIS_Seq5000_ReOrder.Edit("[IsPrintASN]=1, [AsnNumber]='" + AsnNumber + "'", strWhere);
F_JIS5000_Print_ReOrder.PrintASNList(dsData, AsnNumber);
dsData.Tables[0].TableName = "ReOrder";
F_JIS5000_Print.WriteASN_ReOrder(dsData, AsnNumber);
btnQuery_Click(new object(), new EventArgs());
}
catch (Exception ex)
{
MyMessageBox.ShowErrorMessage(ex.Message);
}
finally
{
this.lblOutput.Text = "";
this.btnPrintHand.Enabled = true;
Application.DoEvents();
}
}
private void btnRePrint_Click(object sender, EventArgs e)
{
try
{
if (!MyMessageBox.ShowQuestion("是否要补打ASN?")) return;
if (this.dgrdView1.SelectedRows.Count == 0) throw new Exception("请选择要补打的记录!");
string AsnNumber = this.dgrdView1.SelectedRows[0].Cells["AsnNumber"].Value.ToString();
if (AsnNumber == "") throw new Exception("只有已经打印过的才能补打!");
Entity_t_JIS_Seq5000_ReOrder t_JIS_Seq5000_ReOrder = new Entity_t_JIS_Seq5000_ReOrder();
DataSet dsData = t_JIS_Seq5000_ReOrder.GetData("", "[AsnNumber]='" + AsnNumber + "'", "[SwetTime], [SequenceNumber] ASC");
if (dsData.Tables[0].Select("[IsPrintASN]=0").Length > 0)
throw new Exception("没有可打印的数据");
dsData.Tables[0].TableName = "BillHead";
F_JIS5000_Print_ReOrder.PrintASNList(dsData, AsnNumber);
btnQuery_Click(new object(), new EventArgs());
}
catch (Exception ex)
{
MyMessageBox.ShowErrorMessage(ex.Message);
}
}
private void btnSet_Click(object sender, EventArgs e)
{
MyGridViewStyle.Show(this.dgrdView1, "ReOrderASN");
}
private void btnOutPut_Click(object sender, EventArgs e)
{
#region old
/*
try
{
//Stone.Common.MyExport.ShowExport(this.dgrdView1);
if (this.dgrdView1.DataSource == null) throw new Exception("请先查询出数据");
if (this.dgrdView1.SelectedRows.Count == 0) throw new Exception("请选择要导出的数据");
DataTable dtData = ((DataTable)this.dgrdView1.DataSource).Copy();
dtData.Columns.Add("qty", typeof(Int32));
if (dtData.Rows.Count == 0) throw new Exception("请先查询出数据");
if (!MyMessageBox.ShowQuestion("导出的信息中包含所有小件的信息,导出的时间比较长,是否要导出?")) return;
//DataTable dtOut = dtData.Clone();
DataTable dtOut = new DataTable();
dtOut.Columns.Add("CheckSequence");
dtOut.Columns.Add("SwetTime");
dtOut.Columns.Add("SequenceNumber");
dtOut.Columns.Add("Variant");
dtOut.Columns.Add("OrderNumber");
dtOut.Columns.Add("PartsFamily");
dtOut.Columns.Add("SupplyGroup");
dtOut.Columns.Add("AsnNumber");
dtOut.Columns.Add("PackingListNumber");
dtOut.Columns.Add("partNumber");
dtOut.Columns.Add("PartName");
dtOut.Columns.Add("PartColor");
dtOut.Columns.Add("qty", typeof(System.Int32));
Entity_v_JIS_Tod v_JIS_Tod = new Entity_v_JIS_Tod();
int i = 0;
foreach (DataRow drData in dtData.Rows)
{
i++;
this.lblOutput.Text = "正在导出第 " + i.ToString() + " 条主零件";
this.Update();
string OrderNumber = drData["OrderNumber"].ToString();
string PartsFamily = drData["PartsFamily"].ToString();
string SupplyGroup = drData["SupplyGroup"].ToString();
string strWhere = "[OrderNumber]='" + OrderNumber + "' and [PartsFamily]='" + PartsFamily + "' and [SupplyGroup]='" + SupplyGroup + "'";
DataSet dsTod = v_JIS_Tod.GetData("", strWhere, "partNumber asc");
foreach (DataRow drEdi_daily_package_temp in dsTod.Tables[0].Rows)
{
DataRow drNew = dtOut.NewRow();
drNew["CheckSequence"] = drData["CheckSequence"].ToString();
drNew["SwetTime"] = drData["SwetTime"].ToString();
drNew["SequenceNumber"] = drData["SequenceNumber"].ToString();
drNew["Variant"] = drData["Variant"].ToString();
drNew["OrderNumber"] = drEdi_daily_package_temp["OrderNumber"].ToString();
drNew["PartsFamily"] = drEdi_daily_package_temp["PartsFamily"].ToString();
drNew["SupplyGroup"] = drEdi_daily_package_temp["SupplyGroup"].ToString();
drNew["AsnNumber"] = drData["AsnNumber"].ToString();
drNew["PackingListNumber"] = drData["PackingListNumber"].ToString();
drNew["partNumber"] = drEdi_daily_package_temp["partNumber"].ToString();
drNew["PartName"] = drEdi_daily_package_temp["description"].ToString();
drNew["PartColor"] = drEdi_daily_package_temp["ColorName"].ToString();
drNew["qty"] = drEdi_daily_package_temp["quantity"].ToString();
dtOut.Rows.Add(drNew);
}
}
this.lblOutput.Text = "";
object o_sum = dtOut.Compute("sum(qty)", "1=1");
if (o_sum.ToString() == "") o_sum = 0;
frmEdiPrintASNOut frm = new frmEdiPrintASNOut();
frm.dgrdView1.DataSource = dtOut;
frm.label1.Text = "记录数:" + dtOut.Rows.Count.ToString() + " 数量合计:" + o_sum.ToString();
frm.ShowDialog();
}
catch (Exception ex)
{
MyMessageBox.ShowInfoMessage(ex.Message);
}
*/
#endregion
try
{
frmEdiPrintASNOutNew frm = new frmEdiPrintASNOutNew();
frm.Text = "导出ASN";
frm.t_base = new Entity_t_JIS_ASN_ReOrder();
frm.ShowDialog();
frm.Dispose();
}
catch (Exception ex)
{
MyMessageBox.ShowErrorMessage(ex.Message);
}
}
private void chkAuto_CheckedChanged(object sender, EventArgs e)
{
AutoUpdate();
}
private void timer1_Tick(object sender, EventArgs e)
{
AutoUpdate();
}
private void AutoUpdate()
{
if (chkAuto.Checked)
{
this.lblShow.Text = "自动刷新中...";
this.Update();
btnQuery_Click(new object(), new EventArgs());
this.lblShow.Text = DateTime.Now.ToString() + " 自动刷新完成,下次刷新 " + Convert.ToString(this.timer1.Interval / 1000) + " 秒以后";
}
else
{
this.lblShow.Text = "自动刷新关闭";
}
}
private void frmEdiPrintReOrderASN_FormClosing(object sender, FormClosingEventArgs e)
{
try
{
MyGridViewStyle.SaveGridViewState(this.dgrdView1, "ReOrderASN");
}
catch
{
}
}
}
}