void cboUser_SelectedIndexChanged(object sender, EventArgs e) { DataTable tb = AccountBookController.GetAccountHandInDate(Convert.ToInt32(cboUser.SelectedValue)); DataTable tbDate = new DataTable( ); tbDate.Columns.Add("AccountId", Type.GetType("System.Int32")); tbDate.Columns.Add("AccountDate", Type.GetType("System.String")); DataRow drCurrent = tbDate.NewRow( ); drCurrent["AccountId"] = 0; drCurrent["AccountDate"] = "<当前未交>"; tbDate.Rows.Add(drCurrent); foreach (DataRow dr in tb.Rows) { DataRow drOld = tbDate.NewRow( ); drOld["AccountId"] = dr[0]; drOld["AccountDate"] = Convert.ToDateTime(dr[1]).ToString("yyyy-MM-dd HH:mm:ss"); tbDate.Rows.Add(drOld); } cboAccountDate.DisplayMember = "AccountDate"; cboAccountDate.ValueMember = "AccountId"; cboAccountDate.DataSource = tbDate; cboAccountDate_SelectedIndexChanged(null, null); }
void cboAccountDate_SelectedIndexChanged(object sender, EventArgs e) { int accountId = Convert.ToInt32(cboAccountDate.SelectedValue); if (accountId == 0 && Convert.ToInt32(currentUser.EmployeeID) == Convert.ToInt32(cboUser.SelectedValue)) { btnHandIn.Enabled = true; btnPrint.Enabled = false; } else { btnHandIn.Enabled = false; btnPrint.Enabled = true; } ClearInfo( ); PrivyAccountBook book; if (currentUser.IsAdministrator) { book = AccountBookController.GetPrivyAccountBook(Convert.ToInt32(cboUser.SelectedValue), accountId); } else { book = AccountBookController.GetPrivyAccountBook(Convert.ToInt32(currentUser.EmployeeID), accountId); } this.Tag = book; if (book != null) { ShowAccountBook(book); } }
private void btnHandIn_Click(object sender, EventArgs e) { try { if (this.Tag != null) { bool ret = AccountBookController.HandInAccount(Convert.ToInt32(currentUser.EmployeeID), (PrivyAccountBook)this.Tag); if (ret == true) { MessageBox.Show("交款完成,请及时打印交款单!"); cboUser_SelectedIndexChanged(null, null); } else { MessageBox.Show("交款不成功!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("没有需要交款的数据!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception err) { MessageBox.Show(err.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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); }
public FrmAccoutStatItem(int AccountId, int TollerId, DateTime AccountDate, string Toller) { InitializeComponent( ); accountDate = AccountDate; toller = Toller; DataTable tbStatItem = AccountBookController.GetAccountStatItemList(AccountId, TollerId); FormatData(tbStatItem); }
private void CreateTreeList() { int selectedchargeUserId = 0; if (chkChargeUser.Checked) { selectedchargeUserId = Convert.ToInt32(cboChargeUser.SelectedValue); } tvwAccountList.Nodes.Clear( ); DataTable tbHandIn = AccountBookController.GetAccountList(dtpFrom.Value, dtpTo.Value); TreeNode tdHandIn = new TreeNode( ); tdHandIn.Text = "已交款"; List <PrivyAccountBook> lstAllBooks = new List <PrivyAccountBook>( ); #region 构造交款员树 for (int i = 0; i < tbHandIn.Rows.Count; i++) { int chargeUserId = Convert.ToInt32(tbHandIn.Rows[i]["AccountCode"]); if (chkChargeUser.Checked && chargeUserId != selectedchargeUserId) { continue; } if (tdHandIn.Nodes.Count == 0) { TreeNode ndUser = new TreeNode( ); ndUser.Text = BaseDataController.GetName(BaseDataCatalog.人员列表, chargeUserId); ndUser.Tag = chargeUserId; tdHandIn.Nodes.Add(ndUser); } else { bool hasIntree = false; foreach (TreeNode nd in tdHandIn.Nodes) { if (Convert.ToInt32(nd.Tag) == chargeUserId) { hasIntree = true; break; } } if (!hasIntree) { TreeNode ndUser = new TreeNode( ); ndUser.Text = BaseDataController.GetName(BaseDataCatalog.人员列表, chargeUserId); ndUser.Tag = chargeUserId; tdHandIn.Nodes.Add(ndUser); } } } #endregion #region 生成账单明细,并合并 foreach (TreeNode ndUser in tdHandIn.Nodes) { int chargeUserId = Convert.ToInt32(ndUser.Tag); 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++) { TreeNode ndDate = new TreeNode( ); ndDate.Text = Convert.ToDateTime(drsAccount[i]["ACCOUNTDATE"]).ToString("yyyy-MM-dd HH:mm:ss"); int accountId = Convert.ToInt32(drsAccount[i]["ACCOUNTID"]); PrivyAccountBook book = AccountBookController.GetPrivyAccountBook(chargeUserId, accountId, tbInvoice, tbInvoiceDetail, tbHandIn); ndDate.Tag = book; ndUser.Nodes.Add(ndDate); lstBook.Add(book); } //PrivyAccountBook totalBook = AccountBookController.CollectPrivyAccountBook( lstBook ); ndUser.Tag = new PrivyAccountBook(); //lstAllBooks.Add( totalBook ); } #endregion tvwAccountList.Nodes.Add(tdHandIn); //CollectAccountBook allBook = AccountBookController.CollectAllAccountBook( lstAllBooks ); tdHandIn.Tag = new PrivyAccountBook(); DataTable tbUnHandIn = AccountBookController.GetNotHandInAccountUser( ); TreeNode ndUnHandIn = new TreeNode( ); List <PrivyAccountBook> lstAllnothandBook = new List <PrivyAccountBook>( ); ndUnHandIn.Text = "未交款"; for (int i = 0; i < tbUnHandIn.Rows.Count; i++) { TreeNode ndUnhandInUser = new TreeNode( ); ndUnhandInUser.Text = tbUnHandIn.Rows[i]["CHARGENAME"].ToString().Trim(); int chargeUserId = Convert.ToInt32(tbUnHandIn.Rows[i]["CHARGECODE"]); if (chkChargeUser.Checked && chargeUserId != selectedchargeUserId) { continue; } //PrivyAccountBook book = AccountBookController.GetPrivyAccountBook( chargeUserId , 0 ); ndUnhandInUser.Tag = new PrivyAccountBook(); ndUnHandIn.Nodes.Add(ndUnhandInUser); // lstAllnothandBook.Add( book ); } tvwAccountList.Nodes.Add(ndUnHandIn); //CollectAccountBook notHandBook = AccountBookController.CollectAllAccountBook( lstAllnothandBook ); ndUnHandIn.Tag = new PrivyAccountBook(); tvwAccountList.ExpandAll( ); }
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; } } }