Exemplo n.º 1
0
        private void BtnPrint_Click(object sender, RoutedEventArgs e)
        {
            string name = "Bill" + WithdrawBillDAO.Instance.GetLastBillID() + ".png";

            CaptureUIElement.Instance.SaveFrameworkElementToPng(Panel_Bill, (int)Panel_Bill.ActualWidth, (int)Panel_Bill.ActualHeight, name);
            MessageBoxCustom.setContent("phiếu lưu tại: " + System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)).ShowDialog();
        }
        private void Update_Transaction(object sender, RoutedEventArgs e)
        {
            //cap nhat giao dich
            if (!string.IsNullOrEmpty(TextBox_SavingBookID.Text.Trim()))
            {
                string idBill = TextBox_SavingBookID.Text.Trim();

                if (CollectBillDAO.Instance.CheckIfExistBillID(idBill) == true)
                {
                    //update
                }
                else if (WithdrawBillDAO.Instance.CheckIfExistBillID(idBill) == true)
                {
                    //update
                }
            }
            //cap nhat khach hang
            if (!string.IsNullOrEmpty(this.TextBox_CustomerID.Text.Trim()))
            {
                try
                {
                    Customer cus = new Customer
                    {
                        Id          = int.Parse(this.TextBox_CustomerID.Text),
                        Cus_name    = this.TextBox_CustomerName.Text.Trim(),
                        Cmnd        = this.TextBox_CustomerIDcard.Text.Trim(),
                        Cus_address = this.TextBox_CustomerAddress.Text.Trim()
                    };
                    CustomerDAO.Instance.UpdateCustomer(cus);
                    MessageBoxCustom.setContent("Sửa thông tin khách hàng thành công").ShowDialog();
                }
                catch { MessageBoxCustom.setContent("Trùng số CMND hoặc số CMND quá 9 kí tự").ShowDialog(); }
            }
        }
Exemplo n.º 3
0
 private void BtnSMoney_Click(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrEmpty(this.Money.Text))
     {
         MessageBoxCustom.setContent("Người dùng nhập thiếu dữ liệu").ShowDialog();
         return;
     }
     else
     {
         if (CollectBillDAO.Instance.CheckCollectMoney(long.Parse(this.Money.Text.ToString()), (this.Cb_TypePassbook.SelectedItem as TypePassbook).Typename))
         {
             MessageBoxCustom.setContent("Số tiên gởi không hợp lê").ShowDialog();
             Clearall();
             return;
         }
         if (CollectBillDAO.Instance.CheckCollectdate(this.DatePicker_Time.SelectedDate, int.Parse(Txt_PassbookID.Text.ToString())))
         {
             MessageBoxCustom.setContent("Chưa đến ngày đáo hạn sổ, Ngày đáo hạn là: " + (PassbookDAO.Instance.GetWithdrawday(int.Parse(this.Txt_PassbookID.Text.ToString()))).Value.ToString("dd/MM/yyyy")).ShowDialog();
             return;
         }
         CollectBill bill = new CollectBill
         {
             Id = 1.ToString().Trim(),
             Collect_passbook = int.Parse(Txt_PassbookID.Text),
             Collect_money    = long.Parse(Money.Text),
             Collectdate      = this.DatePicker_Time.SelectedDate ?? DateTime.Now
         };
         CollectBillDAO.Instance.InsertCollectBill(bill);
         MessageBoxCustom.setContent("Thêm phiếu gởi thành công").ShowDialog();
         Clearall();
     }
 }
