private void cbbWorksheetNubmerS_SelectedValueChanged(object sender, EventArgs e) { try { if (cbbWorksheetNubmerS.Text != string.Empty) { DatabaseSet.工作單DataTable wsTable = 工作單TableAdapter.Instance.GetBy單號(cbbWorksheetNubmerS.Text); if (wsTable.Count == 0) { throw new SWLHMSException("工作單號 " + cbbWorksheetNubmerS.Text + " 不存在"); } if (dtpDate.Value < wsTable[0].單據日期 || (!Convert.IsDBNull(wsTable[0]["實際完成日"]) && dtpDate.Value >= wsTable[0].實際完成日)) { throw new SWLHMSException("工作單在 " + dtpDate.Value.ToString("yyyy/MM/dd") + " 未開始或已結束"); } DataTable table = 工作單品號TableAdapter.Instance.GetBy單號(cbbWorksheetNubmerS.Text); table.Columns.Add(new DataColumn("Display", typeof(string), "'#'+編號+'-'+品號")); bsPart.DataSource = table; cbbPart.DisplayMember = "Display"; lbPartCount.Text = "共 " + table.Rows.Count + " 筆品號資料"; } } catch (Exception ex) { bsPart.DataSource = null; lbPartCount.Text = ex.Message; } }
private void btnSearchWorksheet_Click(object sender, EventArgs e) { try { if (cbbWorksheetNubmerS.Text != string.Empty) { DatabaseSet.工作單DataTable wsTable = 工作單TableAdapter.Instance.GetBy單號(cbbWorksheetNubmerS.Text); if (wsTable.Count == 0) { throw new SWLHMSException("工作單號 " + cbbWorksheetNubmerS.Text + " 不存在"); } if (dtpDate.Value < wsTable[0].單據日期 || (!Convert.IsDBNull(wsTable[0]["實際完成日"]) && dtpDate.Value > wsTable[0].實際完成日)) { throw new SWLHMSException("工作單在 " + dtpDate.Value.ToString("yyyy/MM/dd") + " 未開始或已結束"); } DataTable table = 工作單品號TableAdapter.Instance.GetBy單號(cbbWorksheetNubmerS.Text); bsPart.DataSource = table; cbbPart.DisplayMember = "品號"; lbPartCount.Text = "共 " + table.Rows.Count + " 筆品號資料"; } } catch (Exception ex) { bsPart.DataSource = null; lbPartCount.Text = ex.Message; } }
protected override void WriteHeader() { int rptWidth = _table.Columns.Count; int row = 1; DatabaseSet.工作單DataTable wsTable = 工作單TableAdapter.Instance.GetBy單號(_worksheetNo); DatabaseSet.工作單Row wsRow = (DatabaseSet.工作單Row)wsTable.Rows[0]; Range range; range = this.SheetAdapter.GetRange(row, 1, row, rptWidth); range.MergeCells = true; range.HorizontalAlignment = XlHAlign.xlHAlignCenter; this.SheetAdapter[range] = "安天德百電股份有限公司(ITW Electronic Business Asia Co.,Ltd.)"; row++; range = this.SheetAdapter.GetRange(row, 1, row, rptWidth); range.MergeCells = true; range.Font.Size = 15; range.Font.Bold = true; range.HorizontalAlignment = XlHAlign.xlHAlignCenter; this.SheetAdapter[range] = "製 造 部 訂 料 通 知 單"; row++; range = this.SheetAdapter.GetRange(row, 1, row, rptWidth); range.MergeCells = true; range.HorizontalAlignment = XlHAlign.xlHAlignCenter; this.SheetAdapter[range] = "* * * * * * * * * * * * * * * *"; row++; //string line = DatabaseSet.GetLineByWorksheetNo(_worksheetNo); //DatabaseSet.產線DataTable lineTable = 產線TableAdapter.Instance.GetDataByLine(line); //DatabaseSet.產線Row lineRow = (DatabaseSet.產線Row)lineTable.Rows[0]; //this.SheetAdapter[row, 1] = "協 力 廠: " + lineRow.代號; this.SheetAdapter[row, 1] = "協 力 廠: " + _gangerName; range = this.SheetAdapter.GetRange(row, rptWidth - 1); range.HorizontalAlignment = XlHAlign.xlHAlignRight; this.SheetAdapter[range] = "日期: "; range = this.SheetAdapter.GetRange(row, rptWidth); range.HorizontalAlignment = XlHAlign.xlHAlignLeft; this.SheetAdapter[range] = wsRow.單據日期.ToString("yyyy/MM/dd"); row++; range = this.SheetAdapter.GetRange(row, rptWidth - 1); range.HorizontalAlignment = XlHAlign.xlHAlignRight; this.SheetAdapter[range] = "編號: "; range = this.SheetAdapter.GetRange(row, rptWidth); range.NumberFormat = "0"; range.HorizontalAlignment = XlHAlign.xlHAlignLeft; this.SheetAdapter[range] = wsRow.單號; row++; base.WriteHeader(); }
public void EditWorksheet(string WorksheetNumber) { if ((_worksheetTable = 工作單TableAdapter.Instance.GetBy單號(WorksheetNumber)).Count > 0) { bsWorksheet.DataSource = _worksheetTable[0]; tbxWorksheetNumber.ReadOnly = true; tbxWorksheetNumber.DataBindings.Add("Text", bsWorksheet, "單號", true, DataSourceUpdateMode.Never); //tbxCustomerName.DataBindings.Add("Text", bsWorksheet, "客戶名稱", true, DataSourceUpdateMode.OnPropertyChanged); dtpBegin.DataBindings.Add("Value", bsWorksheet, "單據日期", true, DataSourceUpdateMode.OnPropertyChanged); dtpEnd.DataBindings.Add("Value", bsWorksheet, "實際完成日", true, DataSourceUpdateMode.Never, DateTime.Today); //dtpCustomerNeed.DataBindings.Add("Value", bsWorksheet, "客戶需貨日", true, DataSourceUpdateMode.OnPropertyChanged); //dtpEstimate.DataBindings.Add("Value", bsWorksheet, "預計完成日", true, DataSourceUpdateMode.OnPropertyChanged); if (_worksheetTable[0]["實際完成日"] != DBNull.Value) { ckbEnd.Checked = true; } _worksheetPartTable = 工作單品號TableAdapter.Instance.GetBy單號(_worksheetTable[0].單號); bsWorksheetPart.DataSource = _worksheetPartTable; //判斷目前工作單所屬產線 if (_worksheetPartTable.Count > 0) { DatabaseSet.產品品號DataTable tmpTable = 產品品號TableAdapter.Instance.GetBy品號(_worksheetPartTable[0].品號); if (tmpTable.Count > 0) { _curWorkshhetLine = tmpTable[0].產線; } else { throw new SWLHMSException("找不到品號 " + _worksheetPartTable[0].品號 + " 的資料"); } } btnAddWorksheet.Visible = false; } else { throw new SWLHMSException("找不到單號 " + WorksheetNumber + " 的資料"); } }
public virtual DatabaseSet.工作單DataTable GetBy單號(string 單號) { this.Adapter.SelectCommand = this.CommandCollection[1]; if ((單號 == null)) { throw new global::System.ArgumentNullException("單號"); } else { this.Adapter.SelectCommand.Parameters[0].Value = ((string)(單號)); } DatabaseSet.工作單DataTable dataTable = new DatabaseSet.工作單DataTable(); this.Adapter.Fill(dataTable); return dataTable; }
public virtual DatabaseSet.工作單DataTable GetData() { this.Adapter.SelectCommand = this.CommandCollection[0]; DatabaseSet.工作單DataTable dataTable = new DatabaseSet.工作單DataTable(); this.Adapter.Fill(dataTable); return dataTable; }