using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using System.Windows.Forms;
|
|
namespace WFormReadData_SMR
|
{
|
public partial class ZZ_GlueWeigh : Form
|
{
|
DataTable dataTable = new DataTable();
|
private json objJsonResult = new json();
|
public DBHelper oCN = new DBHelper();
|
public ZZ_GlueWeigh()
|
{
|
InitializeComponent();
|
}
|
|
private void textBox2_Leave(object sender, EventArgs e)
|
{
|
if (string.IsNullOrWhiteSpace(txtHMaker.Text))
|
{
|
this.txtHMaker.ForeColor = Color.LightGray;
|
txtHMaker.Text = "请输入用户编码!";
|
}
|
}
|
|
private void textBox2_KeyDown(object sender, KeyEventArgs e)
|
{
|
if (e.KeyCode == Keys.Enter)
|
{
|
SelectHMaker(this.txtHMaker.Text);
|
}
|
}
|
|
private void textBox2_Enter(object sender, EventArgs e)
|
{
|
if (txtHMaker.Text.Trim() == "请输入用户编码!")
|
{
|
txtHMaker.Text = "";
|
this.txtHMaker.ForeColor = Color.Black;
|
}
|
}
|
|
//查询职员信息
|
public void SelectHMaker(string txtHMaker)
|
{
|
try
|
{
|
DataSet ds = oCN.RunProcReturn("select HItemID,HName,HNumber from Gy_Employee where HNumber='" + txtHMaker + "' or HName ='" + txtHMaker + "'", "Gy_Employee");
|
if (ds.Tables[0].Rows.Count > 0)
|
{
|
string HName = ds.Tables[0].Rows[0]["HName"].ToString();
|
string HMakerID = ds.Tables[0].Rows[0]["HItemID"].ToString();
|
string HNumber = ds.Tables[0].Rows[0]["HNumber"].ToString();
|
this.txtHMaker.Text = HName;
|
this.txtHMakerNumber.Text = HNumber;
|
this.labHMakerID.Text = HMakerID;
|
this.txtHMaker.ReadOnly = true;
|
}
|
else
|
{
|
MessageBox.Show(this.BeforeWeigh.Text + ",查无数据,可能是输入编码有误!", "提示");
|
}
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show(this, e.Message, "提示");
|
}
|
}
|
|
//条形码回车
|
private void txtLzk_KeyDown(object sender, KeyEventArgs e)
|
{
|
if (e.KeyCode == Keys.Enter)
|
{
|
if (this.txtHMaker.Text == "")
|
{
|
MessageBox.Show("请输入制单人信息!");
|
}
|
else
|
{
|
SelectHBardCode(this.txtLzk.Text);
|
}
|
|
}
|
}
|
|
//查询条形码
|
public void SelectHBardCode(string HBillNo)
|
{
|
try
|
{
|
DataSet ds = oCN.RunProcReturn("select * from h_v_Sc_ProcessExchangeBillQuerySub where 单据号='" + HBillNo + "' and 工序代码<>'9999' order by HEntryID desc", "h_v_Sc_ProcessExchangeBillQuerySub");
|
if (ds.Tables[0].Rows.Count == 0)
|
{
|
MessageBox.Show("流转卡:" + HBillNo + ",查无数据!");
|
}
|
else
|
{
|
string HProjectNum = ds.Tables[0].Rows[0]["HProjectNum"].ToString();
|
this.txtPcm.Text = HProjectNum;
|
this.txtLzk.Text = ds.Tables[0].Rows[0]["单据号"].ToString();
|
this.txtLzk.ReadOnly = true;
|
|
this.cmbPro.DataSource = ds.Tables[0];
|
this.cmbPro.DisplayMember = "工序名称";
|
this.cmbPro.ValueMember = "HProcID";
|
this.cmbPro.SelectedIndex = 0;
|
ShowData("CMR-F-001");//电子天平 CMR-F-001 测试 LMJC
|
|
}
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show(this, e.Message, "提示");
|
}
|
}
|
|
private void ZZ_GlueWeigh_Load(object sender, EventArgs e)
|
{
|
this.cmbEquip.SelectedIndex = 0;
|
this.cmbEquip.DropDownStyle = ComboBoxStyle.DropDownList;//只读
|
|
this.cmbPro.DropDownStyle = ComboBoxStyle.DropDownList;//只读
|
this.cmbJYSelect.DropDownStyle = ComboBoxStyle.DropDownList;//只读
|
this.cmbJYSelect.SelectedIndex = 0;
|
this.txtHMakerNumber.ReadOnly = true;//只读
|
this.txtPcm.ReadOnly = true;//只读
|
}
|
|
//查询称重的重量
|
private void btnBeFoSelect_Click(object sender, EventArgs e)
|
{
|
|
string cmbEquip = this.cmbEquip.Text;
|
if (cmbEquip == "全部")
|
{
|
MessageBox.Show("请选择组装设备!");
|
}
|
else {
|
string HNumber = "";
|
switch (cmbEquip)
|
{
|
case "组装2":
|
HNumber = "CMR-ZD-SD-002S2"; // CMR-ZD-SD-002
|
break;
|
case "组装3":
|
HNumber = "CMR-ZD-SD-006S2"; // CMR-ZD-SD-004
|
break;
|
default:
|
MessageBox.Show("设备错误!");
|
break;
|
}
|
|
//查询 顶部点胶重量 和 底部点胶重量 当前最大的数据
|
DataSet ds = oCN.RunProcReturn(@"select top 1 HTechParamName,HResult,HCreateTime from Sb_EquipMentCollectionTechParam_Temp
|
where HSourceCode = '" + HNumber + @"' and HTechParamName = '顶部点胶重量' and HCreateTime in(
|
select max(HCreateTime) from Sb_EquipMentCollectionTechParam_Temp
|
where HSourceCode = '" + HNumber + @"' and HTechParamName = '顶部点胶重量')
|
union
|
select top 1 HTechParamName,HResult,HCreateTime from Sb_EquipMentCollectionTechParam_Temp
|
where HSourceCode = '" + HNumber + @"' and HTechParamName = '底部点胶重量' and HCreateTime in(
|
select max(HCreateTime) from Sb_EquipMentCollectionTechParam_Temp
|
where HSourceCode = '" + HNumber + @"' and HTechParamName = '底部点胶重量')", "Sb_EquipMentCollectionTechParam_Temp");
|
|
//DataSet ds = oCN.RunProcReturn(@"select top 1 '螺牙检测数据' HTechParamName,HResult,HCreateTime from Sb_EquipMentCollectionTechParam_Temp
|
//where HTechParamName = '保压2'
|
//union
|
//select top 1 '同步测试' HTechParamName,HResult,HCreateTime from Sb_EquipMentCollectionTechParam_Temp
|
//where HTechParamName = '保压1'
|
//order by HCreateTime desc", "Sb_EquipMentCollectionTechParam_Temp");
|
|
if (ds.Tables[0].Rows.Count > 0)
|
{
|
//获取 顶部点胶重量 和 底部点胶重量
|
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
|
{
|
string HTechParamName = ds.Tables[0].Rows[i]["HTechParamName"].ToString();
|
for (int j = 0; j < dataTable.Rows.Count; j++)
|
{
|
if (HTechParamName == dataTable.Rows[j]["HQCCheckItemHName"].ToString())
|
{
|
string HResult = ds.Tables[0].Rows[i]["HResult"].ToString();
|
dataTable.Rows[j]["Actual"] = HResult;
|
|
switch (HTechParamName)
|
{
|
case "顶部点胶重量":
|
this.BeforeWeigh.Text = HResult;
|
break;
|
case "底部点胶重量":
|
this.AfterWeigh.Text = HResult;
|
break;
|
default:
|
MessageBox.Show("设备错误!");
|
break;
|
}
|
|
//switch (HTechParamName)
|
//{
|
// case "螺牙检测数据":
|
// this.BeforeWeigh.Text = HResult;
|
// break;
|
// case "同步测试":
|
// this.AfterWeigh.Text = HResult;
|
// break;
|
// default:
|
// MessageBox.Show("设备错误!");
|
// break;
|
//}
|
|
ListData.Items.Add("参数:" + ds.Tables[0].Rows[i]["HTechParamName"].ToString() + ",值:" + HResult);
|
break;
|
}
|
}
|
}
|
}
|
}
|
}
|
//更换流转卡
|
private void btnRep_Click(object sender, EventArgs e)
|
{
|
this.txtLzk.Text = "";
|
this.txtLzk.ReadOnly = false;
|
this.txtPcm.Text = "";
|
this.cmbPro.DataSource = null;
|
this.ListData.Items.Clear();
|
this.BeforeWeigh.Text = "";
|
this.AfterWeigh.Text = "";
|
this.btnSave.Enabled = true;
|
this.cmbEquip.SelectedIndex = 0;
|
}
|
|
//保存
|
private void btnSave_Click(object sender, EventArgs e)
|
{
|
string txtLzk = this.txtLzk.Text;
|
if (txtLzk == "")
|
{
|
MessageBox.Show("流转卡没有扫描!");
|
}
|
else
|
{
|
//保存按钮灰掉
|
this.btnSave.Enabled = false;
|
string SelectTpye = this.cmbJYSelect.Text;
|
switch (SelectTpye)
|
{
|
case "首件检验单":
|
FistInspectionForm_Save();
|
break;
|
case "巡检检验单":
|
InspectionForm_Save();
|
break;
|
case "工序检验单":
|
FinalInspectionForm_Save();
|
break;
|
default:
|
MessageBox.Show("检验类型错误!");
|
break;
|
}
|
}
|
}
|
|
|
//判断流转卡对应的物料有没有检验方案
|
public void ShowData(string HNumber)
|
{
|
//清空网格内容
|
ListData.Items.Clear();
|
//清空表格内容
|
dataTable.Columns.Clear();
|
dataTable.Rows.Clear();
|
|
dataTable.Columns.Add("HQCSchemeID");
|
dataTable.Columns.Add("CharacteristicID");
|
dataTable.Columns.Add("HQCStd");
|
dataTable.Columns.Add("Actual");
|
dataTable.Columns.Add("HUpLimit");
|
dataTable.Columns.Add("HDownLimit");
|
dataTable.Columns.Add("HInspectInstruMentID");
|
dataTable.Columns.Add("HQCCheckItemHName");
|
|
|
//修改是在哪个设备上进行的数据采集 b.HInspectInstruMentID=1 三坐标1 轮廓仪2
|
DataSet dataSet = oCN.RunProcReturn(@"select b.HInspectInstruMentID,a.HInterID HQCSchemeID,b.HQCCheckItemID, ch.HNumber HQCCheckItemNumber,ch.HName HQCCheckItemHName,m.HNumber,HUpLimit,HDownLimit,HTargetVal
|
from Sc_ProcessExchangeBillMain pr with(nolock)
|
inner join Gy_QCCheckProjectMain a with(nolock) on pr.HMaterID=a.HMaterID
|
inner join Gy_QCCheckProjectSub b with(nolock) on a.HInterID=b.HInterID
|
inner join Gy_InspectInstruMent men with(nolock) on b.HInspectInstruMentID=men.HItemID and men.HNumber='" + HNumber + @"'
|
left join Gy_Material m with(nolock) on a.HMaterID=m.HItemID
|
left join Gy_QCCheckItem ch with(nolock) on b.HQCCheckItemID=ch.HItemID
|
where pr.HBillNo='" + this.txtLzk.Text + "'", "Gy_QCCheckProjectMain");
|
|
if (dataSet.Tables[0].Rows.Count == 0)
|
{
|
MessageBox.Show("当前流转卡对应的物料没有对应的检验方案!");
|
}
|
else
|
{
|
for (int j = 0; j < dataSet.Tables[0].Rows.Count; j++)
|
{
|
DataRow dr = dataTable.NewRow();
|
dr["HQCSchemeID"] = dataSet.Tables[0].Rows[j]["HQCSchemeID"].ToString();
|
dr["CharacteristicID"] = dataSet.Tables[0].Rows[j]["HQCCheckItemID"].ToString();
|
dr["HQCStd"] = dataSet.Tables[0].Rows[j]["HTargetVal"].ToString();
|
dr["Actual"] = "0";
|
dr["HUpLimit"] = dataSet.Tables[0].Rows[j]["HUpLimit"].ToString();
|
dr["HDownLimit"] = dataSet.Tables[0].Rows[j]["HDownLimit"].ToString();
|
dr["HInspectInstruMentID"] = dataSet.Tables[0].Rows[j]["HInspectInstruMentID"].ToString();
|
dr["HQCCheckItemHName"] = dataSet.Tables[0].Rows[j]["HQCCheckItemHName"].ToString();
|
string HQCCheckItemHName = dataSet.Tables[0].Rows[j]["HQCCheckItemHName"].ToString();
|
ListData.Items.Add("参数:" + HQCCheckItemHName + ",上限值:" + dataSet.Tables[0].Rows[j]["HUpLimit"].ToString() + ",下限值:" + dataSet.Tables[0].Rows[j]["HDownLimit"].ToString());
|
if (dr.ItemArray.Length > 0)
|
{
|
dataTable.Rows.Add(dr);
|
}
|
}
|
}
|
}
|
|
//首件检验单保存
|
public void FistInspectionForm_Save()
|
{
|
try
|
{
|
string HProcID = this.cmbPro.SelectedValue.ToString();
|
string sExeReturnInfo = "";
|
string BillType = "7505";
|
long HInterID = oCN.CreateBillID_Prod(BillType, ref sExeReturnInfo);
|
string HBillNo = oCN.CreateBillCode(BillType, ref sExeReturnInfo, true);
|
|
//判断当前流转卡对应的工序有没有开工
|
DataSet ds = oCN.RunProcReturn(@"select staus.HSourceID,a.HICMOInterID,a.HICMOEntryID,a.HICMOBillNo,a.HPlanQty,a.HInterID HProcExchInterID,
|
staus.HSourceEntryID HProcExchEntryID,a.HBillNo HProcExchBillNo,a.HQty,a.HMaterID
|
from Sc_ProcessExchangeBillMain a with(nolock)
|
inner join Sc_ICMOBillStatus_Tmp staus with(nolock) on a.HInterID=staus.HSourceInterID
|
where a.HBillNo='" + this.txtLzk.Text + "' and staus.HProcID=" + HProcID, "Sc_ProcessExchangeBillMain");
|
|
if (ds.Tables[0].Rows.Count == 0)
|
{
|
MessageBox.Show("当前工单没有开工数据!");
|
this.btnSave.Enabled = true;
|
}
|
else
|
{
|
string HSourceID = ds.Tables[0].Rows[0]["HSourceID"].ToString();
|
string HICMOInterID = ds.Tables[0].Rows[0]["HICMOInterID"].ToString();
|
string HICMOEntryID = ds.Tables[0].Rows[0]["HICMOEntryID"].ToString();
|
string HICMOBillNo = ds.Tables[0].Rows[0]["HICMOBillNo"].ToString();
|
string HPlanQty = ds.Tables[0].Rows[0]["HPlanQty"].ToString();
|
string HProcExchInterID = ds.Tables[0].Rows[0]["HProcExchInterID"].ToString();
|
string HProcExchEntryID = ds.Tables[0].Rows[0]["HProcExchEntryID"].ToString();
|
string HProcExchBillNo = ds.Tables[0].Rows[0]["HProcExchBillNo"].ToString();
|
string HQty = ds.Tables[0].Rows[0]["HQty"].ToString();
|
string HMaterID = ds.Tables[0].Rows[0]["HMaterID"].ToString();
|
string HQCSchemeID = dataTable.Rows[0]["HQCSchemeID"].ToString();
|
|
int HLastResults = 1;
|
|
oCN.BeginTran();
|
|
for (int i = 0; i < dataTable.Rows.Count; i++)
|
{
|
decimal HWeigh = decimal.Parse(dataTable.Rows[i]["Actual"].ToString());
|
decimal HUpLimits = decimal.Parse(dataTable.Rows[i]["HUpLimit"].ToString()) + decimal.Parse(dataTable.Rows[i]["HQCStd"].ToString());
|
decimal HDownLimits = decimal.Parse(dataTable.Rows[i]["HDownLimit"].ToString()) + decimal.Parse(dataTable.Rows[i]["HQCStd"].ToString());
|
int HLastResult = (HWeigh <= HUpLimits && HDownLimits <= HWeigh) ? 1 : 0;
|
|
if (HLastResult == 1 && HLastResults != 0)
|
{
|
HLastResults = 1;
|
}
|
else
|
{
|
HLastResults = 0;
|
}
|
//新增子表
|
oCN.RunProc("Insert into QC_FirstPieceCheckBillSub " +
|
" (HInterID,HBillNo_bak,HEntryID,HCloseMan" +
|
",HEntryCloseDate,HCloseType,HRemark,HSourceInterID" +
|
",HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
|
",HQCCheckItemID,HQCStd,HUnit,HQCNote,HResult" +
|
",HMax,HMin,HAvg,HSampleSchemeID,HSampleQty,HSampleDamageQty,HAcceptQty" +
|
",HRejectQty,HSampleUnRightQty,HStatus,HUnitID,HInspectVal,HTargetVal" +
|
",HUpLimit,HDownLimit,HUpOffSet,HDownOffSet,HKeyInspect,HAnalysisMethod,HInspectInstruMentID,HInspectResult" +
|
") values("
|
+ HInterID + ",'" + HBillNo + "'," + (i + 1) + ",''" +
|
",getdate(),0,''," + HProcExchInterID +
|
"," + HProcExchEntryID + ",'" + HProcExchBillNo + "','',0,0" +
|
"," + dataTable.Rows[i]["CharacteristicID"].ToString() + ",'" + dataTable.Rows[i]["HQCStd"].ToString() + "','','" + dataTable.Rows[i]["HQCStd"].ToString() + "','" + HLastResult + "'" +
|
",'" + dataTable.Rows[i]["HUpLimit"].ToString() + "','" + dataTable.Rows[i]["HDownLimit"].ToString() + "',''" + ",0,0,0,0,0,0,'',0,'" + HWeigh + "','" + dataTable.Rows[i]["HQCStd"].ToString() + "','" + dataTable.Rows[i]["HUpLimit"].ToString() + "','" + dataTable.Rows[i]["HDownLimit"].ToString() + "','','',0,'2'," + dataTable.Rows[i]["HInspectInstruMentID"].ToString() + ",'" + HLastResult + "'" +
|
") ");
|
}
|
|
string HMakeDate = DateTime.Now.ToString();
|
|
//主表
|
oCN.RunProc("Insert Into QC_FirstPieceCheckBillMain " +
|
"(HBillType,HBillSubType,HInterID,HBillNo,HBillStatus,HDate,HMaker,HMakeDate" +
|
",HYear,HPeriod,HRemark" +
|
",HSourceID,HICMOInterID,HICMOBillNo,HICMOQty,HProcExchInterID,HProcExchEntryID" +
|
",HProcExchBillNo,HProcExchQty,HMaterID,HFirstCheckEmp,HLastResult" +
|
",HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HMainSourceBillType,HICMOEntryID,HQCSchemeID,HShiftsID,HErrTreatment" +
|
",HTakeSampleCheckBillID,HTakeSampleCheckBillNo,HProcID" +
|
",HBatchNo) " +
|
" values('" + BillType + "','" + BillType + "'," + HInterID + ",'" + HBillNo + "',1,'" + HMakeDate + "','" + this.txtHMaker.Text + "',getdate()" +
|
"," + DateTime.Now.Year + "," + DateTime.Now.Month + ",''" +
|
"," + HSourceID + "," + HICMOInterID + ",'" + HICMOBillNo + "'," + HPlanQty + "," + HProcExchInterID + "," + HProcExchEntryID +
|
",'" + HProcExchBillNo + "'," + HQty + "," + HMaterID + ",'" + this.labHMakerID.Text + "', " + HLastResults +
|
"," + HProcExchInterID + "," + HProcExchEntryID + ",'" + HProcExchBillNo + "',''," + HICMOEntryID + "," + HQCSchemeID + ",0,''" +
|
",0,''," + HProcID + "" +
|
",'" + this.txtPcm.Text + "') ");
|
|
oCN.Commit();
|
|
MessageBox.Show("保存成功!");
|
|
}
|
}
|
catch (Exception e)
|
{
|
oCN.RollBack();
|
//保存按钮灰掉
|
this.btnSave.Enabled = true;
|
MessageBox.Show("保存失败!" + e.Message);
|
}
|
}
|
|
//巡检检验单保存
|
public void InspectionForm_Save()
|
{
|
try
|
{
|
string HProcID = this.cmbPro.SelectedValue.ToString();
|
string sExeReturnInfo = "";
|
string BillType = "7520";
|
long HInterID = oCN.CreateBillID_Prod(BillType, ref sExeReturnInfo);
|
string HBillNo = oCN.CreateBillCode(BillType, ref sExeReturnInfo, true);
|
|
//判断当前流转卡对应的工序有没有开工
|
DataSet ds = oCN.RunProcReturn(@"select staus.HSourceID,a.HICMOInterID,a.HICMOEntryID,a.HICMOBillNo,a.HPlanQty,a.HInterID HProcExchInterID,
|
staus.HSourceEntryID HProcExchEntryID,a.HBillNo HProcExchBillNo,a.HQty,a.HMaterID
|
from Sc_ProcessExchangeBillMain a with(nolock)
|
inner join Sc_ICMOBillStatus_Tmp staus with(nolock) on a.HInterID=staus.HSourceInterID
|
where a.HBillNo='" + this.txtLzk.Text + "' and staus.HProcID=" + HProcID, "Sc_ProcessExchangeBillMain");
|
|
if (ds.Tables[0].Rows.Count == 0)
|
{
|
MessageBox.Show("当前工单没有开工数据!");
|
this.btnSave.Enabled = true;
|
}
|
else
|
{
|
string HSourceID = ds.Tables[0].Rows[0]["HSourceID"].ToString();
|
string HICMOInterID = ds.Tables[0].Rows[0]["HICMOInterID"].ToString();
|
string HICMOEntryID = ds.Tables[0].Rows[0]["HICMOEntryID"].ToString();
|
string HICMOBillNo = ds.Tables[0].Rows[0]["HICMOBillNo"].ToString();
|
string HPlanQty = ds.Tables[0].Rows[0]["HPlanQty"].ToString();
|
string HProcExchInterID = ds.Tables[0].Rows[0]["HProcExchInterID"].ToString();
|
string HProcExchEntryID = ds.Tables[0].Rows[0]["HProcExchEntryID"].ToString();
|
string HProcExchBillNo = ds.Tables[0].Rows[0]["HProcExchBillNo"].ToString();
|
string HQty = ds.Tables[0].Rows[0]["HQty"].ToString();
|
string HMaterID = ds.Tables[0].Rows[0]["HMaterID"].ToString();
|
string HQCSchemeID = dataTable.Rows[0]["HQCSchemeID"].ToString();
|
int HLastResults = 1;
|
|
oCN.BeginTran();
|
|
for (int i = 0; i < dataTable.Rows.Count; i++)
|
{
|
decimal HWeigh = decimal.Parse(dataTable.Rows[i]["Actual"].ToString());
|
decimal HUpLimits = decimal.Parse(dataTable.Rows[i]["HUpLimit"].ToString()) + decimal.Parse(dataTable.Rows[i]["HQCStd"].ToString());
|
decimal HDownLimits = decimal.Parse(dataTable.Rows[i]["HDownLimit"].ToString()) + decimal.Parse(dataTable.Rows[i]["HQCStd"].ToString());
|
int HLastResult = (HWeigh <= HUpLimits && HDownLimits <= HWeigh) ? 1 : 0;
|
|
if (HLastResult == 1 && HLastResults != 0)
|
{
|
HLastResults = 1;
|
}
|
else
|
{
|
HLastResults = 0;
|
}
|
|
oCN.RunProc("Insert into QC_PatrolProcCheckOtherBillSub " +
|
" (HInterID,HBillNo_bak,HEntryID,HCloseMan" +
|
",HEntryCloseDate,HCloseType,HRemark,HSourceInterID" +
|
",HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
|
",HQCCheckItemID,HQCStd,HUnit,HQCNote,HResult" +
|
",HMax,HMin,HAvg,HSampleSchemeID,HSampleQty,HSampleDamageQty,HAcceptQty" +
|
",HRejectQty,HSampleUnRightQty,HStatus,HUnitID,HInspectVal,HTargetVal" +
|
",HUpLimit,HDownLimit,HUpOffSet,HDownOffSet,HKeyInspect,HAnalysisMethod,HInspectInstruMentID,HInspectResult" +
|
") values("
|
+ HInterID + ",'" + HBillNo + "'," + (i + 1) + ",''" +
|
",getdate(),0,''," + HProcExchInterID +
|
"," + HProcExchEntryID + ",'" + HProcExchBillNo + "','',0,0," + dataTable.Rows[i]["CharacteristicID"].ToString() + ",'" + dataTable.Rows[i]["HQCStd"].ToString() + "','','" + dataTable.Rows[i]["HQCStd"].ToString() + "','" + HLastResult + "'" +
|
",'" + dataTable.Rows[i]["HUpLimit"].ToString() + "','" + dataTable.Rows[i]["HDownLimit"].ToString() + "',''" + ",0,0,0,0,0,0,'',0,'" + HWeigh + "','" + dataTable.Rows[i]["HQCStd"].ToString() + "','" + dataTable.Rows[i]["HUpLimit"].ToString() + "','" + dataTable.Rows[i]["HDownLimit"].ToString() + "','','',0,'2'," + dataTable.Rows[i]["HInspectInstruMentID"].ToString() + ",'" + HLastResult + "'" + ") ");
|
}
|
|
string HMakeDate = DateTime.Now.ToString();
|
|
//主表
|
oCN.RunProc("Insert Into QC_PatrolProcCheckOtherBillMain " +
|
"(HBillType,HBillSubType,HInterID,HBillNo,HBillStatus,HDate,HMaker,HMakeDate" +
|
",HYear,HPeriod,HRemark" +
|
",HSourceID,HICMOInterID,HICMOBillNo,HICMOQty,HProcExchInterID,HProcExchEntryID" +
|
",HProcExchBillNo,HProcExchQty,HMaterID,HFirstCheckEmp,HLastResult" +
|
",HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HMainSourceBillType,HICMOEntryID,HQCSchemeID,HShiftsID,HErrTreatment" +
|
",HTakeSampleCheckBillID,HTakeSampleCheckBillNo,HProcID,HBatchNo) " +
|
" values('" + BillType + "','" + BillType + "'," + HInterID + ",'" + HBillNo + "',1,'" + HMakeDate + "','" + this.txtHMaker.Text + "',getdate()" +
|
"," + DateTime.Now.Year + "," + DateTime.Now.Month + ",''" +
|
"," + HSourceID + "," + HICMOInterID + ",'" + HICMOBillNo + "'," + HPlanQty + "," + HProcExchInterID + "," + HProcExchEntryID +
|
",'" + HProcExchBillNo + "'," + HQty + "," + HMaterID + ",'" + this.labHMakerID.Text + "', " + HLastResults +
|
"," + HProcExchInterID + "," + HProcExchEntryID + ",'" + HProcExchBillNo + "',''," + HICMOEntryID + "," + HQCSchemeID + ",0,''" +
|
",0,''," + HProcID + ",'" + this.txtPcm.Text + "') ");
|
|
oCN.Commit();
|
|
MessageBox.Show("保存成功!");
|
}
|
}
|
catch (Exception e)
|
{
|
oCN.RollBack();
|
MessageBox.Show("保存失败!" + e.Message);
|
}
|
}
|
|
//末检检验单
|
public void FinalInspectionForm_Save()
|
{
|
try
|
{
|
string HProcID = this.cmbPro.SelectedValue.ToString();
|
string sExeReturnInfo = "";
|
string BillType = "7507";
|
long HInterID = oCN.CreateBillID_Prod(BillType, ref sExeReturnInfo);
|
string HBillNo = oCN.CreateBillCode(BillType, ref sExeReturnInfo, true);
|
|
//判断当前流转卡对应的工序有没有开工
|
DataSet ds = oCN.RunProcReturn(@"select staus.HSourceID,a.HICMOInterID,a.HICMOEntryID,a.HICMOBillNo,a.HPlanQty,a.HInterID HProcExchInterID,
|
staus.HSourceEntryID HProcExchEntryID,a.HBillNo HProcExchBillNo,a.HQty,a.HMaterID,staus.HProcID
|
from Sc_ProcessExchangeBillMain a with(nolock)
|
inner join Sc_ICMOBillStatus_Tmp staus with(nolock) on a.HInterID=staus.HSourceInterID
|
where a.HBillNo='" + this.txtLzk.Text + "' and staus.HProcID=" + HProcID, "Sc_ProcessExchangeBillMain");
|
|
if (ds.Tables[0].Rows.Count == 0)
|
{
|
MessageBox.Show("当前工单没有开工数据!");
|
this.btnSave.Enabled = true;
|
}
|
else
|
{
|
string HSourceID = ds.Tables[0].Rows[0]["HSourceID"].ToString();
|
string HICMOInterID = ds.Tables[0].Rows[0]["HICMOInterID"].ToString();
|
string HICMOEntryID = ds.Tables[0].Rows[0]["HICMOEntryID"].ToString();
|
string HICMOBillNo = ds.Tables[0].Rows[0]["HICMOBillNo"].ToString();
|
string HPlanQty = ds.Tables[0].Rows[0]["HPlanQty"].ToString();
|
string HProcExchInterID = ds.Tables[0].Rows[0]["HProcExchInterID"].ToString();
|
string HProcExchEntryID = ds.Tables[0].Rows[0]["HProcExchEntryID"].ToString();
|
string HProcExchBillNo = ds.Tables[0].Rows[0]["HProcExchBillNo"].ToString();
|
string HQty = ds.Tables[0].Rows[0]["HQty"].ToString();
|
string HMaterID = ds.Tables[0].Rows[0]["HMaterID"].ToString();
|
HProcID = ds.Tables[0].Rows[0]["HProcID"].ToString();
|
string HQCSchemeID = dataTable.Rows[0]["HQCSchemeID"].ToString();
|
int HLastResults = 1;
|
|
|
oCN.BeginTran();
|
|
for (int i = 0; i < dataTable.Rows.Count; i++)
|
{
|
decimal HWeigh = decimal.Parse(dataTable.Rows[i]["Actual"].ToString());
|
decimal HUpLimits = decimal.Parse(dataTable.Rows[i]["HUpLimit"].ToString()) + decimal.Parse(dataTable.Rows[i]["HQCStd"].ToString());
|
decimal HDownLimits = decimal.Parse(dataTable.Rows[i]["HDownLimit"].ToString()) + decimal.Parse(dataTable.Rows[i]["HQCStd"].ToString());
|
int HLastResult = (HWeigh <= HUpLimits && HDownLimits <= HWeigh) ? 1 : 0;
|
|
if (HLastResult == 1 && HLastResults != 0)
|
{
|
HLastResults = 1;
|
}
|
else
|
{
|
HLastResults = 0;
|
}
|
|
oCN.RunProc("Insert into QC_ProcessCheckBillSub " +
|
" (HInterID,HBillNo_bak,HEntryID,HCloseMan" +
|
",HEntryCloseDate,HCloseType,HRemark,HSourceInterID" +
|
",HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
|
",HQCCheckClassID,HQCCheckItemID,HQCStd,HQCRelValue,HResult" +
|
",HProcCheckEmp,HProcCheckTime,HSampleSchemeID,HSampleQty,HSampleDamageQty,HAcceptQty" +
|
",HRejectQty,HSampleUnRightQty,HStatus,HUnitID,HInspectVal,HTargetVal" +
|
",HUpLimit,HDownLimit,HUpOffSet,HDownOffSet,HKeyInspect,HAnalysisMethod,HInspectInstruMentID,HInspectResult" +
|
",HQCNote) values("
|
+ HInterID + ",'" + HBillNo + "'," + (i + 1) + ",''" +
|
",getdate(),0,''," + HProcExchInterID +
|
"," + HProcExchEntryID + ",'" + HProcExchBillNo + "','',0,0,0," + dataTable.Rows[i]["CharacteristicID"].ToString() + ",'" + dataTable.Rows[i]["HQCStd"].ToString() + "','','" + HLastResult + "'" +
|
",0,'',0,0,0,0,0,0,'',0,'" + HWeigh + "','" + dataTable.Rows[i]["HQCStd"].ToString() + "','" + dataTable.Rows[i]["HUpLimit"].ToString() + "','" + dataTable.Rows[i]["HDownLimit"].ToString() +
|
"','','',0,'2'," + dataTable.Rows[i]["HInspectInstruMentID"].ToString() + ",'" + HLastResult + "'" +
|
",'" + dataTable.Rows[i]["HQCStd"].ToString() + "') ");
|
}
|
|
string HMakeDate = DateTime.Now.ToString();
|
|
//主表
|
oCN.RunProc("Insert Into QC_ProcessCheckBillMain " +
|
"(HBillType,HBillSubType,HInterID,HBillNo,HBillStatus,HDate,HMaker,HMakeDate" +
|
",HYear,HPeriod,HRemark" +
|
",HICMOInterID,HICMOBillNo,HProcExchInterID,HProcExchEntryID,HProcExchBillNo" +
|
",HMaterID,HProcID,HSourceID,HEmpID,HInStockQty" +
|
",HCheckQty,HRightQty,HBadQty,HFirstCheckEmp,HLastResult" +
|
",HBarCode,HLBatchNo,HCusID,HSortBillNo,HContrctBatchNo" +
|
",HProdAreaID,HProdTypeID,HProdStoveNo,HRecipeID,HDiameter1" +
|
",HDiameter2,HRoutingInterID,HDrawingDireID,HPackTypeID" +
|
",HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HMainSourceBillType,HICMOEntryID,HQCSchemeID,HICMOQty" +
|
",HProcExchQty,HShiftsID,HErrTreatment" +
|
",HTakeSampleCheckBillID,HTakeSampleCheckBillNo" +
|
",HBatchNo,HCheckerResult) " +
|
" values('" + BillType + "','" + BillType + "'," + HInterID + ",'" + HBillNo + "',1,'" + HMakeDate + "','" + this.txtHMaker.Text + "',getdate()" +
|
"," + DateTime.Now.Year + "," + DateTime.Now.Month + ",''" +
|
"," + HICMOInterID + ",'" + HICMOBillNo + "'," + HProcExchInterID + "," + HProcExchEntryID + ",'" + HProcExchBillNo + "'" +
|
"," + HMaterID + "," + HProcID + "," + HSourceID + ",0,0,0,0,0," + this.labHMakerID.Text + ",'" + HLastResults + "'" +
|
",'','',0,'',''" +
|
",0,0,'',0,0,0,0,'',0," + HProcExchInterID + "," + HProcExchEntryID + ",'" + HProcExchBillNo + "',''," + HICMOEntryID + "," + HQCSchemeID + "," + HPlanQty + "," + HQty + ",0,''" +
|
",0,''" +
|
",'" + this.txtPcm.Text + "','" + HLastResults + "') ");
|
|
|
oCN.Commit();
|
|
MessageBox.Show("保存成功!");
|
}
|
}
|
catch (Exception e)
|
{
|
oCN.RollBack();
|
MessageBox.Show("保存失败!" + e.Message);
|
}
|
}
|
|
private void btnAfterSelect_Click(object sender, EventArgs e)
|
{
|
|
}
|
//更换用户
|
private void btnHMaker_Click(object sender, EventArgs e)
|
{
|
this.txtHMaker.Text = "";
|
this.txtHMaker.ReadOnly = false;
|
this.txtHMakerNumber.Text = "";
|
this.labHMakerID.Text = "0";
|
}
|
|
private void ZZ_GlueWeigh_FormClosing(object sender, FormClosingEventArgs e)
|
{
|
if (MessageBox.Show("确定要关闭吗?", "确认", MessageBoxButtons.YesNo) == DialogResult.No)
|
{
|
e.Cancel = true;
|
}
|
}
|
|
private void ZZ_GlueWeigh_Activated(object sender, EventArgs e)
|
{
|
//光标选中制单人
|
this.txtHMaker.Focus();
|
}
|
}
|
}
|