Exemplo n.º 4
0
        private void Txt_CustomerID_LostFocus(object sender, RoutedEventArgs e)
        {
            int customerID;

            if (int.TryParse(this.Txt_CustomerID.Text, out customerID) == true)
            {
                customerID = int.Parse(this.Txt_CustomerID.Text);
                bool exist_ID = CustomerDAO.Instance.CheckExistID(customerID);
                if (exist_ID)
                {
                    this.TextBox_warning_1.Visibility = Visibility.Collapsed;
                    this.Txt_CustomerName.Text        = CustomerDAO.Instance.GetCustomerName(customerID);
                    this.Txt_CustomerCard.Text        = CustomerDAO.Instance.GetCustomerCardNumber(customerID);
                    this.Txt_CustomerAddress.Text     = CustomerDAO.Instance.GetCustomerAddress(customerID);
                    this.Money.Clear();
                    this.Txt_PassbookID.Clear();
                    this.Cb_TypePassbook.ItemsSource = null;
                    this.Cb_TypePassbook.Items.Clear();
                    this.Cb_TypePassbook.ItemsSource       = TypePassbookDAO.Instance.GetListTypeByCusID(customerID);
                    this.Cb_TypePassbook.DisplayMemberPath = "Typename";
                }
                else
                {
                    this.TextBox_warning_1.Visibility = Visibility.Visible;
                    MessageBoxCustom.setContent("Mã khách hàng này không tồn tại!").ShowDialog();
                    this.Txt_CustomerID.Clear();
                }
            }
        }
 private void TextBox_CardID_LostFocus(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrEmpty(this.TextBox_CardID.Text))
     {
         return;
     }
     else
     {
         if (this.TextBox_CardID.Text.Length == 9)
         {
             if (IsNumber(this.TextBox_CardID.Text))
             {
                 if (CustomerDAO.Instance.CheckCardIDexist(this.TextBox_CardID.Text))
                 {
                     return;
                 }
                 else
                 {
                     MessageBoxCustom.setContent("Số CMND đã tồn tại. Vui lòng nhập lại").ShowDialog();
                     this.TextBox_CardID.Clear();
                     return;
                 }
             }
         }
         MessageBoxCustom.setContent("Số CMND chưa đúng, Vui lòng nhập lại").ShowDialog();
         this.TextBox_CardID.Clear();
     }
 }
Exemplo n.º 6
0
        private void Add_Type(object sender, RoutedEventArgs e)
        {
            TypePassbook type = new TypePassbook
            {
                Min_passbookblance = int.Parse(this.TextBox_MinBalanceMoney.Text),
                Interest_rate      = float.Parse(this.TextBox_InterestRate.Text) / 100
            };

            if (this.RadioButton_Noterm.IsChecked == true)
            {
                type.Term         = 0;
                type.Withdrawterm = int.Parse(this.TextBox_MinWithdrawDay.Text.ToString());
            }
            else
            {
                type.Term = int.Parse(this.TextBox_Term.Text);
            }
            type.Min_collectmoney = int.Parse(this.TextBox_MinCollectMoney.Text);
            try { TypePassbookDAO.Instance.InsertType(type); }
            catch { MessageBoxCustom.setContent("Trùng loại tiết kiệm").ShowDialog(); }
            SetReadOnly(true);
            enableRadioButton(false);
            this.TextBox_Term.IsReadOnly = true;
            ShowTreeItem();
        }
 private void Delete_Transaction(object sender, RoutedEventArgs e)
 {
     if (MessageBoxCustom.setContent("bạn muốn xóa giao dịch này?").ShowDialog() == true)
     {
         //cap nhat giao dich
         ClearPage();
     }
 }
        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
        }
Exemplo n.º 9
0
 private void Delete_type(object sender, RoutedEventArgs e)
 {
     if (MessageBoxCustom.setContent("Bạn thực sự muốn xóa loại tiết kiệm này?").ShowDialog() == true)
     {
         if (this.ListView_TransactionType.Items.Count > 0)
         {
             TypePassbook typepassbook = (TypePassbook)(this.ListView_TransactionType.SelectedItem as ListViewItem).Tag;
             if (!TypePassbookDAO.Instance.CheckIfExistActivePassbookInType(typepassbook.Id))
             {
                 TypePassbookDAO.Instance.DeleteType(typepassbook.Id);
                 ShowTreeItem();
             }
             else
             {
                 MessageBoxCustom.setContent("Loại tiết kiệm này vẫn còn sổ mở").ShowDialog();
             }
         }
     }
 }
