Beispiel #1
0
 private void ClearForm()
 {
     _selectedRoom              = null;
     _selectedMonth             = 0;
     tbxRoomNo.Text             = "";
     tbxMonth.Text              = "";
     tbxWaterStart.Text         = "";
     tbxWaterEnd.Text           = "";
     tbxWaterUnits.Text         = "";
     tbxWaterUnitPrices.Text    = "";
     tbxWaterAmount.Text        = "";
     tbxElectricStart.Text      = "";
     tbxElectricEnd.Text        = "";
     tbxElectricUnits.Text      = "";
     tbxElectricUnitPrices.Text = "";
     tbxElectricAmount.Text     = "";
     tbxTelephoneAmount.Text    = "";
     tbxMonthCost.Text          = "";
     tbxImproveCost.Text        = "";
     tbxImproveText.Text        = "ค่าใช้จ่ายอื่น ๆ";
     tbxTotal.Text              = "";
     tbxVATAmount.Text          = "";
     tbxGrandTotal.Text         = "";
     lblGrandTotalText.Content  = "";
     tbxComment.Text            = "";
     PopulateFieldsOnLoad();
 }
Beispiel #2
0
 private void tbxRoomNo_KeyDown(object sender, KeyEventArgs e)
 {
     try
     {
         if (e.Key == Key.Enter && tbxRoomNo.Text != "")
         {
             _selectedRoom = new RoomsLogic().GetRoomByRoomNo(tbxRoomNo.Text);
             if (_selectedRoom != null)
             {
                 if (!new InvoicesLogic().IsThisMonthInvoiceExists(_selectedRoom.RoomId, long.Parse(tbxMonth.Text), DateTime.Now.Year))
                 {
                     PopulateFieldsOnRoomSelect();
                     tbxWaterEnd.Focus();
                 }
                 else
                 {
                     MessageBox.Show("มีข้อมูลใบแจ้งหนี้ของเดือนนี้ในระบบแล้ว", "เกิดข้อผิดพลาด", MessageBoxButton.OK, MessageBoxImage.Error);
                     ClearForm();
                 }
             }
             else
             {
                 MessageBox.Show("ไม่พบเลขที่ห้องพักที่กำหนด", "เกิดข้อผิดพลาด", MessageBoxButton.OK, MessageBoxImage.Error);
                 ClearForm();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "เกิดข้อผิดพลาด", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Beispiel #3
0
        private void UpdateRoomData(Model.Room room)
        {
            UpdateRoom updateWindow = new UpdateRoom(room);

            if (updateWindow.ShowDialog() == true)
            {
                dgRooms.ItemsSource = new RoomsLogic().GetRooms(Global.CurrentApartment.ApartmentId);
            }
        }
Beispiel #4
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (IsFormInputsValid())
                {
                    if (_isNewCustomer)
                    {
                        Model.Customer customer = new Model.Customer()
                        {
                            ContactName = tbxContactName.Text,
                            CustomerNo  = " ",
                            CompanyName = tbxCompanyName.Text,
                            CardId      = tbxCardId.Text,
                            Address     = tbxAddress.Text,
                            Tel         = Global.CurrentApartment.Tel
                        };
                        new CustomersLogic().AddCustomer(customer);
                        _selectedCustomer = new CustomersLogic().GetLatestCustomer();
                    }
                    if (_selectedCustomer != null)
                    {
                        Model.Room room = new Model.Room()
                        {
                            RoomNo          = tbxRoomNo.Text,
                            Customer        = _selectedCustomer,
                            WUnitStart      = long.Parse(tbxWUnitStart.Text),
                            EUnitStart      = long.Parse(tbxEUnitStart.Text),
                            MonthCost       = Decimal.Parse(tbxMonthCost.Text),
                            InsureCost      = Decimal.Parse(tbxInsureCost.Text),
                            StartDate       = dpStartDate.SelectedDate,
                            ApartmentId     = Global.CurrentApartment.ApartmentId,
                            Floor           = tbxFloor.Text,
                            Picture         = " ",
                            ContractMonth   = tbxContractMonth.Text != "" ? long.Parse(tbxContractMonth.Text) : 0,
                            LandTaxedPerson = rbIsLandTaxedPerson.IsChecked.Value,
                            Available       = rbRoomAvailable.IsChecked.Value
                        };
                        new RoomsLogic().AddRoom(room);
                        MessageBox.Show("การเพิ่มข้อมูลสำเร็จเรียบร้อย", "สำเร็จ", MessageBoxButton.OK, MessageBoxImage.Information);

                        ClearForm();

                        this.DialogResult = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "เกิดข้อผิดพลาด", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #5
0
 private void tbxRoomNo_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter && tbxRoomNo.Text != "")
     {
         _selectedRoom = new RoomsLogic().GetRoomByRoomNo(tbxRoomNo.Text);
         if (_selectedRoom != null)
         {
             PopulateReceiptData();
             tbxComment.Focus();
         }
         else
         {
             MessageBox.Show("ไม่พบเลขที่ห้องพักที่กำหนด", "เกิดข้อผิดพลาด", MessageBoxButton.OK, MessageBoxImage.Error);
             ClearForm();
         }
     }
 }
Beispiel #6
0
 private void PopulateRoomData(Model.Room room)
 {
     tbxContactName.Text              = room.Customer.ContactName;
     tbxCardId.Text                   = room.Customer.CardId;
     tbxCompanyName.Text              = room.Customer.CompanyName;
     tbxAddress.Text                  = room.Customer.Address;
     rbIsLandTaxedPerson.IsChecked    = room.LandTaxedPerson;
     rbIsNotLandTaxedPerson.IsChecked = !room.LandTaxedPerson;
     rbRoomAvailable.IsChecked        = room.Available;
     rbRoomUnavailable.IsChecked      = !room.Available;
     tbxRoomNo.Text                   = room.RoomNo;
     tbxFloor.Text            = room.Floor;
     tbxMonthCost.Text        = room.MonthCost.ToString();
     tbxInsureCost.Text       = room.InsureCost.ToString();
     tbxWUnitStart.Text       = room.WUnitStart.ToString();
     tbxEUnitStart.Text       = room.EUnitStart.ToString();
     tbxContractMonth.Text    = room.ContractMonth.ToString();
     dpStartDate.SelectedDate = room.StartDate.Value;
 }
Beispiel #7
0
 private void PopulateReceiptData()
 {
     if (IsMonthInputValid())
     {
         if (tbxRoomNo.Text != null)
         {
             _selectedRoom = new RoomsLogic().GetRoomByRoomNo(tbxRoomNo.Text);
             int receiptYear = (DateTime.Now.Month == 1 && _selectedMonth == 12) ? DateTime.Now.Year - 1 : DateTime.Now.Year;
             if (!new ReceiptsLogic().IsThisMonthReceiptExists(_selectedRoom.RoomId, long.Parse(tbxMonth.Text), receiptYear))
             {
                 PopulateFieldsOnRoomSelect();
             }
             else
             {
                 ClearForm();
                 MessageBox.Show("มีข้อมูลใบเสร็จรับเงินของเดือนนี้ในระบบแล้ว", "เกิดข้อผิดพลาด", MessageBoxButton.OK, MessageBoxImage.Error);
             }
         }
     }
 }
Beispiel #8
0
 public UpdateRoom(Model.Room room)
 {
     InitializeComponent();
     _room = room;
     PopulateRoomData(_room);
 }