//private void MakeBankAccountComboBox() //{ // BankAccountAdapter.Fill(this.m_DataSet.BankAccount); // List<CBankAccountForComboBox> list = new List<CBankAccountForComboBox>(); // CBankAccountForComboBox acc = new CBankAccountForComboBox(); // list.Add(acc); // foreach (var r in m_DataSet.BankAccount) // { // if (r.ID != 1) // ID 1是給零用金的特殊帳號 // { // acc = new CBankAccountForComboBox(); // acc.Name = r.ShowName; // acc.ID = r.ID; // list.Add(acc); // } // } // cbBankAccount.DataSource = list; //} private void FormImportBankExcel_Load(object sender, EventArgs e) { string[] names = null; if (openFileDialog1.ShowDialog() != DialogResult.OK) { m_CloseForm = true; return; } m_FileName = openFileDialog1.FileName; try { excel = new ExcelLib(); names = excel.SheetNames(m_FileName); if (names == null || names.Length < 1) { MessageBox.Show("找不到<" + m_FileName + ">!"); m_CloseForm = true; return; } cbSheetNames.Items.Clear(); foreach (string name in names) { cbSheetNames.Items.Add(name); } } catch { MessageBox.Show("轉換Excel表過程出錯! 是否沒有安裝Excel或 Microsoft.Office.Interop.Excel.dll不存在!"); m_CloseForm = true; } var bankAccountAdapter = new VoucherExpense.DamaiDataSetTableAdapters.BankAccountTableAdapter(); // MakeBankAccountComboBox(); bankAccountAdapter.Fill(this.m_DataSet.BankAccount); List <CBankAccountForComboBox> list = new List <CBankAccountForComboBox>(); CBankAccountForComboBox acc = new CBankAccountForComboBox(); list.Add(acc); foreach (var r in m_DataSet.BankAccount) { if (r.ID != 1) // ID 1是給零用金的特殊帳號 { acc = new CBankAccountForComboBox(); acc.Name = r.ShowName; acc.ID = r.ID; list.Add(acc); } } cbBankAccount.DataSource = list; }
private void FormBankDetail_Load(object sender, EventArgs e) { SetupBindingSource(); var bankAccountAdapter = new VoucherExpense.DamaiDataSetTableAdapters.BankAccountTableAdapter(); var accountingTitleAdapter = new VoucherExpense.DamaiDataSetTableAdapters.AccountingTitleTableAdapter(); accountingTitleAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); bankAccountAdapter.Fill(m_DataSet.BankAccount); accountingTitleAdapter.Fill(m_DataSet.AccountingTitle); bankDetailAdapter.Fill(m_DataSet.BankDetail); //accountingTitleBindingSource.Filter = // "(TitleCode like '1*' or TitleCode like '2*')"; //int btm = bankDetailBindingNavigator.Bottom + 5; //dgvBankDetail.Top = btm - Top; //dgvBankDetail.Height = Height - dgvBankDetail.Top - 5; calendar.MaxDate = new DateTime(MyFunction.IntHeaderYear, 12, 31); calendar.MinDate = new DateTime(MyFunction.IntHeaderYear, 1, 1); MakeBankAccountComboBox(); List <AccTitle> AssetList = new List <AccTitle>(); foreach (var r in m_DataSet.AccountingTitle) { if (r.TitleCode.Length == 0) { continue; } AccTitle item = new AccTitle(r.TitleCode, r.Name); if (r.IsInitialValueNull()) { item.Money = 0; } else { item.Money = r.InitialValue; } char c = r.TitleCode[0]; if (c == '1') { AssetList.Add(item); } } foreach (var r in m_DataSet.BankAccount) { BankDictionary.Add(r.ID, new BankDefault(r.AccountTitleCode, r.DefaultTitleCode)); } AccTitle defaultAsset = Find(Setup.DefaultAsset, AssetList, null); foreach (KeyValuePair <int, BankDefault> pair in BankDictionary) { BankDefault bank = pair.Value; bank.DefaultTitle = Find(bank.DefaultCode, AssetList, defaultAsset); AccTitle title = Find(bank.BankCode, AssetList, defaultAsset); if (title != null) { bank.InitialValue = title.Money; } } if (cbSelectBank.Items.Count > 1) { cbSelectBank.SelectedIndex = cbSelectBank.Items.Count - 1; } if (MyFunction.LockAll) { dgvBankDetail.ReadOnly = true; } }
private void Expense_Load(object sender, EventArgs e) { SetupBindingSource(); var bankAccountAdapter = new VoucherExpense.DamaiDataSetTableAdapters.BankAccountTableAdapter(); var operatorAdapter = new VoucherExpense.DamaiDataSetTableAdapters.OperatorTableAdapter(); var accTitleAdapter = new VoucherExpense.DamaiDataSetTableAdapters.AccountingTitleTableAdapter(); var HRAdapter = new VoucherExpense.DamaiDataSetTableAdapters.HRTableAdapter(); operatorAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); accTitleAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); bankAccountAdapter.Fill(m_DataSet.BankAccount); operatorAdapter.Fill(m_DataSet.Operator); accTitleAdapter.Fill(m_DataSet.AccountingTitle); HRAdapter.Fill(m_DataSet.HR); expenseAdapter.Fill(m_DataSet.Expense); MyFunction.SetControlLengthFromDB(this, m_DataSet.Expense); if (checkMode) { this.Text = "查核費用"; blockEdit(); expenseDataGridView.Columns["columnCheck"].ReadOnly = false; ckBoxAllowEdit.Visible = true; } else { ckBoxAllowEdit.Visible = false; } if (!零用金mode) { bankAccountIDComboBox.Visible = true; labelBank.Visible = true; cbSelectBank.Enabled = true; } cbSelectBank.Items.Clear(); cbSelectBank.Items.Add("全部"); foreach (var r in m_DataSet.BankAccount) { cbSelectBank.Items.Add(r.ShowName); } // 資料準備好,再加上EventHandler this.cbSelectBank.SelectedIndexChanged += new System.EventHandler(this.cbSelectBank_SelectedIndexChanged); if (cbSelectBank.Items.Count > 1) { cbSelectBank.SelectedIndex = 1; } comboBoxMonth.SelectedIndex = DateTime.Now.Month; if (MyFunction.LockAll) { blockEdit(); ckBoxAllowEdit.Visible = false; } // comboBoxMonth.SelectedIndex = DateTime.Now.Month; dateTimePicker1.MaxDate = new DateTime(MyFunction.IntHeaderYear, 12, 31); dateTimePicker1.MinDate = new DateTime(MyFunction.IntHeaderYear, 1, 1); }
private void ReportByTitle_Load(object sender, EventArgs e) { var headerAdapter = new MyHeaderAdapter(); m_OrderSet = m_DataSet; var accTitleAdapter = new VoucherExpense.DamaiDataSetTableAdapters.AccountingTitleTableAdapter(); var bankAccountAdapter = new VoucherExpense.DamaiDataSetTableAdapters.BankAccountTableAdapter(); var expenseAdapter = new VoucherExpense.DamaiDataSetTableAdapters.ExpenseTableAdapter(); var voucherAdapter = new VoucherExpense.DamaiDataSetTableAdapters.VoucherTableAdapter(); var voucherDetailAdapter = new VoucherExpense.DamaiDataSetTableAdapters.VoucherDetailTableAdapter(); var bankDetailAdapter = new VoucherExpense.DamaiDataSetTableAdapters.BankDetailTableAdapter(); var accVoucherAdapter = new VoucherExpense.DamaiDataSetTableAdapters.AccVoucherTableAdapter(); accTitleAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg); try { headerAdapter.Fill(m_OrderSet.Header); } catch { MessageBox.Show("標頭資料讀取錯誤,你的資料庫版本可能不對"); } int count = m_OrderSet.Header.Count; if (count == 0) { MessageBox.Show("無資料!"); Close(); return; } var row = m_OrderSet.Header[count - 1]; Revenue = new RevenueCalcBakery(row.DataDate, 0); AccList.NewAll(); BankDictionary = new Dictionary <int, BankDefault>(); RevenueCache = new MonthlyReportData[12]; MonthBalances = new CMonthBalance[13]; for (int i = 0; i < 13; i++) { MonthBalances[i] = new CMonthBalance(); MonthBalances[i].Month = i + 1; } MonthBalances[12].Month = 0; // 第13月統計用 cMonthBalanceBindingSource.DataSource = MonthBalances; string[] Name = new string[6] { "資產", "負債", "收入", "成本", "費用", "股東權益" }; comboBox1.Items.Clear(); comboBox2.Items.Clear(); foreach (string str in Name) { comboBox1.Items.Add(str); comboBox2.Items.Add(str); } try { 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); 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); foreach (var r in m_DataSet.BankAccount) { BankDictionary.Add(r.ID, new BankDefault(r.AccountTitleCode, r.DefaultTitleCode)); } comboBox1.SelectedIndex = 0; comboBox2.SelectedIndex = 1; comboBoxStart.SelectedIndex = MyFunction.IntHeaderMonth; Setup.Load(); dataGridView1.Focus(); } catch { MessageBox.Show("資料庫讀取錯誤!"); } }