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.
289 lines
12 KiB
289 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 DevExpress.XtraEditors;
|
|
using ICSSoft.Base.Language.Tool;
|
|
using ICSSoft.Base.UserControl.MessageControl;
|
|
using System.Data.SqlClient;
|
|
using ICSSoft.Base.Config.AppConfig;
|
|
using ICSSoft.Base.Report.Filter;
|
|
using ICSSoft.Base.Config.DBHelper;
|
|
using ICSSoft.Base.UserControl.FormControl;
|
|
using ICSSoft.Base.ReferForm.AppReferForm;
|
|
using ICSSoft.Frame.Data.BLL;
|
|
using ICSSoft.Frame.Data.Entity;
|
|
|
|
namespace ICSSoft.Frame.APP
|
|
{
|
|
public partial class FormICSINLoadAdd : DevExpress.XtraEditors.XtraForm
|
|
{
|
|
#region 构造函数
|
|
public FormICSINLoadAdd()
|
|
{
|
|
InitializeComponent();
|
|
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
|
|
this.WindowState = FormWindowState.Maximized;
|
|
}
|
|
#endregion
|
|
|
|
#region 移动窗体
|
|
private const int WM_NCHITTEST = 0x84;
|
|
private const int HTCLIENT = 0x1;
|
|
private const int HTCAPTION = 0x2;
|
|
//首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
|
|
//系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
|
|
//假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
|
|
//同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
|
|
|
|
//重写窗体,使窗体可以不通过自带标题栏实现移动
|
|
protected override void WndProc(ref Message m)
|
|
{
|
|
//当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
|
|
//当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
|
|
//这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
|
|
//注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
|
|
switch (m.Msg)
|
|
{
|
|
case WM_NCHITTEST:
|
|
base.WndProc(ref m);
|
|
if ((int)m.Result == HTCLIENT)
|
|
m.Result = (IntPtr)HTCAPTION;
|
|
return;
|
|
}
|
|
//拦截双击标题栏、移动窗体的系统消息
|
|
if (m.Msg != 0xA3)
|
|
{
|
|
base.WndProc(ref m);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 退出
|
|
private void btnClose_Click(object sender, EventArgs e)
|
|
{
|
|
AppConfig.CloseFormShow(this.Text);
|
|
this.Close();
|
|
}
|
|
|
|
private void btnExit_Click(object sender, EventArgs e)
|
|
{
|
|
AppConfig.CloseFormShow(this.Text);
|
|
this.Close();
|
|
}
|
|
#endregion
|
|
|
|
#region 全选
|
|
private void btnSelect_Click(object sender, EventArgs e)
|
|
{
|
|
for (int i = 0; i < grvDetail.RowCount; i++)
|
|
{
|
|
grvDetail.SetRowCellValue(i, colisSelect, "Y");
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 全消
|
|
private void btnCanSelect_Click(object sender, EventArgs e)
|
|
{
|
|
for (int i = 0; i < grvDetail.RowCount; i++)
|
|
{
|
|
grvDetail.SetRowCellValue(i, colisSelect, "");
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 双击选择
|
|
private void grvDetail_DoubleClick(object sender, EventArgs e)
|
|
{
|
|
if (grvDetail.FocusedRowHandle < 0)
|
|
{
|
|
return;
|
|
}
|
|
if (grvDetail.FocusedColumn == colisSelect)
|
|
{
|
|
if (grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colisSelect).ToString() == "")
|
|
{
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "Y");
|
|
}
|
|
else
|
|
{
|
|
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "");
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
private void FormICSINLoadAdd_Load(object sender, EventArgs e)
|
|
{
|
|
init();
|
|
}
|
|
|
|
public void init()
|
|
{
|
|
string sql = @"SELECT DISTINCT VenBatch FROM ICSITEMLot WHERE WorkPoint = '{0}' AND TYPE = '到货' ORDER BY VenBatch";
|
|
sql = string.Format(sql, AppConfig.WorkPointCode);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
|
|
if (dt.Rows.Count > 0 && dt != null)
|
|
{
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
if (!txtVenBatch.Items.Contains(dr["VenBatch"].ToString().Trim()))
|
|
{
|
|
txtVenBatch.Items.Add(dr["VenBatch"].ToString().Trim());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void txtVenBatch_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (txtVenBatch.Text.Trim() == "")
|
|
{
|
|
return;
|
|
}
|
|
string sql = @"SELECT '' isSelect, A.LotNO, A.VenderLotNO, A.ItemCode, B.INVNAME, B.INVSTD
|
|
FROM ICSITEMLot A LEFT JOIN ICSINVENTORY B ON A.ItemCode = B.INVCODE
|
|
WHERE 1=1 AND A.VenBatch = '{0}' AND A.WorkPoint = '{1}' AND A.TYPE = '到货' ORDER BY A.VenderLotNO DESC ";
|
|
sql = string.Format(sql, txtVenBatch.Text.Trim(), AppConfig.WorkPointCode);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
|
|
grdDetail.DataSource = dt;
|
|
grvDetail.BestFitColumns();
|
|
}
|
|
|
|
private void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
int count = 0;
|
|
for (int i = 0; i < grvDetail.RowCount; i++)
|
|
{
|
|
if (grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colisSelect).ToString() == "Y")
|
|
{
|
|
count++;
|
|
}
|
|
}
|
|
if (count == 0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("请选择数据");
|
|
return;
|
|
}
|
|
string INCode = "";
|
|
string sql = @"SELECT TOP 1 A.INCode FROM ICSINFile A WHERE 1=1 AND A.WorkPoint = '{0}' ORDER BY A.INCode DESC ";
|
|
sql = string.Format(sql, AppConfig.WorkPointCode);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
|
|
if (dt.Rows.Count > 0 && dt != null)
|
|
{
|
|
INCode = dt.Rows[0]["INCode"].ToString().Substring(0, 4) + (Convert.ToInt32(dt.Rows[0]["INCode"].ToString().Substring(4, 4)) + 1).ToString().PadLeft(4, '0');
|
|
}
|
|
else
|
|
{
|
|
INCode = "LLWJ0001";
|
|
}
|
|
#region 原逻辑
|
|
//List<string> VenderLotNOs = new List<string>();
|
|
//List<string> LotNOs = new List<string>();
|
|
//for (int i = 0; i < grvDetail.RowCount; i++)
|
|
//{
|
|
// if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
|
|
// {
|
|
// if (!VenderLotNOs.Contains(grvDetail.GetRowCellValue(i, colVenderLotNO).ToString()))
|
|
// {
|
|
// VenderLotNOs.Add(grvDetail.GetRowCellValue(i, colVenderLotNO).ToString());
|
|
// }
|
|
// }
|
|
//}
|
|
//foreach (string VenderLotNO in VenderLotNOs)
|
|
//{
|
|
// string LotNO = "";
|
|
// for (int i = 0; i < grvDetail.RowCount; i++)
|
|
// {
|
|
// if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
|
|
// {
|
|
// if (VenderLotNO == grvDetail.GetRowCellValue(i, colVenderLotNO).ToString())
|
|
// {
|
|
// if (LotNO == "")
|
|
// {
|
|
// LotNO = grvDetail.GetRowCellValue(i, colLotNO).ToString();
|
|
// }
|
|
// else
|
|
// {
|
|
// LotNO = LotNO + ";" + grvDetail.GetRowCellValue(i, colLotNO).ToString();
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// LotNOs.Add(LotNO);
|
|
//}
|
|
//try
|
|
//{
|
|
// List<ICSINFile> datas = new List<ICSINFile>();
|
|
// for (int i = 0; i < VenderLotNOs.Count; i++)
|
|
// {
|
|
// ICSINFile data = new ICSINFile();
|
|
// data.ID = AppConfig.GetGuid().ToString();
|
|
// data.INCode = INCode.Substring(0, 4) + (Convert.ToInt32(INCode.Substring(4, 4)) + i).ToString().PadLeft(4, '0');
|
|
// data.VenBatch = txtVenBatch.Text;
|
|
// data.VenderLotNO = VenderLotNOs[i].ToString();
|
|
// data.LotNOs = LotNOs[i].ToString();
|
|
// data.WorkPoint = AppConfig.WorkPointCode;
|
|
// data.MUSER = AppConfig.UserCode;
|
|
// data.MUSERName = AppConfig.UserName;
|
|
// data.MTIME = DateTime.Now;
|
|
// datas.Add(data);
|
|
// }
|
|
// ICSHeatTreatmentBLL.AddINList(datas, AppConfig.AppConnectString);
|
|
// ICSBaseSimpleCode.AppshowMessageBox("保存成功");
|
|
// this.Close();
|
|
//}
|
|
//catch (Exception ex)
|
|
//{
|
|
// ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
//}
|
|
#endregion
|
|
#region 现逻辑
|
|
try
|
|
{
|
|
List<ICSINFile> datas = new List<ICSINFile>();
|
|
string VenderLotNO = "";
|
|
string LotNOs = "";
|
|
for (int i = 0; i < grvDetail.RowCount; i++)
|
|
{
|
|
if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
|
|
{
|
|
if (VenderLotNO == "")
|
|
{
|
|
VenderLotNO = grvDetail.GetRowCellValue(i, colVenderLotNO).ToString();
|
|
LotNOs = grvDetail.GetRowCellValue(i, colLotNO).ToString();
|
|
}
|
|
else
|
|
{
|
|
VenderLotNO += "; " + grvDetail.GetRowCellValue(i, colVenderLotNO).ToString();
|
|
LotNOs += "; " + grvDetail.GetRowCellValue(i, colLotNO).ToString();
|
|
}
|
|
}
|
|
}
|
|
ICSINFile data = new ICSINFile();
|
|
data.ID = AppConfig.GetGuid().ToString();
|
|
data.INCode = INCode;
|
|
data.VenBatch = txtVenBatch.Text;
|
|
data.VenderLotNO = VenderLotNO;
|
|
data.LotNOs = LotNOs;
|
|
data.WorkPoint = AppConfig.WorkPointCode;
|
|
data.MUSER = AppConfig.UserCode;
|
|
data.MUSERName = AppConfig.UserName;
|
|
data.MTIME = DateTime.Now;
|
|
datas.Add(data);
|
|
ICSHeatTreatmentBLL.AddINList(datas, AppConfig.AppConnectString);
|
|
ICSBaseSimpleCode.AppshowMessageBox("保存成功");
|
|
this.Close();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
}
|