Exemplo n.º 10
0
        private void BtnSearch_Click(object sender, RoutedEventArgs e)
        {
            int customerID;

            if (int.TryParse(this.Txt_CustomerID.Text, out customerID) == true)
            {
                customerID = int.Parse(this.Txt_CustomerID.Text);
                bool exist_ID = CustomerDAO.Instance.CheckExistID(customerID);
                if (exist_ID)
                {
                    this.Txt_CustomerName.Text        = CustomerDAO.Instance.GetCustomerName(customerID);
                    this.Txt_CustomerCard.Text        = CustomerDAO.Instance.GetCustomerCardNumber(customerID);
                    this.Txt_CustomerAddress.Text     = CustomerDAO.Instance.GetCustomerAddress(customerID);
                    this.DatePicker_Time.SelectedDate = DateTime.Now;
                }
                else
                {
                    MessageBoxCustom.setContent("CustomerID is not available").ShowDialog();
                }
            }
        }
Exemplo n.º 11
0
 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();
     }
 }
        //check if the customer has had an account type before, if not, create new passbook, if yes, show messagebox warning
        private void Button_OpenPassbook(object sender, RoutedEventArgs e)
        {
            int      IDcustomer = int.Parse(this.TextBox_CustomerID.Text);
            Customer customer   = new Customer
            {
                Cus_address = TextBox_Address.Text.Trim(),
                Cus_name    = TextBox_CustomerName.Text.Trim(),
                Cmnd        = TextBox_CardID.Text.Trim()
            };

            if (this.RadioButton_NewCustomer.IsChecked == true)
            {
                if (string.IsNullOrEmpty(customer.Cus_name) || string.IsNullOrEmpty(customer.Cmnd))
                {
                    MessageBoxCustom.setContent("Chưa điền đầy đủ thông tin khách hàng");
                    return;
                }
                if (PassbookDAO.Instance.CheckBalance(long.Parse(this.TextBox_Money.Text.ToString()), (this.Combobox_TypePassbook.SelectedItem as TypePassbook).Typename))
                {
                    MessageBoxCustom.setContent("Số tiền gởi ban đầu không hợp lệ ").ShowDialog();
                    Clearall();
                    this.TextBox_CustomerID.Text = (CustomerDAO.Instance.GetCurrentMaxCustomerID() + 1).ToString();
                    return;
                }
                CustomerDAO.Instance.InsertCustomer(customer);
            }
            int? idType = (this.Combobox_TypePassbook.SelectedItem as TypePassbook).Id;
            bool Check  = CustomerDAO.Instance.CheckCustomerHasAccountType(IDcustomer, idType);

            if (!Check) //cus dont have any active passbook of this kind
            {
                if (idType != null)
                {
                    Passbook pass = new Passbook
                    {
                        Passbook_customer = IDcustomer,
                        Opendate          = this.DatePicker_DateOpen.SelectedDate ?? DateTime.Now,
                        Passbooktype      = idType ?? -1,
                        Passbook_balance  = 0
                    };
                    PassbookDAO.Instance.InsertPassbook(pass);
                    CollectBill bill = new CollectBill
                    {
                        Id = 1.ToString(),
                        Collect_passbook = int.Parse(this.TextBox_PassbookID.Text.ToString()),
                        Collect_money    = long.Parse(this.TextBox_Money.Text.ToString()),
                        Collectdate      = this.DatePicker_DateOpen.SelectedDate ?? DateTime.Now
                    };
                    CollectBillDAO.Instance.InsertCollectBill(bill);
                    MessageBoxCustom.setContent("Thêm sổ thành công").ShowDialog();
                    Clearall();
                    this.TextBox_PassbookID.Text = (PassbookDAO.Instance.GetMaxID() + 1).ToString();
                    this.TextBox_Money.Clear();
                    if (this.RadioButton_NewCustomer.IsChecked == true)
                    {
                        this.TextBox_CustomerID.Text = (CustomerDAO.Instance.GetCurrentMaxCustomerID() + 1).ToString();
                    }
                }
            }
            else
            {
                MessageBoxCustom.setContent("Lỗi, khách hàng này đã có tài khoản thuộc loại " + (this.Combobox_TypePassbook.SelectedItem as TypePassbook).Typename + " còn thời hạn.").ShowDialog();
            }
        }