天津投入产出系统后端
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.
 
 
 
 
 
 

175 lines
6.7 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace QMAPP.WinForm.Forms.TianJin
{
public partial class TJResetSendIndexForm : Form
{ //最后的发车时间
DateTime updateTime;
//发车单号
string pasteCardIndex;
DataTable dt;
public TJResetSendIndexForm()
{
InitializeComponent();
}
private void btnSave_Click(object sender, EventArgs e)
{
string selectPlantCode = comboBox1.Text.ToString();
int sendIndex = Convert.ToInt32(numericUpDown1.Value);
if (sendIndex > 10000)
{
MessageBox.Show("当前发车数量不能大于9999!");
numericUpDown1.Focus();
return;
}
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
DataTable dt = agent.InvokeServiceFunction<DataTable>(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetPastecardIndex.ToString(), selectPlantCode, selectPlantCode + DateTime.Now.ToString("yyyyMMdd"));
if (dt.Rows.Count > 0)
{
foreach (DataRow dr in dt.Rows)
{
// string plantCodeInRow = dr["PLANTCODE"].ToString();
// if (selectPlantCode == plantCodeInRow)
// {
pasteCardIndex = dr["PASTECARDNO"].ToString();
updateTime = Convert.ToDateTime(dr["PASTECARDDATE"]);
// }
}
if (Convert.ToDateTime(updateTime.ToString("yyyy-MM-dd")) > Convert.ToDateTime(label2.Text))
{
label2.Text = System.DateTime.Now.ToString("yyyy-MM-dd");
numericUpDown1.Value = Convert.ToInt32(pasteCardIndex.Substring(pasteCardIndex.Length - 4, 4));
MessageBox.Show("请重新修改当前发车数量!");
numericUpDown1.Focus();
return;
}
if (Convert.ToDateTime(updateTime.ToString("yyyy-MM-dd")) == Convert.ToDateTime(label2.Text) && sendIndex < Convert.ToInt32(pasteCardIndex.Substring(pasteCardIndex.Length - 4, 4)))
{
numericUpDown1.Value = Convert.ToInt32(pasteCardIndex.Substring(pasteCardIndex.Length - 4, 4));
MessageBox.Show("请重新修改当前发车数量!");
numericUpDown1.Focus();
return;
}
// pasteCardIndex = pasteCardIndex.Substring(0, 2) + label2.Text.Replace("-", "") + numericUpDown1.Value.ToString().PadLeft(4, '0');
pasteCardIndex = label2.Text.Replace("-", "") + numericUpDown1.Value.ToString().PadLeft(4, '0');
int result = agent.InvokeServiceFunction<int>(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_UpdatePastecardIndex.ToString(), selectPlantCode+pasteCardIndex, selectPlantCode);
this.Close();
}
else
{
string strnum=sendIndex.ToString().PadLeft(4,'0');
pasteCardIndex = System.DateTime.Now.ToString("yyyyMMdd") + strnum;
int result2 = agent.InvokeServiceFunction<int>(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_UpdatePastecardIndex.ToString(), selectPlantCode + pasteCardIndex, selectPlantCode);
this.Close();
}
}
private void ResetSendIndexForm_Load(object sender, EventArgs e)
{
//string pFisType = QM.Config.CustomConfig.GetItem("FlashProCode");
string pFisType = QMAPP.WinForm.Common.LocalSetting.Settings["PlantNameConfig"];
label2.Text = System.DateTime.Now.ToString("yyyy-MM-dd");
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
dt = agent.InvokeServiceFunction<DataTable>(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetPastecardIndex.ToString(), "", "");
this.comboBox1.DataSource = dt;
this.comboBox1.DisplayMember = "PLANTNAME";
this.comboBox1.ValueMember = "PLANTNAME";
comboBox1.SelectedValue = pFisType;
int i = 0;
foreach (DataRow dr in dt.Rows)
{
if (i >= 1)
{
break;
}
string plantNo = dr["PLANTCODE"].ToString();
pasteCardIndex = dr["PASTECARDNO"].ToString();
updateTime = Convert.ToDateTime(dr["PASTECARDDATE"]);
i++;
}
if (updateTime.ToString("yyyy-MM-dd") != label2.Text)
{
numericUpDown1.Value = 0;
}
else
{
numericUpDown1.Value = Convert.ToInt32(pasteCardIndex.Substring(pasteCardIndex.Length - 4, 4));
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.Text != "System.Data.DataRowView")
{
string selectPlantCode = comboBox1.Text;
// string selectPlantCode = comboBox1.SelectedValue.ToString();
//foreach (DataRow dr in dt.Rows)
//{
// string plantCodeInRow = dr["PLANTCODE"].ToString();
// if (selectPlantCode == plantCodeInRow)
// {
// string cardIndex = dr["PASTECARDNO"].ToString();
// DateTime updateTimeRow = Convert.ToDateTime(dr["PASTECARDDATE"]);
// if (updateTimeRow.ToString("yyyy-MM-dd") != label2.Text)
// {
// numericUpDown1.Value = 0;
// }
// else
// {
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
dt = agent.InvokeServiceFunction<DataTable>(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetPastecardIndex.ToString(), selectPlantCode, selectPlantCode + DateTime.Now.ToString("yyyyMMdd"));
// numericUpDown1.Value = Convert.ToInt32(cardIndex.Substring(cardIndex.Length-4, 4));
if (dt.Rows.Count > 0)
{
numericUpDown1.Value = Convert.ToInt32(dt.Rows[0]["PASTECARDNO"].ToString().Substring(dt.Rows[0]["PASTECARDNO"].ToString().Length - 4, 4));
}
else
{
numericUpDown1.Value = 0;
}
// }
}
//}
}
}
}