Exemple #1
0
        private void FormAccVoucher_Load(object sender, EventArgs e)
        {
            SetupBindingSource();
            var HRAdapter       = new VoucherExpense.DamaiDataSetTableAdapters.HRTableAdapter();
            var operatorAdapter = new VoucherExpense.DamaiDataSetTableAdapters.OperatorTableAdapter();
            var accTitleAdapter = new VoucherExpense.DamaiDataSetTableAdapters.AccountingTitleTableAdapter();

            operatorAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg);
            accTitleAdapter.Connection.ConnectionString = DB.SqlConnectString(MyFunction.HardwareCfg);
            HRAdapter.Fill(m_DataSet.HR);
            operatorAdapter.Fill(m_DataSet.Operator);
            accTitleAdapter.Fill(m_DataSet.AccountingTitle);
            accVoucherAdapter.Fill(m_DataSet.AccVoucher);

            dateTimePicker1.MaxDate = new DateTime(MyFunction.IntHeaderYear, 12, 31);
            dateTimePicker1.MinDate = new DateTime(MyFunction.IntHeaderYear, 1, 1);

            if (CheckMode)
            {
                this.Text = "傳票查核";
                blockEdit();
                columnCheck.ReadOnly   = false;  // DataGridView裏的columnCheck
                ckBoxAllowEdit.Visible = true;
            }
            else
            {
                ckBoxAllowEdit.Visible = false;
            }

            if (MyFunction.LockAll)
            {
                blockEdit();
                ckBoxAllowEdit.Visible = false;
            }
        }
Exemple #2
0
        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("資料庫讀取錯誤!");
            }
        }