锐腾搅拌上料功能
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.

920 lines
40 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Linq;
using System.Linq;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Views.BandedGrid;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid;
using System.IO;
using System.Threading;
using ICSSoft.Base.Language.Tool;
using ICSSoft.Base.Config.AppConfig;
using ICSSoft.Base.UserControl.MessageControl;
using ICSSoft.Base.Config.DBHelper;
using ICSSoft.Base.Report.Filter;
using ICSSoft.Base.UserControl.FormControl;
using ICSSoft.Base.Report.GridReport;
using ICSSoft.Base.ReferForm.AppReferForm;
using ICSSoft.Frame.Data.BLL;
using ICSSoft.Frame.Data.Entity;
namespace ICSSoft.Frame.APP
{
public partial class FormICSWareHouseLotInfoLog : DevExpress.XtraEditors.XtraForm
{
private string sqltxt = "";
private string sqlconn = "";
String guid = AppConfig.GetGuid();
private DataTable dataSource = null;
string receiptno = "";
int receiptline;
#region 构造函数
public FormICSWareHouseLotInfoLog()
{
InitializeComponent();
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
this.WindowState = FormWindowState.Maximized;
}
#endregion
#region 操作权限
public DataTable RightOfExute()
{
DataTable rData = new DataTable();
rData.Columns.Add("BtnName");
rData.Columns.Add("ActionName");
//查看权限(必须有)
DataRow seeRow = rData.NewRow();
seeRow["BtnName"] = "see";
seeRow["ActionName"] = "查看";
rData.Rows.Add(seeRow);
List<Control> ControlList = new List<Control>();
ControlList.Add(btnStorage);
foreach (Control ctr in ControlList)
{
if (ctr.GetType() == typeof(SimpleButton))
{
DataRow dr = rData.NewRow();
dr["BtnName"] = ctr.Name;
dr["ActionName"] = ctr.Text;
rData.Rows.Add(dr);
}
}
rData.AcceptChanges();
return rData;
}
public DataTable RightOfData()// 数据权限
{
DataTable rData = new DataTable();
rData.Columns.Add("BodyName");
rData.Columns.Add("ControlName");
rData.Columns.Add("ControlCaption");
rData.AcceptChanges();
return rData;
}
#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 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 grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
{
if (e.Info.IsRowIndicator && e.RowHandle >= 0)
e.Info.DisplayText = (e.RowHandle + 1).ToString();
}
#endregion
#region 过滤
private string tempTableName = "";
private void btnFilter_Click(object sender, EventArgs e)
{
FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name));
filter.OldTempTableName = tempTableName;
if (filter.ShowDialog() == DialogResult.OK)
{
DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
try
{
_wait.Show();
tempTableName = filter.NewTempTableName;
sqltxt = filter.SqlText;
sqlconn = filter.FilterConnectString;
dataSource = filter.FilterData.Tables[0];
grdDetail.DataSource = dataSource;
grvDetail.BestFitColumns();
rptPage.RecordNum = dataSource.Rows.Count;
rptPage.PageSize = 499;
rptPage.PageIndex = 1;
rptPage.ReLoad();
rptPage.PageSize = 500;
rptPage.PageIndex = 1;
rptPage.ReLoad();
_wait.Close();
}
catch (Exception ex)
{
MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
_wait.Close();
}
}
}
#endregion
#region 绑定数据源
private void btnConfig_Click(object sender, EventArgs e)
{
if (AppConfig.UserCode.ToLower() != "demo")
{
ICSBaseSimpleCode.AppshowMessageBox("您没有权限设置数据源,请联系软件提供商!");
return;
}
FormDataSource fdata = new FormDataSource(AppConfig.GetMenuId(this.Tag.ToString()), btnConfig.Name);
fdata.ShowDialog();
}
#endregion
#region 分页
private void rptPage_PageIndexChanged(object Sender, EventArgs e)
{
DataTable data = AppConfig.GetPageData(dataSource, rptPage.PageIndex, rptPage.PageSize).Copy();
//DataTable data = AppConfig.GetPageDataByDb(tempTableName, "pagerowindex", rptPage.PageSize, rptPage.PageIndex, dataSource.Rows.Count);
grdDetail.DataSource = data;
}
#endregion
#region 过滤方法
private void FormContainerManager_FormClosing(object sender, FormClosingEventArgs e)
{
AppConfig.DropTemTable(tempTableName);
}
#endregion
#region 全选
private void btnSelectAll_Click(object sender, EventArgs e)
{
grvDetail.PostEditor();
this.Validate();
for (int i = 0; i < grvDetail.RowCount; i++)
{
grvDetail.SetRowCellValue(i, colisSelect, "Y");
}
}
#endregion
#region 全消
private void btnCancelAll_Click(object sender, EventArgs e)
{
grvDetail.PostEditor();
this.Validate();
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
#region 导出
private void btnOutPut_Click(object sender, EventArgs e)
{
FormOutExcel foe = new FormOutExcel(this.Tag.ToString(), grdDetail);
foe.ShowDialog();
}
#endregion
#region 刷新
private void btnRefresh_Click(object sender, EventArgs e)
{
DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
try
{
_wait.Show();
FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name), false);
filter.OldTempTableName = tempTableName;
//tempTableName = filter.NewTempTableName;
//DataTable data = DBHelper.ExecuteDataset(AppConfig.FrameConnectString, CommandType.Text, "select * from " + tempTableName).Tables[0];
dataSource = DBHelper.ExecuteDataset(sqlconn, CommandType.Text, sqltxt).Tables[0];
grdDetail.DataSource = dataSource;
grvDetail.BestFitColumns();
rptPage.RecordNum = dataSource.Rows.Count;
rptPage.PageIndex = 1;
rptPage.ReLoad();
_wait.Close();
}
catch (Exception ex)
{
MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
_wait.Close();
}
}
#endregion
#region 新增
private void btnCreate_Click(object sender, EventArgs e)
{
SimpleButton btntemp = (SimpleButton)sender;
if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
{
ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
return;
}
FormDCTAdd add = new FormDCTAdd();
add.ShowDialog();
btnRefresh_Click(null, null);
}
#endregion
private void grvDetail_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
{
if (e.RowHandle >= 0 && e.Column.FieldName == "DCTCODE")
{
//e.DisplayText = FormatHelper.
e.CellValue = "cccc";
}
}
private void FormDCT_Load(object sender, EventArgs e)
{
btnFilter_Click(sender, e);
}
#region 退出
private void btnExit_Click_1(object sender, EventArgs e)
{
AppConfig.CloseFormShow(this.Text);
this.Close();
}
#endregion
#region 库位按钮
private void repositoryItemButtonEdit1_BottonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
string storageid = "";
if (grvDetail.FocusedColumn == colStackCode)
{
DataTable dt1 = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectStorageID(grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colStorageCode).ToString());
if (dt1 != null && dt1.Rows.Count > 0)
{
storageid = dt1.Rows[0][0].ToString();
}
}
DataTable dt = ICSWareHouseLotInfoLogBLL.SearchStackInfoList(storageid, AppConfig.AppConnectString);
FormDataRefer reForm = new FormDataRefer();
reForm.FormTitle = "库位";
reForm.DataSource = dt;
reForm.MSelectFlag = false;
reForm.RowIndexWidth = 35;
reForm.HideCols.Add("guid");
reForm.FormWidth = 500;
reForm.FormHeight = 500;
if (reForm.ShowDialog() == DialogResult.OK)
{
DataTable retData = reForm.ReturnData;
foreach (DataRow dr in retData.Rows)
{
FormICSStackUIModel Item = new FormICSStackUIModel();
//Item.Serial = dr["guid"].ToString();
Item.StackCode = dr["库位代码"].ToString();
Item.StackName = dr["库位名称"].ToString();
if (grvDetail.FocusedRowHandle < 0)
{
return;
}
if (grvDetail.FocusedColumn == colStackCode)
{
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colStackCode, Item.StackCode);
}
}
}
}
#endregion
#region 物料追溯信息按钮
private void repositoryItemButtonEdit2_BottonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
string receiptno = "";
int receiptline;
if (grvDetail.FocusedColumn == colITEMLot)
{
receiptno = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colReceiptNO).ToString();
receiptline = Convert.ToInt32(grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colReceiptLine));
FormICSITEMLOTAdd linkDetail = new FormICSITEMLOTAdd(receiptno, receiptline);
linkDetail.ShowDialog();
}
}
#endregion
#region 物料入库按钮
private void btnStorage_Click(object sender, EventArgs e)
{
int count = 0;
for (int j = 0; j < grvDetail.RowCount; j++)
{
if (grvDetail.GetRowCellValue(j, colisSelect).ToString() == "Y")
{
count++;
}
}
if (count != 1)
{
ICSBaseSimpleCode.AppshowMessageBox("请选择数据,且只能选择一条进行入库!!!");
return;
}
int i = grvDetail.FocusedRowHandle;
if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
{
receiptno = grvDetail.GetRowCellValue(i, colReceiptNO).ToString();
receiptline = Convert.ToInt32(grvDetail.GetRowCellValue(i, colReceiptLine));
#region 判断
//物料的检验结果必须为合格:TBLINVReceiptDetail.IQCStatus=Qualified
if (grvDetail.GetRowCellValue(i, colIQCStatus).ToString() != "合格")
{
ICSBaseSimpleCode.AppshowMessageBox("对不起,您选择的物料检验未合格不能入库!");
return;
}
//检查入库数量不能为零
if (Convert.ToInt32(grvDetail.GetRowCellValue(i, colACTQTY)) == 0)
{
ICSBaseSimpleCode.AppshowMessageBox("入库数量为零,不能入库!");
return;
}
//检查库别和库位必须输入
if (string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colStorageCode).ToString()) || string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colStackCode).ToString()))
{
ICSBaseSimpleCode.AppshowMessageBox("库别或库位不能为空");
return;
}
//如果入库数量<>收货数量,提示用户
if (!string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colACTQTY).ToString()) && !string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colRECEIVEQTY).ToString()))
{
if (Convert.ToDecimal(grvDetail.GetRowCellValue(i, colACTQTY)) != Convert.ToDecimal(grvDetail.GetRowCellValue(i, colRECEIVEQTY)))
{
if (ICSBaseSimpleCode.AppshowMessageBoxRepose("入库数量不等于收货数量,确认继续入库吗?") != DialogResult.OK)
return;
}
}
//如果物料是批管控料或单件管控料:(tblmaterial. MCONTROLTYPE)
//检查TBLITEMLot. TransNO=@入库单号and TransLine=@入库单行的数量sum(TBLITEMLot.LOTQTY)是否等于入库数量,不等于则提示:请维护该物料的批号或单件号。
if (!string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colACTQTY).ToString()) && !string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colRECEIVEQTY).ToString()) && !string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colQualifyQTY).ToString()))
{
if ((Convert.ToDecimal(grvDetail.GetRowCellValue(i, colACTQTY)) != Convert.ToDecimal(grvDetail.GetRowCellValue(i, colRECEIVEQTY))) && (Convert.ToDecimal(grvDetail.GetRowCellValue(i, colACTQTY)) != Convert.ToDecimal(grvDetail.GetRowCellValue(i, colQualifyQTY))))
{
if (ICSBaseSimpleCode.AppshowMessageBoxRepose("入库数量与收货数量、合格数量不相等,确认继续入库吗?") != DialogResult.OK)
return;
}
}
#endregion
try
{
#region 存入库存信息表
if (grvDetail.GetRowCellValue(i, colINVCONTROLTYPE).ToString() == "批次管控" ||
grvDetail.GetRowCellValue(i, colINVCONTROLTYPE).ToString() == "单件管控" ||
grvDetail.GetRowCellValue(i, colINVCONTROLTYPE).ToString() == "不管控")
{
ICSWareHouseInfo lotinfo = new ICSWareHouseInfo();
DataTable dt1 = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectStorageID(grvDetail.GetRowCellValue(i, colStorageCode).ToString());
if (dt1 != null && dt1.Rows.Count > 0)
{
lotinfo.WHGUID = dt1.Rows[0][0].ToString();
}
lotinfo.WHCode = grvDetail.GetRowCellValue(i, colStorageCode).ToString();
DataTable dt2 = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectStsckID(grvDetail.GetRowCellValue(i, colStackCode).ToString());
if (dt2 != null && dt2.Rows.Count > 0)
{
lotinfo.BinGUID = dt2.Rows[0][0].ToString();
}
lotinfo.BinCode = grvDetail.GetRowCellValue(i, colStackCode).ToString();
DataTable dt3 = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectItemID(grvDetail.GetRowCellValue(i, colITEMCODE).ToString());
if (dt3 != null && dt3.Rows.Count > 0)
{
lotinfo.INVGUID = dt3.Rows[0][0].ToString();
}
lotinfo.INVCode = grvDetail.GetRowCellValue(i, colITEMCODE).ToString();
DataTable dt4 = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectQTY(lotinfo.WHGUID, lotinfo.BinGUID, lotinfo.INVGUID);
if (dt4 == null || dt4.Rows.Count == 0)
{
if (!string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colACTQTY).ToString()))
{
lotinfo.QTY = Convert.ToDecimal(grvDetail.GetRowCellValue(i, colACTQTY));
}
}
if (dt4 != null && dt4.Rows.Count > 0)
{
if (!string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colACTQTY).ToString()) && !string.IsNullOrEmpty(dt4.Rows[0]["QTY"].ToString()))
{
lotinfo.QTY = Convert.ToDecimal(dt4.Rows[0]["QTY"]) + Convert.ToDecimal(grvDetail.GetRowCellValue(i, colACTQTY));
}
}
lotinfo.WorkPoint = AppConfig.WorkPointCode;
lotinfo.MUSER = AppConfig.UserId;
lotinfo.MUSERName = AppConfig.UserName;
lotinfo.MTIME = DateTime.Now;
lotinfo.EATTRIBUTE1 = null;
ICSWareHouseLotInfoLogBLL.WareHouseInfo(lotinfo, AppConfig.AppConnectString);
}
#endregion
#region 存入物料,产品批次的库存信息
if (grvDetail.GetRowCellValue(i, colINVCONTROLTYPE).ToString() == "批次管控" || grvDetail.GetRowCellValue(i, colINVCONTROLTYPE).ToString() == "单件管控")
{
FormICSWareHouseLotInfoUIModel lotinfo2 = new FormICSWareHouseLotInfoUIModel();
if (!string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colReceiptLine).ToString()))
{
DataTable ddt = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectLotNO(grvDetail.GetRowCellValue(i, colReceiptNO).ToString(), Convert.ToInt32(grvDetail.GetRowCellValue(i, colReceiptLine)));
if (ddt != null && ddt.Rows.Count > 0)
{
for (int j = 0; j < ddt.Rows.Count; j++)
{
lotinfo2.ID = AppConfig.GetGuid();
lotinfo2.LotNO = ddt.Rows[j][0].ToString();
DataTable ddt1 = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectStorageID(grvDetail.GetRowCellValue(i, colStorageCode).ToString());
if (ddt1 != null && ddt1.Rows.Count > 0)
{
lotinfo2.WHGUID = ddt1.Rows[0][0].ToString();
}
lotinfo2.WHCode = grvDetail.GetRowCellValue(i, colStorageCode).ToString();
DataTable ddt2 = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectStsckID(grvDetail.GetRowCellValue(i, colStackCode).ToString());
if (ddt2 != null && ddt2.Rows.Count > 0)
{
lotinfo2.BinGUID = ddt2.Rows[0][0].ToString();
}
lotinfo2.BinCode = grvDetail.GetRowCellValue(i, colStackCode).ToString();
DataTable ddt3 = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectItemID(grvDetail.GetRowCellValue(i, colITEMCODE).ToString());
if (ddt3 != null && ddt3.Rows.Count > 0)
{
lotinfo2.INVGUID = ddt3.Rows[0][0].ToString();
}
lotinfo2.INVCode = grvDetail.GetRowCellValue(i, colITEMCODE).ToString();
DataTable ddt4 = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectLOTQTY(lotinfo2.LotNO);
if (ddt4 != null && ddt4.Rows.Count > 0)
{
if (!string.IsNullOrEmpty(ddt4.Rows[0][0].ToString()))
{
lotinfo2.LotQty = Convert.ToDecimal(ddt4.Rows[0][0]);
}
}
lotinfo2.ReceiveDate = DateTime.Now;
lotinfo2.WorkPoint = AppConfig.WorkPointCode;
lotinfo2.MUSER = AppConfig.UserId;
lotinfo2.MUSERName = AppConfig.UserName;
lotinfo2.MTIME = DateTime.Now;
lotinfo2.EATTRIBUTE1 = null;
ICSWareHouseLotInfoLogBLL.towh(lotinfo2, AppConfig.AppConnectString);
}
}
}
}
#endregion
#region 存入物料收发交易记录表
if (grvDetail.GetRowCellValue(i, colINVCONTROLTYPE).ToString() == "批次管控" ||
grvDetail.GetRowCellValue(i, colINVCONTROLTYPE).ToString() == "单件管控" ||
grvDetail.GetRowCellValue(i, colINVCONTROLTYPE).ToString() == "不管控")
{
ICSITEMTrans lotinfo3 = new ICSITEMTrans();
lotinfo3.ID = AppConfig.GetGuid();
lotinfo3.TransNO = grvDetail.GetRowCellValue(i, colReceiptNO).ToString();
if (!string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colReceiptLine).ToString()))
{
lotinfo3.TransLine = Convert.ToInt32(grvDetail.GetRowCellValue(i, colReceiptLine));
}
lotinfo3.ITEMCODE = grvDetail.GetRowCellValue(i, colITEMCODE).ToString();
lotinfo3.FRMStorageCODE = "";
lotinfo3.FRMStackCODE = "";
lotinfo3.TOStorageCODE = grvDetail.GetRowCellValue(i, colStorageCode).ToString();
lotinfo3.TOStackCODE = grvDetail.GetRowCellValue(i, colStackCode).ToString();
if (!string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colACTQTY).ToString()))
{
lotinfo3.TransQTY = Convert.ToDecimal(grvDetail.GetRowCellValue(i, colACTQTY));
}
lotinfo3.Memo = grvDetail.GetRowCellValue(i, colMEMO).ToString();
lotinfo3.TransType = "收";
lotinfo3.BusinessCode = "";
lotinfo3.WorkPoint = AppConfig.WorkPointCode;
lotinfo3.MUSER = AppConfig.UserId;
lotinfo3.MUSERName = AppConfig.UserName;
lotinfo3.MTIME = DateTime.Now;
lotinfo3.EATTRIBUTE1 = null;
ICSWareHouseLotInfoLogBLL.trans(lotinfo3, AppConfig.AppConnectString);
}
#endregion
#region 存入物料收发交易批号记录表
if (grvDetail.GetRowCellValue(i, colINVCONTROLTYPE).ToString() == "批次管控" ||
grvDetail.GetRowCellValue(i, colINVCONTROLTYPE).ToString() == "单件管控")
{
ICSITEMTransLot lotinfo4 = new ICSITEMTransLot();
if (!string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colReceiptLine).ToString()))
{
DataTable ddt = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectLotNO(grvDetail.GetRowCellValue(i, colReceiptNO).ToString(), Convert.ToInt32(grvDetail.GetRowCellValue(i, colReceiptLine)));
if (ddt != null && ddt.Rows.Count > 0)
{
for (int j = 0; j < ddt.Rows.Count; j++)
{
lotinfo4.ID = AppConfig.GetGuid();
DataTable ddt1 = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectTransID(grvDetail.GetRowCellValue(i, colReceiptNO).ToString(), Convert.ToInt32(grvDetail.GetRowCellValue(i, colReceiptLine)));
if (ddt1 != null && ddt1.Rows.Count > 0)
{
lotinfo4.ITEMTransID = ddt1.Rows[0][0].ToString();
}
lotinfo4.LotNO = ddt.Rows[j][0].ToString();
lotinfo4.ITEMCODE = grvDetail.GetRowCellValue(i, colITEMCODE).ToString();
DataTable ddt4 = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectLOTQTY(lotinfo4.LotNO);
if (ddt4 != null && ddt4.Rows.Count > 0)
{
if (!string.IsNullOrEmpty(ddt4.Rows[0][0].ToString()))
{
lotinfo4.TransQTY = Convert.ToDecimal(ddt4.Rows[0][0]);
}
}
lotinfo4.Memo = grvDetail.GetRowCellValue(i, colMEMO).ToString();
lotinfo4.WorkPoint = AppConfig.WorkPointCode;
lotinfo4.MUSER = AppConfig.UserId;
lotinfo4.MUSERName = AppConfig.UserName;
lotinfo4.MTIME = DateTime.Now;
ICSWareHouseLotInfoLogBLL.transLOT(lotinfo4, AppConfig.AppConnectString);
}
}
}
}
#endregion
#region 存入物料收发交易详细记录表
ICSITEMTransLotDetail lotinfo5 = new ICSITEMTransLotDetail();
if (grvDetail.GetRowCellValue(i, colINVCONTROLTYPE).ToString() == "单件管控")
{
if (!string.IsNullOrEmpty(grvDetail.GetRowCellValue(i, colReceiptLine).ToString()))
{
DataTable ddt = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectLotNO(grvDetail.GetRowCellValue(i, colReceiptNO).ToString(), Convert.ToInt32(grvDetail.GetRowCellValue(i, colReceiptLine)));
if (ddt != null && ddt.Rows.Count > 0)
{
for (int j = 0; j < ddt.Rows.Count; j++)
{
DataTable ddt1 = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectSeriaNO(ddt.Rows[j][0].ToString());
if (ddt1 != null && ddt1.Rows.Count > 0)
{
for (int m = 0; m < ddt1.Rows.Count; m++)
{
lotinfo5.ID = AppConfig.GetGuid();
DataTable ddt2 = ICSSoft.Frame.Data.BLL.ICSWareHouseLotInfoLogBLL.SelectTransLotID(ddt.Rows[j][0].ToString());
if (ddt2 != null && ddt2.Rows.Count > 0)
{
lotinfo5.ITEMTransLotID = ddt2.Rows[0][0].ToString();
}
lotinfo5.LotNO = ddt.Rows[j][0].ToString();
lotinfo5.ITEMCODE = grvDetail.GetRowCellValue(i, colITEMCODE).ToString();
lotinfo5.SERIALNO = ddt1.Rows[m][0].ToString();
lotinfo5.WorkPoint = AppConfig.WorkPointCode;
lotinfo5.MUSER = AppConfig.UserId;
lotinfo5.MUSERName = AppConfig.UserName;
lotinfo5.MTIME = DateTime.Now;
lotinfo5.EATTRIBUTE1 = null;
ICSWareHouseLotInfoLogBLL.transLOTDetail(lotinfo5, AppConfig.AppConnectString);
#region 更新物料产品详细信息产品状态
ICSITEMLotDetail itemlotdetail = ICSWareHouseLotInfoLogBLL.selectitemlotdetail(lotinfo5.SERIALNO, lotinfo5.ITEMCODE, AppConfig.AppConnectString);
ICSWareHouseLotInfoLogBLL.updateSerialStatus(lotinfo5.SERIALNO, lotinfo5.ITEMCODE);
try
{
ICSWareHouseLotInfoLogBLL.iqcdetail(itemlotdetail, AppConfig.AppConnectString);
}
catch (Exception ex)
{
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
}
#endregion
}
}
}
}
}
}
#endregion
//CloseStatus(receiptno, receiptline);
ICSWareHouseLotInfoLogBLL.updatestatus(receiptno, receiptline);
ICSBaseSimpleCode.AppshowMessageBox("操作成功");
btnRefresh_Click(null, null);
}
catch (Exception ex)
{
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
}
}
}
#endregion
#region
// private void CloseStatus(string stno, int stline)
// {
// #region 更新送检单子表的行状态
// ICSASNIQCDETAIL iqcdetail = ICSWareHouseLotInfoLogBLL.selectIQCDetail(stno, stline, AppConfig.AppConnectString);
// ICSWareHouseLotInfoLogBLL.updateSTDSTATUS(stno, stline);
// try
// {
// ICSWareHouseLotInfoLogBLL.iqcdetail(iqcdetail, AppConfig.AppConnectString);
// }
// catch (Exception ex)
// {
// ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
// }
// #endregion
// #region 更新送到货单详细表的到货单状态
// ICSINVReceiptDetail receiptdetail = ICSWareHouseLotInfoLogBLL.selectReceiptDetail(stno, stline, AppConfig.AppConnectString);
// ICSWareHouseLotInfoLogBLL.updateRECSTATUS(stno, stline);
// try
// {
// ICSWareHouseLotInfoLogBLL.Receiptdetail(receiptdetail, AppConfig.AppConnectString);
// }
// catch (Exception ex)
// {
// ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
// }
// #endregion
// #region 更新送检单主表单据状态
//// string sql = @"select STDSTATUS
//// from ICSASNIQCDETAIL
//// where STNO='" + stno + "' and WorkPoint='" + AppConfig.WorkPointCode + "'";
//// sql = string.Format(sql);
//// DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
//// int flag = 0;
//// foreach (DataRow dr in data.Rows)
//// {
//// if (!dr["STDSTATUS"].ToString().Equals("已检已入"))
//// flag = 1;
//// }
//// if (flag == 0)
//// {
// ICSASNIQC iqc = ICSWareHouseLotInfoLogBLL.selectASNIQC(stno, stline, AppConfig.AppConnectString);
// ICSWareHouseLotInfoLogBLL.updateSTATUS(stno, stline);
// try
// {
// ICSWareHouseLotInfoLogBLL.asniqc(iqc, AppConfig.AppConnectString);
// }
// catch (Exception ex)
// {
// ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
// }
// //}
// #endregion
// #region 更新到货单主表单据状态
// string sql1 = @"select RECSTATUS
// from ICSINVReceiptDetail
// where ReceiptNO='" + stno + "' and WorkPoint='" + AppConfig.WorkPointCode + "'";
// sql1 = string.Format(sql1);
// DataTable data1 = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql1).Tables[0];
// int flag1 = 0;
// foreach (DataRow dr in data1.Rows)
// {
// if (!dr["RECSTATUS"].ToString().Equals("已经完成"))
// flag1 = 1;
// }
// if (flag1 == 0)
// {
// ICSINVReceipt invreceipt = ICSWareHouseLotInfoLogBLL.selectreceipt(stno, AppConfig.AppConnectString);
// ICSWareHouseLotInfoLogBLL.updatereceiptRECSTATUS(stno);
// try
// {
// ICSWareHouseLotInfoLogBLL.invreceipt(invreceipt, AppConfig.AppConnectString);
// }
// catch (Exception ex)
// {
// ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
// }
// }
// #endregion
// }
#endregion
/// <summary>
/// 关闭单据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnCancle_Click(object sender, EventArgs e)
{
#region 更新送到货单详细表的到货单状态
List<string> guidList = new List<string>();
for (int i = 0; i < grvDetail.RowCount; i++)
{
if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
{
guidList.Add(grvDetail.GetRowCellValue(i, colReceiptNO).ToString());
}
}
if (guidList.Count == 0)
{
ICSBaseSimpleCode.AppshowMessageBox("请选择数据!");
return;
}
if (grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colisSelect).ToString() == "Y")
{
string no = grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colReceiptNO).ToString();
int line = Convert.ToInt32(grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colReceiptLine));
ICSINVReceiptDetail receiptdetail = ICSWareHouseLotInfoLogBLL.selectReceiptDetail(no, line, AppConfig.AppConnectString);
ICSWareHouseLotInfoLogBLL.updateRECSTATUS(no, line);
try
{
ICSWareHouseLotInfoLogBLL.Receiptdetail(receiptdetail, AppConfig.AppConnectString);
ICSBaseSimpleCode.AppshowMessageBox("关闭成功");
btnRefresh_Click(null, null);
}
catch (Exception ex)
{
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
}
}
#endregion
}
}
}