void LoadUnfilledData() { if (cbxLaborNumber.SelectedIndex != -1) { DatabaseSet.工時DataTable table = 工時TableAdapter.Instance.GetFilledDataBy員工編號(cbxLaborNumber.SelectedValue.ToString()); DateTime from = Settings.UnfilledDate; DateTime to = DateTime.Today; for (DateTime date = from; date <= to; date = date.AddDays(1)) { if (!假日TableAdapter.Instance.IsHoliday(_holidayTable, date)) { if (date != dtpDate.Value) { DataRow[] rows = table.Select("日期 = #" + date.ToString("yyyy/MM/dd") + "#"); if (rows.Length == 0) { llbUnfilledTip.Text = date.ToString("yyyy/MM/dd") + "的資料尚未填寫完畢"; llbUnfilledTip.Tag = date; llbUnfilledTip.Visible = true; return; } } } } llbUnfilledTip.Visible = false; } }
private void llbNGTip_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { try { if (e.Button == MouseButtons.Left) { NGTipForm form = new NGTipForm(); if (form.ShowDialog(this, this.NGTable, _remainHours, this.TodayIsHoliday) == DialogResult.OK) { DatabaseSet.工時Row row = form.DataRow; string replace = row["取代編號"].ToString(); if (_dataTable.Select("取代編號 = '" + replace + "'").Length > 0) { throw new SWLHMSException("此筆重驗資料已存在"); } DatabaseSet.工時Row newRow = _dataTable.New工時Row(); //MessageBox.Show("工時資料編號 " + form.SelectedHourDataID); // Check the borrow line string borrower = null; if (ckbBorrowLine.Checked) { if (cbbBorrowLine.SelectedIndex == -1) { throw new SWLHMSException("請選擇借入產線"); } borrower = (string)this.cbbBorrowLine.SelectedItem; } // hour type HourType hourType = (HourType)cbxHourType.SelectedIndex; newRow["品號"] = row["品號"]; newRow["取代編號"] = row["取代編號"]; newRow.FillRow(this.SelectedLaborNumber, dtpDate.Value, row["工作單號"].ToString(), (decimal)row["工時"], (int)row["待驗數量"], borrower, row["QCN"].ToString(), (int)row["工品編號"], hourType); newRow.新舊 = "*"; newRow["工時類型名稱"] = hourType.ToString(); _dataTable.Rows.Add(newRow); dgvHoursData.AutoResizeColumns(); UpdateRemainHour(); UpdateRemainAmount(); } } } catch (Exception ex) { Global.ShowError(ex); } }
private void btnStore_Click(object sender, EventArgs e) { try { if (_remainHours > 0 && !this.TodayIsHoliday) { if (MessageBox.Show("尚有時數未填寫完畢,確定要儲存嗎?", "儲存提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel) { return; } } //SetFinishDate(); //重驗後的工時資料刪除時進行復原工作 int update = 0; DatabaseSet.工時DataTable table = (DatabaseSet.工時DataTable)_dataTable.Copy(); foreach (DataRow row in _dataTable) { if (row.RowState == DataRowState.Deleted) { string id = (string)row["編號", DataRowVersion.Original]; update += 工時TableAdapter.Instance.DeleteEx(id); } } foreach (DataRow row in table.Select(null, null, DataViewRowState.Deleted)) { row.AcceptChanges(); } update += 工時TableAdapter.Instance.Update(table); int reinspect; int qa = UpdateQATable(out reinspect); UpdateFinishDate(); string msg = "更新了 " + update + " 筆資料"; if (qa > 0) { msg += "\n新增了 " + qa + " 筆待驗資料"; } if (reinspect > 0) { msg += "\n重新送驗了 " + reinspect + "筆資料"; } MessageBox.Show(msg); UpdateRemainAmount(); LoadOldHourData(); LoadNGData(); } catch (Exception ex) { //MessageBox.Show(ex.Message); Global.ShowError(ex); } }