Files
lserp_cs_6.0/插件库/mes_YzUsedby2/FrmMain.cs
T
cyf ab56a9bcf7 基线 SVN r240
SVN-Revision: r240
2025-02-06 06:46:06 +00:00

794 lines
38 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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;
using Lskj.Control;
using Lskj.Core;
using Lskj.Util;
using Lskj.Data;
using Lskj.Business.Impl;
using System.Data.SqlClient;
using static System.Windows.Forms.TabControl;
using Lskj.Business;
namespace mes_YzUsedby2
{
public partial class FrmMain : BaseForm
{
public DynamicDemoModel Model;
public TextBox t1 { get { return textBox1; } }
public TextBox t2 { get { return textBox2; } }
public string ScanningText;
public FrmMain()
{
InitializeComponent();
gridViewClSj.ClearSelection();
//this.tabControl1.TabPages.RemoveAt(2);
}
private System.Data.DataTable ClsjTable = new System.Data.DataTable();
private System.Data.DataTable YlsjTable = new System.Data.DataTable();
private System.Data.DataTable BcpsjTable = new System.Data.DataTable();
private System.Data.DataTable CpsjTable = new System.Data.DataTable();
private System.Data.DataTable JTlSjTable = new System.Data.DataTable();
private System.Data.DataTable YSjTable = new System.Data.DataTable();
private System.Data.DataTable YXjTable = new System.Data.DataTable();
private System.Data.DataTable tmpTable = new System.Data.DataTable();
//成品上机
// sql = "select coalias, mxId,primaryKey,Billid_stepover,a.id,uniqueCode,ABS(Amount) AS Amount,jtBillNo from wms_productBarCode a WITH (NOLOCK) join Wms_BilljoinsMainTab a1 WITH (NOLOCK) on primaryKey=wms_mjoins_billdocument_id join Wms_BilljoinslistTab a2 on wms_mjoins_billdocument_id=wms_ljoins_billdocument_id and a.mxId=a2.wms_ljoins_id " +
//" left join Mps_MachineSetTab b on a.Jtid=b.id left join P_CustomerTab c on a.coid=c.id " +
//" where modid in (1100301,11003) and wms_ljoins_jtid='" + DllBaseClass.Gjtid + "' and (objectId='" + textBox3.Text + "' or '" + textBox6.Text + "'='替代纸') and ISNULL(SjTig,0)=0 " +
//" and uniqueCode like '%" + textBox11.Text + "%' and amount<0 ";
// CpsjTable = BaseImpl.GetDataTableResult(sql);
// gridControlCpSj.DataSource = CpsjTable;
// //机台料上机
// sql = "select top 20 id,ClTm,operatordate,amount,OutBarID from WMS_BillOutUsedByPlanTab where jtid='" + DllBaseClass.Gjtid + "' and Productid='" + textBox3.Text + "' and planlistid<>'" + DllBaseClass.planlistid + "' and cltm not in (select cltm from WMS_BillOutUsedByPlanTab where planlistid='" + DllBaseClass.planlistid + "' and issn=1 ) and issn=1 and Sjtype<>5 order by operatordate desc ";
// JTlSjTable = BaseImpl.GetDataTableResult(sql);
// gridControlJTLSJ.DataSource = JTlSjTable;
public void adddata()
{
//材料上机 where modid in (1100201, 11002) and isnull(jstig,0)=0
// " and uniqueCode like '%" + textBox7.Text + "%' and amount<0 ";
//string sql = @"select coalias,isnull(YsTig,0) as YsTig,mxId,primaryKey,Billid_stepover,a.id,uniqueCode,ABS(Amount) AS Amount,jtBillNo,p.model as model,p.spec as spec
// from wms_productBarCode a WITH(NOLOCK)
// join mps_PlanBomBaseTab aa WITH(NOLOCK) on a.objectId = aa.productid
// left join mrp_mpsPlanListTab mp with(nolock) on aa.planlistid = mp.id
// join Wms_BillOutMainTab a1 WITH(NOLOCK) on primaryKey = wms_mout_billdocument_id
// left join p_ProductTab p on p.ProductId=a.objectId
// left join Mps_MachineSetTab b on a.Jtid = b.id
// left join P_ProviderTab c on a.poid = c.id
// left join mes_ws_list ws on mp.workshopid = ws.mes_ws_ID
// where modid in (1100201, 11002) and a1.wms_mout_operatedate >= GETDATE()-ws.mes_ws_sjday
// --and not exists(select 1 from wms_BillOutExpendTab with(nolock) where cltm = a.uniqueCode and isnull(Tmqz,'') = 'CLXJ')
// and a.Amount < 0 and a.Jtid = mp.scjtid
// and wms_mout_workshop = '" + DllBaseClass.workshop + "' and aa.planlistid = '" + DllBaseClass.planlistid + "' and uniqueCode like '%" + textBox7.Text + "%' order by a.id desc";
// // + "and uniqueCode like '%" + textBox7.Text + "%' and amount<0 ";
string sql = string.Format(@"select coalias,isnull(YsTig,0) as YsTig,mxId,primaryKey,Billid_stepover,a.id,uniqueCode,ABS(a.Amount) AS Amount,jtBillNo,p.model as model,p.spec as spec
from wms_productbarcode a with(nolock)
join mps_planbombasetab aa with(nolock) on a.objectid = aa.productid
left join mrp_mpsplanlisttab mp with(nolock) on aa.planlistid = mp.id
join wms_billoutmaintab a1 with(nolock) on primarykey = wms_mout_billdocument_id
left join p_producttab p with(nolock) on p.productid=a.objectid
left join mps_machinesettab b with(nolock) on a.jtid = b.id
left join p_providertab c with(nolock) on a.poid = c.id
left join mes_ws_list ws with(nolock) on mp.workshopid = ws.mes_ws_id
left join wms_billoutusedbyplantab ss with(nolock) on ss.planlistid=aa.planlistid and ss.cltm=a.uniquecode
where modid in (1100201, 11002) and a1.wms_mout_operatedate >= getdate()-ws.mes_ws_sjday
--and not exists(select 1 from wms_billoutexpendtab with(nolock) where cltm = a.uniquecode and isnull(tmqz,'') = 'clxj')
and a.amount < 0 and a.jtid = mp.scjtid
and isnull(ss.productid,'')=''
and wms_mout_workshop = '{0}' and aa.planlistid = '{1}' and isnull(ustig,0) = 0
and not exists(
select 1 from wms_billoutexpendtab dd with(nolock) where dd.typeid=3 and isnull(dd.cltm,'')=a.uniquecode and dd.Productid=a.objectId
)
and not exists(
select 1 from Mrp_WorkOrderTab dd with(nolock) where isnull(dd.YzBarcode,'')=a.uniquecode
)
order by a.id desc", DllBaseClass.workshop, DllBaseClass.planlistid);
ClsjTable = BaseImpl.GetDataTableResult(sql);
gridControlCLSJ.DataSource = ClsjTable;
this.gridViewClSj.ClearSelection();
//默认选中第一行
//if (ClsjTable.Rows.Count > 0)
//{
// gridViewClSj.FocusedRowHandle = 0;
// gridViewClSj.SelectRow(0);
//}
//余料上机
string jttj = "";
if (checkBox1.Checked == false)
{ jttj = " and jtid='" + DllBaseClass.Gjtid + "' "; }
sql = "select coalias,Jtid,a.id,jtbillno,ClTm,barcode,amount,OutBarID from wms_BillOutExpendTab a WITH (NOLOCK) join Mps_MachineSetTab b on a.Jtid=b.id left join P_ProviderTab c on a.pid=c.id " +
"where b.workshopid='" + DllBaseClass.workshop + "' and Tmqz='CLXJ' " + jttj + " and RedTig=0 and ISNULL(SjTig,0)=0 and productid='" + textBox3.Text + "' and barcode like '%" + textBox8.Text + "%' ";
YlsjTable = BaseImpl.GetDataTableResult(sql);
gridControlYLSJ.DataSource = YlsjTable;
//半成品上机
sql = "select A.ID,PrCoName,jtBillNo,barcode,joinamount from Mrp_WorkOrderTab A JOIN Mps_MachineSetTab B ON A.Jtid=B.id where a.workshopid='" + DllBaseClass.workshop + "' and productid='" + textBox3.Text + "' and barcode='" + textBox10.Text + "' and isnull(BcpSjtig,0)=0 and isnull(rktig,0)=0 ";
BcpsjTable = BaseImpl.GetDataTableResult(sql);
gridControlBcpSj.DataSource = BcpsjTable;
//成品上机
// sql = "select coalias, mxId,primaryKey,Billid_stepover,a.id,uniqueCode,ABS(Amount) AS Amount,jtBillNo from wms_productBarCode a WITH (NOLOCK) join Wms_BilljoinsMainTab a1 WITH (NOLOCK) on primaryKey=wms_mjoins_billdocument_id join Wms_BilljoinslistTab a2 on wms_mjoins_billdocument_id=wms_ljoins_billdocument_id and a.mxId=a2.wms_ljoins_id " +
//" left join Mps_MachineSetTab b on a.Jtid=b.id left join P_CustomerTab c on a.coid=c.id " +
//" where modid in (1100301,11003) and wms_ljoins_jtid='" + DllBaseClass.Gjtid + "' and (objectId='" + textBox3.Text + "' or '" + textBox6.Text + "'='替代纸') and ISNULL(SjTig,0)=0 " +
//" and uniqueCode like '%" + textBox11.Text + "%' and amount<0 ";
// CpsjTable = BaseImpl.GetDataTableResult(sql);
// gridControlCpSj.DataSource = CpsjTable;
////机台料上机
//sql = "select top 20 id,ClTm,operatordate,amount,OutBarID from WMS_BillOutUsedByPlanTab where jtid='" + DllBaseClass.Gjtid + "' and Productid='" + textBox3.Text + "' and planlistid<>'" + DllBaseClass.planlistid + "' and cltm not in (select cltm from WMS_BillOutUsedByPlanTab where planlistid='" + DllBaseClass.planlistid + "' and issn=1 ) and issn=1 and Sjtype<>5 order by operatordate desc ";
//JTlSjTable = BaseImpl.GetDataTableResult(sql);
//gridControlJTLSJ.DataSource = JTlSjTable;
//已上机材料
sql = "select c.coalias,d.coalias as khcoalias,a.*,spec,model from WMS_BillOutUsedByPlanTab a join p_ProductTab b on a.Productid=b.ProductId left join P_ProviderTab c on a.pid=c.id left join P_CustomerTab d on a.cid=d.id where planlistid='" + DllBaseClass.planlistid + "' and issn=1 ";
YSjTable = BaseImpl.GetDataTableResult(sql);
gridControlYSJ.DataSource = YSjTable;
//已经下机器材料
sql = "select coalias,a.*,spec,model from WMS_BillOutUsedByPlanTab a join p_ProductTab b on a.Productid=b.ProductId left join P_ProviderTab c on a.pid=c.id where planlistid='" + DllBaseClass.planlistid + "' and issn=0 ";
YXjTable = BaseImpl.GetDataTableResult(sql);
gridControlYXJ.DataSource = YXjTable;
}
/**
* 说明如下:ss
* 开发环境:采用Vs2010开发环境
* 调用.net程序支持2种模式:1、调用exe 2、调用dll类库
*
* 1、调用exe方式:无需建立DllBaseClass.cs参数类,直接建立exe程序即可。参数通过入口参数提取。
* 2、调用dll方式: 需要建立DllBaseClass.cs参数类,需要注意类名称必须为DllBaseClass,具体参考DllBaseClass.cs方法,基本上通用。
*
* 通用设置:
* 建立窗口需要继承BaseForm窗口,同时引入6个公共dll程序(Lskj.Business.dll、Lskj.Control.dll、Lskj.Core.dll、Lskj.Data.dll、Lskj.Model.dll、Lskj.Util.dll
* 此窗口在Lskj.Control.dll中,前提需要安装DevExpress15.2版本。
* Lskj.Business.dll 所有业务处理类库,以及访问数据库操作类
* Lskj.Core.dll 数据库连接创建类库
* Lskj.Data.dll 存放资源文件以及所有提示信息
* Lskj.Model.dll 存放公用的业务对象Model
* Lskj.Util.dll 存放所有常用操作类
*
* 下面展示一下怎么创建连接获取数据等
**/
/// <summary>
/// <para>说明:窗口加载时调用</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期: </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void FrmMain_Load(object sender, EventArgs e)
{
// 检查数据库连接
if (!DBConfig.Instance.CreateConnection())
{
MessageUtil.Show(ResourceKeys.UnConnectServer);
return;
}
// 检查delphi连接
//if (DelphiHelper.Delphi_Init(new StringBuilder(DBConfig.Instance.GetDelphiConnection())) == 0)
//{
// MessageUtil.Show(ResourceKeys.UnConnectServer + "[By Delphi]");
// return;
//}
// 访问数据库开始操作,所有公共操作在BaseImpl类里面,下面还有很多继承类
string sqlValue = "select * from p_systemtab";
DataTable tmpTable = BaseImpl.GetDataTableResult(sqlValue);
// MessageUtil.Show(table.Rows.Count + "");
this.Text = tmpTable.Rows[0]["ClientName"].ToString();
string sql="select productid,appellation,spec,model from p_producttab where productid='"+DllBaseClass.YzProductid+"' " ;
tmpTable = BaseImpl.GetDataTableResult(sql);
textBox3.Text= tmpTable.Rows[0]["productid"].ToString();
textBox4.Text = tmpTable.Rows[0]["appellation"].ToString();
textBox5.Text = tmpTable.Rows[0]["spec"].ToString();
textBox6.Text = tmpTable.Rows[0]["model"].ToString();
sql = "select a.workshopid,YsHour,jtbillno,jtlsj from Mps_MachineSetTab a join Mrp_WpSetTab b on a.wpid=b.id where a.id='" + DllBaseClass.Gjtid + "' ";
tmpTable = BaseImpl.GetDataTableResult(sql);
DllBaseClass.YsHour = string.IsNullOrEmpty(tmpTable.Rows[0]["YsHour"]+"")?0 : Convert.ToInt32(tmpTable.Rows[0]["YsHour"] + "");
DllBaseClass.jtlsj = Convert.ToInt32(tmpTable.Rows[0]["jtlsj"].ToString());
DllBaseClass.workshop = tmpTable.Rows[0]["workshopid"].ToString();
DllBaseClass.GjtName = tmpTable.Rows[0]["jtbillno"].ToString();
adddata();
textBox1.Text = "操作员:" + DllBaseClass.Goperatorname + "计划ID" + DllBaseClass.planlistid + "机台ID" + DllBaseClass.Gjtid + "原纸编码" + DllBaseClass.YzProductid + "验收小时" + DllBaseClass.YsHour.ToString() + "车间" + DllBaseClass.workshop + "机台编码" + DllBaseClass.GjtName;
//隐藏半成品上机
if (Model.HideTabPage)
{
TabPage tab = this.tabControl1.TabPages[2];
tab.Parent = null;
}
//隐藏余料上机
if (Model.HideExcessStockTabPage)
{
TabPage tab = this.tabControl1.TabPages[1];
tab.Parent = null;
}
//设置不可编辑
this.gridViewClSj.OptionsBehavior.Editable = false;
this.gridViewClSj.OptionsBehavior.ReadOnly = true;
this.gridViewClSj.OptionsSelection.EnableAppearanceFocusedCell = false;
//上机按钮不可交互
//this.button1.Enabled = false;
this.textBox7.KeyDown += TextBox7_KeyDown;
this.textBox7.Focus();
}
public void ChangeColor(bool item)
{
this.gridViewClSj.OptionsView.ShowIndicator = item;
if (item)
{
this.gridViewClSj.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.CellFocus;
}
else {
this.gridViewClSj.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.None;
}
this.gridViewClSj.OptionsSelection.EnableAppearanceFocusedCell = item;
this.gridViewClSj.OptionsSelection.EnableAppearanceFocusedRow = item;
this.gridViewClSj.OptionsSelection.EnableAppearanceHideSelection = item;
}
private void TextBox7_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
string str1 = textBox7.Text;
string str2 = textBox7.Text + "&";
int F = 0;
F = str2.IndexOf("&");
if (F == 0)
{
//str1 = textBox1.Text;
}
else
{
str1 = str2.Substring(0, F);
}
textBox7.Text = str1;
adddata();
}
}
private void GridViewClSj_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
{
DataTable table = gridControlCLSJ.DataSource as DataTable;
if (!string.IsNullOrEmpty(ScanningText))
{
string value = textBox7.Text;
DataTable dataTable = gridControlCLSJ.DataSource as DataTable;
DataRow dr = dataTable.Rows.Cast<DataRow>().FirstOrDefault(x => (x["uniqueCode"] + "").Equals(value));
if (dr != null)
{
ChangeColor(true);
gridViewClSj.Focus();
gridViewClSj.FocusedRowHandle = dataTable.Rows.IndexOf(dr);
gridViewClSj.SelectRow(dataTable.Rows.IndexOf(dr));
this.button1.Enabled = true;
}
}
}
private void button6_Click(object sender, EventArgs e)
{
Close();
}
private void button1_Click(object sender, EventArgs e)
{
if (gridViewClSj.FocusedRowHandle < 0) {
MessageBox.Show("请选择卷号进行上机", "提示");
return;
}
DialogResult str1 = MessageBox.Show("确定将此卷号上机吗", "提示!", MessageBoxButtons.YesNo);
if (str1 == DialogResult.Yes)
{
string sql = "select 1 from wms_productBarCode WITH (NOLOCK) where id='" + ClsjTable.Rows[gridViewClSj.FocusedRowHandle]["id"].ToString() + "' and DATEDIFF(month,Billdt,getdate())>0 ";
tmpTable = BaseImpl.GetDataTableResult(sql);
if (tmpTable.Rows.Count != 0)
{
// MessageBox.Show("此记录不是当前月领料出库,不能上机", "提示");-----------
//return;
}
sql = string.Format(@"select 1 from mrp_mpsPlanListTab a
join mps_PlanBomBaseTab aa on a.id = aa.planlistid
where 1 = 1 and a.id = '{0}'
and not exists(
select * from wms_alluniqueCodeView1 ss where ss.uniquecode = '{1}' and ss.objectid = aa.productid
)", ClsjTable.Rows[gridViewClSj.FocusedRowHandle]["id"].ToString(), ClsjTable.Rows[gridViewClSj.FocusedRowHandle]["uniqueCode"].ToString());
tmpTable = BaseImpl.GetDataTableResult(sql);
if (tmpTable.Rows.Count != 0)
{
//MessageBox.Show("该条码对应的物料不在该任务用料清单中", "提示");
//return;
}
//sql = "select 1 from wms_productBarCode a WITH (NOLOCK) join (select YzProductid,YzProviderid from mrp_mpsPlanListTab WITH (NOLOCK) where id='" + DllBaseClass.planlistid + "' and YZProviderid<>0) b on a.objectId=b.YzProductid and a.Poid<>b.YzProviderid where id='" + ClsjTable.Rows[gridViewClSj.FocusedRowHandle]["id"].ToString() + "' ";
//tmpTable = BaseImpl.GetDataTableResult(sql);
//if (tmpTable.Rows.Count != 0)
//{
// MessageBox.Show("此记录不是生产指定供应商,不能上机", "提示");-----------
// return;
//}
//sql = "select 1 from wms_productBarCode WITH (NOLOCK) where modid in (1100201,11002) and Billid_stepover=0 and ISNULL(YsTig,0)=0 and Amount<0 AND Jtid='" + DllBaseClass.Gjtid + "' and DATEDIFF(HH,operateDate,GETDATE())>=" + DllBaseClass.YsHour.ToString() + " ";
//tmpTable = BaseImpl.GetDataTableResult(sql);
//if (tmpTable.Rows.Count != 0)
//{
// //MessageBox.Show("机台有超过" + DllBaseClass.YsHour + "小时未上机材料未验收,不能上机", "提示");-------------
// //return;
//}
// sql = " select 1 from mrp_PlanJTReplaceTab where JtZy_Barid='" + ClsjTable.Rows[gridViewClSj.FocusedRowHandle]["id"].ToString() + "' and JtZy_stepOver=0 ";
// tmpTable = BaseImpl.GetDataTableResult(sql);
// if (tmpTable.Rows.Count != 0)
// {
// //MessageBox.Show("此条码被其他机台转移申请,请先处理", "提示");-----------
// //return;
// }
// if (Convert.ToInt32(ClsjTable.Rows[gridViewClSj.FocusedRowHandle]["ystig"].ToString()) ==0)
// {
// //MessageBox.Show("此条码未验收,请先验收后再上机", "提示");--------------
// //return;
// }
if (YSjTable.Rows.Count != 0 && checkBox2.Checked ==false)
{
MessageBox.Show("已经有材料上机,如果想多卷上机,请勾选多卷上机","提示");
return;
}
try
{
sql = "insert WMS_BillOutUsedByPlanTab( pid,Sjtype,issn,OutDate,OutListID,OutBarID,ParentClTm,ClTm,Storehouseid,Productid,Jtid,planlistid,amount,operatorname,operatordate) " +
"select poid,1,1,Billdt ,mxid,id,uniqueCode,uniqueCode,storehouseid,objectId,'" + DllBaseClass.Gjtid + "','" + DllBaseClass.planlistid + "',-Amount,'" + DllBaseClass.Goperatorname + "',getdate() " +
"from wms_productBarCode WITH (NOLOCK) where id='" + ClsjTable.Rows[gridViewClSj.FocusedRowHandle]["id"].ToString() + "' ";
BaseImpl.ExecSqlValueMes(sql);
sql = "update wms_productBarCode set sjtig=1 where id='" + ClsjTable.Rows[gridViewClSj.FocusedRowHandle]["id"].ToString() + "' ";
BaseImpl.ExecSqlValueMes(sql);
}
catch (Exception ex)
{
MessageBox.Show("保存失败"+ex.Message);
return;
}
MessageBox.Show("上机成功", "提示");
adddata();
ScanningText = string.Empty;
}
}
private void button2_Click(object sender, EventArgs e)
{
if (gridViewYLSJ.FocusedRowHandle < 0)
{
MessageBox.Show("请选择卷号进行上机", "提示");
return;
}
DialogResult str1 = MessageBox.Show("确定将此卷号上机吗", "提示!", MessageBoxButtons.YesNo);
if (str1 == DialogResult.Yes)
{
string sql = "select 1 from wms_productBarCode WITH (NOLOCK) where id='" + YlsjTable.Rows[gridViewYLSJ.FocusedRowHandle]["OutBarID"].ToString() + "' and DATEDIFF(month,Billdt,getdate())>0 ";
tmpTable = BaseImpl.GetDataTableResult(sql);
if (tmpTable.Rows.Count != 0)
{
MessageBox.Show("此记录不是当前月领料出库,不能上机", "提示");
return;
}
if (YSjTable.Rows.Count != 0 && checkBox2.Checked == false)
{
MessageBox.Show("已经有材料上机,如果想多卷上机,请勾选多卷上机", "提示");
return;
}
sql = string.Format(@"select 1 from mrp_mpsPlanListTab a
join mps_PlanBomBaseTab aa on a.id = aa.planlistid
where 1 = 1 and a.id = '{0}'
and not exists(
select * from wms_alluniqueCodeView1 ss where ss.uniquecode = '{1}' and ss.objectid = aa.productid
)", YlsjTable.Rows[gridViewYLSJ.FocusedRowHandle]["OutBarID"].ToString(), textBox8.Text);
tmpTable = BaseImpl.GetDataTableResult(sql);
if (tmpTable.Rows.Count != 0)
{
MessageBox.Show("该条码对应的物料不在该任务用料清单中", "提示");
return;
}
try
{
sql = "insert WMS_BillOutUsedByPlanTab( pid,Sjtype,issn,OutDate,OutListID,OutBarID,expid,ParentClTm,ClTm,Storehouseid,Productid,Jtid,planlistid,amount,operatorname,operatordate) " +
"select pid,2,1,OutDate ,OutListID,OutBarID,id,ClTm,Barcode,Storehouseid,Productid,'" + DllBaseClass.Gjtid + "','" + DllBaseClass.planlistid + "',Amount,'" + DllBaseClass.Goperatorname + "',getdate() " +
"from wms_BillOutExpendTab WITH (NOLOCK) where id='" + YlsjTable.Rows[gridViewYLSJ.FocusedRowHandle]["id"].ToString() + "' ";
BaseImpl.ExecSqlValueMes(sql);
sql = "update wms_BillOutExpendTab set sjtig=1 where id='" + YlsjTable.Rows[gridViewYLSJ.FocusedRowHandle]["id"].ToString() + "' ";
BaseImpl.ExecSqlValueMes(sql);
}
catch (Exception ex)
{
MessageBox.Show("上机失败" + ex.Message);
return;
}
MessageBox.Show("上机成功", "提示");
adddata();
}
}
private void button5_Click_1(object sender, EventArgs e)
{
try
{
if (gridViewYSJ.FocusedRowHandle < 0)
{
MessageBox.Show("请选择卷号进行上机", "提示");
return;
}
DialogResult str1 = MessageBox.Show("确定要删除此卷号上机吗", "提示!", MessageBoxButtons.YesNo);
if (str1 == DialogResult.Yes)
{
string sql = "select 1 from wms_BillOutExpendTab where OutBarID='" + YSjTable.Rows[gridViewYSJ.FocusedRowHandle]["OutBarID"].ToString() + "' and " +
" ParentClTm='" + YSjTable.Rows[gridViewYSJ.FocusedRowHandle]["ClTm"].ToString() + "' and planlistid='" + DllBaseClass.planlistid + "' ";
tmpTable = BaseImpl.GetDataTableResult(sql);
if (tmpTable.Rows.Count != 0)
{
MessageBox.Show("此条码已经被后续使用,不能删除上机", "提示");
return;
}
sql = "select 1 from wms_BillOutExpendTab where SjWorkId='" + YSjTable.Rows[gridViewYSJ.FocusedRowHandle]["SjWorkId"].ToString() + "' and " +
" ParentClTm='" + YSjTable.Rows[gridViewYSJ.FocusedRowHandle]["ClTm"].ToString() + "' and planlistid='" + DllBaseClass.planlistid + "'";
tmpTable = BaseImpl.GetDataTableResult(sql);
if (tmpTable.Rows.Count != 0)
{
MessageBox.Show("此条码已经被后续使用,不能删除上机", "提示");
return;
}
sql = " delete WMS_BillOutUsedByPlanTab where id='" + YSjTable.Rows[gridViewYSJ.FocusedRowHandle]["id"].ToString() + "' ";
BaseImpl.ExecSqlValueMes(sql);
//材料上机
if (Convert.ToInt32(YSjTable.Rows[gridViewYSJ.FocusedRowHandle]["sjtype"].ToString()) == 1)
{
sql = " update wms_productBarCode set sjtig=0 where id='" + YSjTable.Rows[gridViewYSJ.FocusedRowHandle]["OutBarID"].ToString() + "' ";
BaseImpl.ExecSqlValueMes(sql);
}
//余料上机
if (Convert.ToInt32(YSjTable.Rows[gridViewYSJ.FocusedRowHandle]["sjtype"].ToString()) == 2)
{
sql = " update wms_BillOutExpendTab set sjtig=0 where barcode='" + YSjTable.Rows[gridViewYSJ.FocusedRowHandle]["ClTm"].ToString() + "' ";
BaseImpl.ExecSqlValueMes(sql);
}
//半成品上机
if (Convert.ToInt32(YSjTable.Rows[gridViewYSJ.FocusedRowHandle]["sjtype"].ToString()) == 3)
{
sql = " update Mrp_WorkOrderTab set BcpSjtig=0 where id='" + YSjTable.Rows[gridViewYSJ.FocusedRowHandle]["SjWorkId"].ToString() + "' ";
BaseImpl.ExecSqlValueMes(sql);
}
//成品上机
if (Convert.ToInt32(YSjTable.Rows[gridViewYSJ.FocusedRowHandle]["sjtype"].ToString()) == 4)
{
sql = " update wms_productBarCode set sjtig=0 where id='" + YSjTable.Rows[gridViewYSJ.FocusedRowHandle]["OutBarID"].ToString() + "' ";
BaseImpl.ExecSqlValueMes(sql);
}
}
}
catch (Exception ex)
{
string cw = ex.InnerException.Message;
if (cw.IndexOf("\r\n") > 0)
{
cw = cw.Substring(0, cw.IndexOf("\r\n"));
}
MessageBox.Show("删除失败:" + cw);
}
finally
{
adddata();
}
}
//private void button4_Click(object sender, EventArgs e)
//{
// //if (gridViewJTLSJ.FocusedRowHandle < 0)
// //{
// // MessageBox.Show("请选择卷号进行上机", "提示");
// // return;
// //}
// if (DllBaseClass.jtlsj != 1)
// {
// MessageBox.Show("此工序不允许机台料上机", "提示");
// return;
// }
// DialogResult str1 = MessageBox.Show("确定将此卷号上机吗", "提示!", MessageBoxButtons.YesNo);
// if (str1 == DialogResult.Yes)
// {
// string sql = "select 1 from wms_productBarCode WITH (NOLOCK) where id='" + JTlSjTable.Rows[gridViewJTLSJ.FocusedRowHandle]["OutBarID"].ToString() + "' and DATEDIFF(month,Billdt,getdate())>0 ";
// tmpTable = BaseImpl.GetDataTableResult(sql);
// if (tmpTable.Rows.Count != 0)
// {
// MessageBox.Show("此记录不是当前月领料出库,不能上机", "提示");
// return;
// }
// if (YSjTable.Rows.Count != 0 && checkBox2.Checked == false)
// {
// MessageBox.Show("已经有材料上机,如果想多卷上机,请勾选多卷上机", "提示");
// return;
// }
// sql = "select 1 from WMS_BillOutUsedByPlanTab where planlistid='+planlistid+' and ClTm='" + JTlSjTable.Rows[gridViewJTLSJ.FocusedRowHandle]["ClTm"].ToString() + "' ";
// tmpTable = BaseImpl.GetDataTableResult(sql);
// if (tmpTable.Rows.Count != 0)
// {
// MessageBox.Show("此条码在此订单已经上机,不能继续上机", "提示");
// return;
// }
// sql = "insert WMS_BillOutUsedByPlanTab( pid,Sjtype,issn,OutDate,OutListID,OutBarID,expid,ParentClTm,ClTm,Storehouseid,Productid,Jtid,planlistid,amount,operatorname,operatordate) " +
// "select pid,5,1,OutDate, OutListID,OutBarID,expid,ParentClTm,ClTm,Storehouseid,Productid,Jtid,'" + DllBaseClass.planlistid + "',amount,'" + DllBaseClass.Goperatorname + "',getdate() from WMS_BillOutUsedByPlanTab where id= '" + JTlSjTable.Rows[gridViewJTLSJ.FocusedRowHandle]["ID"].ToString() + "' ";
// BaseImpl.ExecSqlValueMes(sql);
// }
//}
private void button6_Click_1(object sender, EventArgs e)
{
Close();
}
private void textBox7_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)
{
string str1 = textBox7.Text;
string str2 = textBox7.Text + "&";
int F = 0;
F = str2.IndexOf("&");
if (F == 0)
{
str1 = textBox1.Text;
}
else
{
str1 = str2.Substring(0, F);
}
textBox7.Text = str1;
adddata();
}
else if (e.KeyChar == 8 || e.KeyChar == 46)
{
e.Handled = true;
}
}
private void gridControlCLSJ_Click(object sender, EventArgs e)
{
}
private void gridControlJTLSJ_Click(object sender, EventArgs e)
{
}
private void checkBox1_Click(object sender, EventArgs e)
{
adddata();
}
private void button3_Click(object sender, EventArgs e)
{
if (gridViewBcpSj.FocusedRowHandle < 0)
{
MessageBox.Show("请选择卷号进行上机", "提示");
return;
}
DialogResult str1 = MessageBox.Show("确定将此卷号上机吗", "提示!", MessageBoxButtons.YesNo);
if (str1 == DialogResult.Yes)
{
if (YSjTable.Rows.Count != 0 && checkBox2.Checked == false)
{
MessageBox.Show("已经有材料上机,如果想多卷上机,请勾选多卷上机", "提示");
return;
}
string sql1 = string.Format(@"select 1 from mrp_mpsPlanListTab a
join mps_PlanBomBaseTab aa on a.id = aa.planlistid
where 1 = 1 and a.id = '{0}'
and not exists(
select * from wms_alluniqueCodeView1 ss where ss.uniquecode = '{1}' and ss.objectid = aa.productid
)", BcpsjTable.Rows[gridViewBcpSj.FocusedRowHandle]["id"].ToString(), textBox10.Text);
tmpTable = BaseImpl.GetDataTableResult(sql1);
if (tmpTable.Rows.Count != 0)
{
MessageBox.Show("该条码对应的物料不在该任务用料清单中", "提示");
return;
}
try
{
string sql = "insert WMS_BillOutUsedByPlanTab( cid,Sjtype,issn,SjWorkId,ParentClTm,ClTm,Productid,Jtid,planlistid,amount,operatorname,operatordate) " +
"select PrCoid,3,1,id,barcode,barcode,productid,'" + DllBaseClass.Gjtid + "','" + DllBaseClass.planlistid + "',joinamount,'" + DllBaseClass.Goperatorname + "',getdate() " +
"from Mrp_WorkOrderTab WITH (NOLOCK) where id='" + BcpsjTable.Rows[gridViewBcpSj.FocusedRowHandle]["id"].ToString() + "' ";
BaseImpl.ExecSqlValueMes(sql);
sql = "update Mrp_WorkOrderTab set BcpSjtig=1 where id='" + BcpsjTable.Rows[gridViewBcpSj.FocusedRowHandle]["id"].ToString() + "' ";
BaseImpl.ExecSqlValueMes(sql);
}
catch (Exception ex)
{
MessageBox.Show("保存失败" + ex.Message);
return;
}
MessageBox.Show("上机成功", "提示");
adddata();
}
}
private void textBox10_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13) {
adddata();
}
}
private void textBox11_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)
{
adddata();
}
}
//private void button7_Click(object sender, EventArgs e)
//{
// if (gridViewCpSj.FocusedRowHandle < 0)
// {
// MessageBox.Show("请选择卷号进行上机", "提示");
// return;
// }
// DialogResult str1 = MessageBox.Show("确定将此卷号上机吗", "提示!", MessageBoxButtons.YesNo);
// if (str1 == DialogResult.Yes)
// {
// if (YSjTable.Rows.Count != 0 && checkBox2.Checked == false)
// {
// MessageBox.Show("已经有材料上机,如果想多卷上机,请勾选多卷上机", "提示");
// return;
// }
// try
// {
// string sql = "insert WMS_BillOutUsedByPlanTab( cid,Sjtype,issn,OutDate,OutListID,OutBarID,ParentClTm,ClTm,Storehouseid,Productid,Jtid,planlistid,amount,operatorname,operatordate) " +
// "select coid,4,1,Billdt ,mxid,id,uniqueCode,uniqueCode,storehouseid,objectId,'" + DllBaseClass.Gjtid + "','" + DllBaseClass.planlistid + "',-Amount,'" + DllBaseClass.Goperatorname + "',getdate() " +
// "from wms_productBarCode WITH (NOLOCK) where id='" + CpsjTable.Rows[gridViewCpSj.FocusedRowHandle]["id"].ToString() + "' ";
// BaseImpl.ExecSqlValueMes(sql);
// sql = "update wms_productBarCode set sjtig=1 where id='" + CpsjTable.Rows[gridViewCpSj.FocusedRowHandle]["id"].ToString() + "' ";
// BaseImpl.ExecSqlValueMes(sql);
// }
// catch (Exception ex)
// {
// MessageBox.Show("保存失败" + ex.Message);
// return;
// }
// MessageBox.Show("上机成功", "提示");
// adddata();
// }
//}
}
}