private void View_Transaction(object sender, RoutedEventArgs e) { string idBill = this.Textbox_Search.Text; if (CollectBillDAO.Instance.CheckIfExistBillID(idBill) == true) { IsWithdrawBill = false; CollectBill bill = CollectBillDAO.Instance.GetBill(idBill); Passbook passbook = PassbookDAO.Instance.GetAccount(bill.Collect_passbook); Customer customerInfo = CustomerDAO.Instance.GetCustomer(passbook.Passbook_customer); //update form this.TextBox_CustomerID.Text = customerInfo.Id.ToString(); this.TextBox_CustomerIDcard.Text = customerInfo.Cmnd.ToString(); this.TextBox_CustomerName.Text = customerInfo.Cus_name.ToString(); this.TextBox_CustomerAddress.Text = customerInfo.Cus_address.ToString(); this.TextBox_SavingBookID.Text = passbook.Id.ToString(); this.TextBox_Money.Text = bill.Collect_money.ToString(); this.Calender.SelectedDate = bill.Collectdate; this.Combobox_Type.Items.Clear(); this.Combobox_Type.Items.Add(TypePassbookDAO.Instance.GetTypeNameByID(passbook.Passbooktype)); this.Combobox_Type.SelectedIndex = 0; HintAssist.SetHint(this.TextBox_Money, "Số tiền gởi"); } else if (WithdrawBillDAO.Instance.CheckIfExistBillID(idBill) == true) { IsWithdrawBill = true; WithdrawBill bill = WithdrawBillDAO.Instance.GetBill(idBill); Passbook passbook = PassbookDAO.Instance.GetAccount(bill.Withdraw_passbook); Customer customerInfo = CustomerDAO.Instance.GetCustomer(passbook.Passbook_customer); //update form this.TextBox_CustomerID.Text = customerInfo.Id.ToString(); this.TextBox_CustomerIDcard.Text = customerInfo.Cmnd.ToString(); this.TextBox_CustomerName.Text = customerInfo.Cus_name.ToString(); this.TextBox_CustomerAddress.Text = customerInfo.Cus_address.ToString(); this.TextBox_SavingBookID.Text = passbook.Id.ToString(); this.TextBox_Money.Text = bill.Withdrawmoney.ToString(); this.Calender.SelectedDate = bill.Withdrawdate; this.Combobox_Type.Items.Clear(); this.Combobox_Type.Items.Add(TypePassbookDAO.Instance.GetTypeNameByID(passbook.Passbooktype)); this.Combobox_Type.SelectedIndex = 0; HintAssist.SetHint(this.TextBox_Money, "Số tiền rút"); } else { MessageBoxCustom.setContent("Không tìm thấy mã giao dịch này.").ShowDialog(); } #endregion }
private void BtnWithdraw_click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(this.Money.Text)) { MessageBoxCustom.setContent("Thiếu thông tin phiếu gởi!").ShowDialog(); return; } else { if (PassbookDAO.Instance.GetWithdrawday(int.Parse(this.Txt_PassbookID.Text.ToString())) <= this.DatePicker_Time.SelectedDate) { if ((this.Cb_TypePassbook.SelectedItem as TypePassbook).Typename != "Không kì hạn") { if (MessageBoxCustom.setContent("Ngày hoàn thành kì hạn chưa tới, Quý Khách có muốn rút?").ShowDialog() == true) { Clearall(); return; } } } else { MessageBoxCustom.setContent("Chưa đến được rút, thời hạn rút tiền là 15 ngày").ShowDialog(); Clearall(); return; } WithdrawBill bill = new WithdrawBill { Id = 1.ToString().Trim(), Withdraw_passbook = int.Parse(this.Txt_PassbookID.Text.ToString()), Withdrawmoney = long.Parse(this.Money.Text.ToString()), Withdrawdate = this.DatePicker_Time.SelectedDate ?? DateTime.Now }; WithdrawBillDAO.Instance.InsertWithdrawBill(bill); int id = int.Parse(this.Txt_PassbookID.Text); MessageBoxCustom.setContent("Tạo phiếu rút thành công! Số dư còn lại là: " + PassbookDAO.Instance.GetBalancebyIDPassbook(id).ToString()).ShowDialog(); this.Balance.Text = "Số dư:" + PassbookDAO.Instance.GetBalancebyIDPassbook(id).ToString(); Clearall(); } }