private void Ingredient_Load(object sender, EventArgs e) { IngredientBindingSource.DataSource = m_DataSet; vendorBindingSource.DataSource = m_DataSet; accountingTitleBindingSource.DataSource = m_DataSet; m_PhotoDirectoryExist = Directory.Exists(PhotoPath()); photoPictureBox.Visible = true; var vendorAdapter = new DamaiDataSetTableAdapters.VendorTableAdapter(); var accountingTitleAdapter = new DamaiDataSetTableAdapters.AccountingTitleTableAdapter(); IngredientAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); vendorAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); PhotoAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); accountingTitleAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); try { vendorAdapter.Fill(m_DataSet.Vendor); m_VendorList.Add(new CNameIDForComboBox(0, "")); // 提到 .Fill(vEdataSet.Ingredient)之前,要不然第一次 BindingSource.CurrentChanged會先發生 foreach (var vendor in m_DataSet.Vendor) { m_VendorList.Add(new CNameIDForComboBox(vendor.VendorID, vendor.Name)); } vendorIDComboBox.DataSource = m_VendorList; //vendorIDComboBox.ValueMember = "ID"; //vendorIDComboBox.DisplayMember = "Name"; accountingTitleAdapter.Fill(m_DataSet.AccountingTitle); IngredientAdapter.Fill(m_DataSet.Ingredient); } catch (Exception ex) { MessageBox.Show("錯誤:" + ex.Message); } MyFunction.SetFieldLength(dgvIngredient, m_DataSet.Ingredient); MyFunction.SetControlLengthFromDB(this, m_DataSet.Ingredient); }
private void FormLedgerNew_Load(object sender, EventArgs e) { var bankAccountAdapter = new DamaiDataSetTableAdapters.BankAccountTableAdapter(); var accTitleAdapter = new DamaiDataSetTableAdapters.AccountingTitleTableAdapter(); var accVouchAdapter = new DamaiDataSetTableAdapters.AccVouchTableAdapter(); var accVouchDetailAdapter = new DamaiDataSetTableAdapters.AccVouchDetailTableAdapter(); accTitleAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); try { bankAccountAdapter.Fill(damaiDataSet.BankAccount); accTitleAdapter.Fill(damaiDataSet.AccountingTitle); accVouchAdapter.Fill(damaiDataSet.AccVouch); accVouchDetailAdapter.Fill(damaiDataSet.AccVouchDetail); dgvCLedgerTable.Focus(); } catch (Exception ex) { MessageBox.Show("資料庫讀取錯誤! 原因:" + ex.Message); } // 設置comboBoxAccTitle的初值為 <零用金> if (damaiDataSet.BankAccount.Rows.Count > 1) { var bank = damaiDataSet.BankAccount[0]; if (bank.IsAccountTitleCodeNull()) { comboBoxAccTitle.SelectedIndex = 0; } else { comboBoxAccTitle.SelectedValue = bank.AccountTitleCode; } } DontRefresh = false; // Form剛Load不Refresh DataGridView }
private void FormLedger_Load(object sender, EventArgs e) { accountingTitleBindingSource.DataSource = m_DataSet; m_OrderSet = m_DataSet; try { headerAdapter.Fill(m_DataSet.Header); } catch { MessageBox.Show("標頭資料讀取錯誤,你的資料庫版本可能不對"); } int count = m_DataSet.Header.Count; if (count == 0) { MessageBox.Show("無資料!"); Close(); return; } var row = m_DataSet.Header[count - 1]; m_Revenue = new RevenueCalcBakery(row.DataDate, 0); AccList.NewAll(); var accTitleAdapter = new DamaiDataSetTableAdapters.AccountingTitleTableAdapter(); var bankAccountAdapter = new DamaiDataSetTableAdapters.BankAccountTableAdapter(); var expenseAdapter = new DamaiDataSetTableAdapters.ExpenseTableAdapter(); var voucherAdapter = new DamaiDataSetTableAdapters.VoucherTableAdapter(); var voucherDetailAdapter = new DamaiDataSetTableAdapters.VoucherDetailTableAdapter(); var bankDetailAdapter = new DamaiDataSetTableAdapters.BankDetailTableAdapter(); var accVoucherAdapter = new DamaiDataSetTableAdapters.AccVoucherTableAdapter(); var vendorAdapter = new DamaiDataSetTableAdapters.VendorTableAdapter(); var ingredientAdapter = new DamaiDataSetTableAdapters.IngredientTableAdapter(); try { ingredientAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); accTitleAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); vendorAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); accTitleAdapter.Fill(m_DataSet.AccountingTitle); bankAccountAdapter.Fill(m_DataSet.BankAccount); expenseAdapter.Fill(m_DataSet.Expense); // expense檔案小,先全部讀進記憶體 voucherAdapter.Fill(m_DataSet.Voucher); voucherDetailAdapter.Fill(m_DataSet.VoucherDetail); bankDetailAdapter.Fill(m_DataSet.BankDetail); accVoucherAdapter.Fill(m_DataSet.AccVoucher); vendorAdapter.Fill(m_DataSet.Vendor); ingredientAdapter.Fill(m_DataSet.Ingredient); foreach (var r in m_DataSet.AccountingTitle) { AccTitle item = new AccTitle(r.TitleCode, r.Name); if (r.IsInitialValueNull()) { item.Money = 0; } else { item.Money = r.InitialValue; } if (r.TitleCode.Length == 0) { continue; } AccList.Add(item); } AccList1.CopyTableFrom(AccList); Setup.Load(); m_Generator = new LedgerTableGenerator(labelMessage, Setup, m_DataSet, new CalcRevenueDelegate(CalcRevenue)); cLedgerTableDataGridView.Focus(); } catch (Exception ex) { MessageBox.Show("資料庫讀取錯誤! 原因:" + ex.Message); } // 設置comboBoxAccTitle的初值為 <零用金> if (m_DataSet.BankAccount.Rows.Count > 1) { var bank = m_DataSet.BankAccount[0]; if (bank.IsAccountTitleCodeNull()) { comboBoxAccTitle.SelectedIndex = 0; } else { comboBoxAccTitle.SelectedValue = bank.AccountTitleCode; } } DontRefresh = false; // Form剛Load不Refresh DataGridView }