示例#1
0
        private void deleteRentHistoryListButton_Click(object sender, RoutedEventArgs e)
        {
            int index = rentHistoryDataGrid.SelectedIndex;

            if (index == -1)
            {
                MessageBox.Show("Chưa chọn đối tượng để xóa");
                return;
            }

            LichSuGiaoDich rentHistoryList = RentHistoryList[index];

            var dbRentHistory = DataProvider.Instance.Database.LichSuGiaoDiches.SingleOrDefault(p => p.MaNha == rentHistoryList.MaNha &&
                                                                                                p.MaCN == rentHistoryList.MaCN &&
                                                                                                p.MaKH == rentHistoryList.MaKH &&
                                                                                                p.NgayGD == rentHistoryList.NgayGD);

            if (dbRentHistory == null)
            {
                return;
            }

            dbRentHistory.DeleteStatus = true;

            DataProvider.Instance.Database.SaveChanges();

            RentHistoryList = new ObservableCollection <LichSuGiaoDich>(DP.Database.LichSuGiaoDiches.Where(p => p.DeleteStatus == false && p.BD.DeleteStatus == false && p.LoaiGD == "THUE"));
            rentHistoryDataGrid.SelectedIndex = -1;
        }
示例#2
0
        private void addTransactionButton_Click(object sender, RoutedEventArgs e)
        {
            App.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
            {
                string transactionCustomerCode = "";
                string transactionHouseCode    = "";
                string transactionOwnerCode    = "";
                DateTime transactionDate;
                string transactionType = "";
                int rentDuration       = 0;
                if (transactionCustomerListComboBox.SelectedIndex >= 0)
                {
                    transactionCustomerCode = CustomerList[transactionCustomerListComboBox.SelectedIndex].MaKH;
                }
                if (transactionCustomerCode.Length == 0)
                {
                    MessageBox.Show("Chưa chọn mã khách hàng");
                    return;
                }
                if (transactionHouseListComboBox.SelectedIndex >= 0)
                {
                    transactionHouseCode = RentHouseList[transactionHouseListComboBox.SelectedIndex].MaNha;
                    transactionOwnerCode = RentHouseList[transactionHouseListComboBox.SelectedIndex].MaCN;
                }
                if (transactionHouseCode.Length == 0)
                {
                    MessageBox.Show("Chưa chọn mã nhà - chủ nhà");
                    return;
                }

                if (transactionDatePicker.SelectedDate == null)
                {
                    MessageBox.Show("Chưa chọn ngày giao dịch");
                    return;
                }

                if (transactionTypeComboBox.Text.Length == 0)
                {
                    MessageBox.Show("Chưa chọn loại giao dịch");
                    return;
                }


                transactionDate = (DateTime)transactionDatePicker.SelectedDate;
                transactionType = transactionTypeComboBox.Text;

                if (transactionType == "THUE")
                {
                    if (rentDurationTextBox.Text.Length == 0)
                    {
                        MessageBox.Show("Chưa nhập số tháng thuê");
                        return;
                    }
                    if (int.TryParse(rentDurationTextBox.Text, out rentDuration) == false)
                    {
                        MessageBox.Show("Số tháng thuê không hợp lệ");
                        return;
                    }
                }
                else if (transactionType == "MUA")
                {
                    rentDuration = 0;
                    MessageBox.Show("Mua nhà thì tháng thuê là 0");
                }

                LichSuGiaoDich newTransaction = new LichSuGiaoDich();
                newTransaction.MaKH           = transactionCustomerCode;
                newTransaction.MaNha          = transactionHouseCode;
                newTransaction.MaCN           = transactionOwnerCode;
                newTransaction.NgayGD         = transactionDate;
                newTransaction.LoaiGD         = transactionType;
                newTransaction.SoThangThue    = rentDuration;
                newTransaction.DeleteStatus   = false;

                DP.Database.LichSuGiaoDiches.Add(newTransaction);
                DP.Database.SaveChanges();
                MessageBox.Show("Đã thêm lịch sử giao dịch");
            }));
        }
示例#3
0
        // Lịch sử giao dịch
        private void barButtonItem_lichsuGD_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            LichSuGiaoDich lichSuGiaoDich = new LichSuGiaoDich();

            AddTabControl(lichSuGiaoDich, "Lịch sử giao dịch");
        }