|
|
@@ -27,6 +27,8 @@ namespace UAS_MES_NEW.OQC
|
|
|
DataTable TempForCheckType = new DataTable();
|
|
|
|
|
|
string ErrorMessage = "";
|
|
|
+ Timer uncheckBatchTimer;
|
|
|
+ bool loadingUncheckBatches;
|
|
|
|
|
|
public OQC_SamplingDataCollection()
|
|
|
{
|
|
|
@@ -38,11 +40,114 @@ namespace UAS_MES_NEW.OQC
|
|
|
asc.controllInitializeSize(this);
|
|
|
BaseUtil.SetDgvColumnComboxData((DataGridViewComboBoxColumn)CheckTypeDGV.Columns["oi_leveldefect"], "oi_leveldefect", "display", "value", LevelDefect);
|
|
|
dh = SystemInf.dh;
|
|
|
+ checkTab.SelectedIndexChanged += checkTab_SelectedIndexChanged;
|
|
|
+ uncheckBatchTimer = new Timer();
|
|
|
+ uncheckBatchTimer.Interval = 60000;
|
|
|
+ uncheckBatchTimer.Tick += uncheckBatchTimer_Tick;
|
|
|
+ uncheckBatchTimer.Start();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void uncheckBatchTimer_Tick(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ LoadUncheckBatches();
|
|
|
}
|
|
|
|
|
|
private void 抽样数据采集_SizeChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
asc.controlAutoSize(this);
|
|
|
+ FixCheckTabLayout();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void FixCheckTabLayout()
|
|
|
+ {
|
|
|
+ if (ob_checkno.Left <= 0 || ob_makecode.Top <= 0 || WaitChooseDGV.Left <= 0 || sncode.Top <= 0)
|
|
|
+ return;
|
|
|
+
|
|
|
+ int left = ob_checkno.Left * 21 / 127;
|
|
|
+ int top = ob_makecode.Bottom + ob_makecode.Top * 25 / 164;
|
|
|
+ int width = WaitChooseDGV.Left - WaitChooseDGV.Left * 19 / 629 - left;
|
|
|
+ int height = sncode.Top - sncode.Top * 39 / 668 - top;
|
|
|
+ if (width < 200)
|
|
|
+ width = 200;
|
|
|
+ if (height < 160)
|
|
|
+ height = 160;
|
|
|
+ checkTab.SetBounds(left, top, width, height);
|
|
|
+
|
|
|
+ Rectangle area = checkTab.DisplayRectangle;
|
|
|
+ pageCheck.SetBounds(area.X, area.Y, area.Width, area.Height);
|
|
|
+ pageBatch.SetBounds(area.X, area.Y, area.Width, area.Height);
|
|
|
+ CheckTypeDGV.Dock = DockStyle.Fill;
|
|
|
+ UncheckBatchDGV.Dock = DockStyle.Fill;
|
|
|
+ FitUncheckBatchColumns();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkTab_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ if (checkTab.SelectedTab == pageBatch)
|
|
|
+ FitUncheckBatchColumns();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void FitUncheckBatchColumns()
|
|
|
+ {
|
|
|
+ DataGridViewColumn[] cols = { colMakeCode, colCheckNo, colSpec, colSnCode, colStatus };
|
|
|
+ int[] weights = { 16, 16, 28, 28, 12 };
|
|
|
+ int available = UncheckBatchDGV.ClientSize.Width;
|
|
|
+ if (available < 50)
|
|
|
+ available = pageBatch.ClientSize.Width - pageBatch.Padding.Horizontal;
|
|
|
+ available -= 4;
|
|
|
+ if (available < 200)
|
|
|
+ return;
|
|
|
+
|
|
|
+ UncheckBatchDGV.AllowUserToResizeColumns = true;
|
|
|
+ UncheckBatchDGV.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;
|
|
|
+ int used = 0;
|
|
|
+ for (int i = 0; i < cols.Length; i++)
|
|
|
+ {
|
|
|
+ cols[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
|
|
|
+ cols[i].Resizable = DataGridViewTriState.True;
|
|
|
+ int width = available * weights[i] / 100;
|
|
|
+ if (i == cols.Length - 1)
|
|
|
+ width = available - used;
|
|
|
+ if (width < cols[i].MinimumWidth)
|
|
|
+ width = cols[i].MinimumWidth;
|
|
|
+ cols[i].Width = width;
|
|
|
+ used += cols[i].Width;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void LoadUncheckBatches()
|
|
|
+ {
|
|
|
+ if (dh == null || loadingUncheckBatches)
|
|
|
+ return;
|
|
|
+ string makeCode = ob_makecode.Text.Trim();
|
|
|
+ string checkNo = ob_checkno.Text.Trim();
|
|
|
+ if (makeCode == "" || checkNo == "")
|
|
|
+ {
|
|
|
+ UncheckBatchDGV.DataSource = null;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ loadingUncheckBatches = true;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ //DataTable batchDt = (DataTable)dh.ExecuteSql(@"SELECT a.ob_makecode, a.ob_checkno, b.pr_spec, c.ois_sncode,
|
|
|
+ // CASE WHEN a.ob_status = 'UNCHECK' THEN '未检验' WHEN a.ob_status = 'CHECKING' THEN '检验中' END status
|
|
|
+ // FROM oqcbatch a LEFT JOIN product b ON a.ob_prodcode = b.pr_code LEFT JOIN
|
|
|
+ // ( SELECT ois_makecode, ois_checkno, ois_sncode FROM oqcitemsamples GROUP BY ois_makecode, ois_checkno, ois_sncode) c
|
|
|
+ // ON a.ob_makecode = c.ois_makecode AND a.ob_checkno = c.ois_checkno
|
|
|
+ // WHERE a.ob_status IN ( 'UNCHECK', 'CHECKING' ) AND a.ob_indate >= sysdate - 30
|
|
|
+ // ORDER BY a.ob_indate DESC", "select");
|
|
|
+
|
|
|
+ DataTable batchDt = (DataTable)dh.ExecuteSql(@"SELECT a.ob_makecode, a.ob_checkno, b.pr_spec,
|
|
|
+ CASE WHEN a.ob_status = 'UNCHECK' THEN '未检验' WHEN a.ob_status = 'CHECKING' THEN '检验中' END status
|
|
|
+ FROM oqcbatch a LEFT JOIN product b ON a.ob_prodcode = b.pr_code WHERE a.ob_status IN( 'UNCHECK', 'CHECKING')
|
|
|
+ AND a.ob_indate >= sysdate - 30 ORDER BY a.ob_indate DESC", "select");
|
|
|
+ UncheckBatchDGV.DataSource = batchDt;
|
|
|
+ FitUncheckBatchColumns();
|
|
|
+ }
|
|
|
+ finally
|
|
|
+ {
|
|
|
+ loadingUncheckBatches = false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void GetBatch_Click(object sender, EventArgs e)
|
|
|
@@ -121,8 +226,7 @@ namespace UAS_MES_NEW.OQC
|
|
|
{
|
|
|
Confirm_Click(sender, e);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+ LoadUncheckBatches();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -547,6 +651,11 @@ namespace UAS_MES_NEW.OQC
|
|
|
|
|
|
private void OQC_SamplingDataCollection_FormClosing(object sender, FormClosingEventArgs e)
|
|
|
{
|
|
|
+ if (uncheckBatchTimer != null)
|
|
|
+ {
|
|
|
+ uncheckBatchTimer.Stop();
|
|
|
+ uncheckBatchTimer.Dispose();
|
|
|
+ }
|
|
|
dh.Dispose();
|
|
|
}
|
|
|
|