Exemple #1
0
        private void tvwAccountList_AfterCheck(object sender, TreeViewEventArgs e)
        {
            ClearInfo();
            if (e.Node.Tag == null)
            {
                return;
            }
            accountBook    = new List <PrivyAccountBook>();
            notAccountBook = new List <PrivyAccountBook>();

            this.tvwAccountList.AfterCheck  -= new TreeViewEventHandler(tvwAccountList_AfterCheck);
            this.tvwAccountList.SelectedNode = e.Node;
            _currentAccountBook = (PrivyAccountBook)e.Node.Tag;
            accountBook.Clear();
            //设置子节点是否勾选
            SetNodeChecked(this.tvwAccountList.SelectedNode, this.tvwAccountList.SelectedNode.Checked);
            //勾已交款的节点把未交款节点全改为false,反之
            bool b = GetParent(this.tvwAccountList.SelectedNode);

            //得到勾选的节点的ID
            GetNode(this.tvwAccountList.Nodes, b);
            if (b == true)
            {
                CollectAccountBook totalBook = AccountBookController.CollectAllAccountBook(accountBook);
                ShowAccountBook(totalBook);
            }
            else
            {
                CollectAccountBook totalBook1 = AccountBookController.CollectAllAccountBook(notAccountBook);
                ShowAccountBook(totalBook1);
            }
            this.tvwAccountList.AfterCheck += new TreeViewEventHandler(tvwAccountList_AfterCheck);
        }
Exemple #2
0
        private void ShowTotalInfo()
        {
            int selectedchargeUserId = 0;

            DataTable tbHandIn = AccountBookController.GetAccountList(dtpFrom.Value, dtpEnd.Value);

            List <PrivyAccountBook> lstAllBooks = new List <PrivyAccountBook>();

            #region 得到缴款员
            Hashtable htCharge = new Hashtable();
            for (int i = 0; i < tbHandIn.Rows.Count; i++)
            {
                int chargeUserId = Convert.ToInt32(tbHandIn.Rows[i]["AccountCode"]);
                if (!htCharge.ContainsKey(chargeUserId))
                {
                    htCharge.Add(chargeUserId, chargeUserId);
                }
            }
            #endregion

            #region 生成账单明细,并合并
            foreach (object obj in htCharge)
            {
                int       chargeUserId  = Convert.ToInt32(((DictionaryEntry)obj).Value);
                DataRow[] drsAccount    = tbHandIn.Select("ACCOUNTCODE=" + chargeUserId, "ACCOUNTDATE asc");
                int[]     accountIdList = new int[drsAccount.Length];
                for (int i = 0; i < drsAccount.Length; i++)
                {
                    accountIdList[i] = Convert.ToInt32(drsAccount[i]["ACCOUNTID"]);
                }
                DataTable tbInvoice;
                DataTable tbInvoiceDetail;
                AccountBookController.GetAccountData(chargeUserId, accountIdList, out tbInvoice, out tbInvoiceDetail);
                //个人所有账单
                List <PrivyAccountBook> lstBook = new List <PrivyAccountBook>();

                for (int i = 0; i < drsAccount.Length; i++)
                {
                    int accountId         = Convert.ToInt32(drsAccount[i]["ACCOUNTID"]);
                    PrivyAccountBook book = AccountBookController.GetPrivyAccountBook(chargeUserId, accountId, tbInvoice, tbInvoiceDetail, tbHandIn);
                    lstBook.Add(book);
                }

                PrivyAccountBook totalBook = AccountBookController.CollectPrivyAccountBook(lstBook);

                lstAllBooks.Add(totalBook);
            }
            #endregion

            CollectAccountBook allBook = AccountBookController.CollectAllAccountBook(lstAllBooks);

            List <FundInfo> lstFundInfo = new List <FundInfo>();
            if (allBook.TallyPart.Details != null)
            {
                for (int i = 0; i < allBook.TallyPart.Details.Length; i++)
                {
                    lstFundInfo.Add(allBook.TallyPart.Details[i]);
                }
            }

            FundInfo fdFavor = new FundInfo();
            fdFavor.Money   = allBook.FavorPart.TotalMoney;
            fdFavor.PayName = "优惠金额";
            lstFundInfo.Add(fdFavor);

            FundInfo fdCash = new FundInfo();
            fdCash.Money   = allBook.CashPart.TotalMoney;
            fdCash.PayName = "实收现金";
            lstFundInfo.Add(fdCash);



            FundInfo[] allInfo = lstFundInfo.ToArray();

            DataTable tbTotalInfo = new DataTable();
            for (int i = 0; i < 10; i++)
            {
                DataColumn col = new DataColumn();
                col.ColumnName = "C_" + i.ToString();
                tbTotalInfo.Columns.Add(col);
            }

            int colIndex = 0;
            tbTotalInfo.Rows.Add(tbTotalInfo.NewRow());
            int rowIndex = tbTotalInfo.Rows.Count - 1;
            //记账
            for (int i = 0; i < allInfo.Length; i++)
            {
                if (colIndex == 10)
                {
                    tbTotalInfo.Rows.Add(tbTotalInfo.NewRow());
                    rowIndex = tbTotalInfo.Rows.Count - 1;
                    colIndex = 0;
                }

                tbTotalInfo.Rows[rowIndex][colIndex]     = allInfo[i].PayName;
                tbTotalInfo.Rows[rowIndex][colIndex + 1] = allInfo[i].Money;
                colIndex = colIndex + 2;
            }
            dgvTotalInfo.Tag = allInfo;
            tbTotalInfo.Columns.Add("C_EMPTY");
            tbTotalInfo.Rows[tbTotalInfo.Rows.Count - 1]["C_EMPTY"] = "合计:" + allBook.InvoiceItemSumTotal.ToString();
            dgvTotalInfo.DataSource = tbTotalInfo;
            dgvTotalInfo.Columns[dgvTotalInfo.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

            for (int i = 0; i < dgvTotalInfo.Columns.Count; i++)
            {
                if (i % 2 == 1)
                {
                    dgvTotalInfo.Columns[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                }
                else
                {
                    dgvTotalInfo.Columns[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                }
            }
        }