예제 #1
0
        public void loaddata(object sender, DoWorkEventArgs e)
        {
            clist = hrs.getcustomer();
            rlist = hrs.getrecord();
            plist = hrs.getpay();
            // dlist = hrs.getcustomer();
            this.Dispatcher.Invoke(new Action(delegate
            {
                addgrid.ItemsSource     = clist;
                update_grid.ItemsSource = clist;
                search_grid.ItemsSource = rlist;
                bill_grid.ItemsSource   = plist;

                //addgrid.ItemsSource = bklist;
            }));
        }
예제 #2
0
        private void make_booking(object sender, RoutedEventArgs e)
        {
            HRSFACTORY hrs = new HRSFACTORY();

            clist = hrs.getcustomer();
            String nam     = fnam.Text;
            String lnam    = lname.Text;
            String cnic_no = cnic.Text;
            String cell    = ph_no.Text;
            String address = add.Text;
            String type    = rm_type.Text;


            #region validation
            bool valid = true;
            if (nam.Trim() == "")
            {
                fnam.BorderBrush     = Brushes.Red;
                fnam.BorderThickness = new Thickness(2, 2, 2, 2);
                valid = false;
                //MessageBox.Show("Name should not be Empty","Enter add name",MessageBoxButton.OK, MessageBoxImage.Stop);
                //return;
            }
            if (!cnic.IsMaskCompleted)
            {
                cnic.BorderBrush     = Brushes.Red;
                cnic.BorderThickness = new Thickness(2, 2, 2, 2);
                valid = false;
                // MessageBox.Show("Name should not be Empty", "Enter add name", MessageBoxButton.OK, MessageBoxImage.Stop);
                //return;
            }

            if (type == "select room_type")
            {
                rm_type.BorderBrush     = Brushes.Red;
                rm_type.BorderThickness = new Thickness(2, 2, 2, 2);
                valid = false;
                // MessageBox.Show("Name should not be Empty", "Enter add name", MessageBoxButton.OK, MessageBoxImage.Stop);
                //return;
            }
            if (lnam.Trim() == "")
            {
                lname.BorderBrush     = Brushes.Red;
                lname.BorderThickness = new Thickness(2, 2, 2, 2);
                valid = false;
                // MessageBox.Show("Name should not be Empty", "Enter add name", MessageBoxButton.OK, MessageBoxImage.Stop);
                //return;
            }
            if (address.Trim() == "")
            {
                add.BorderBrush     = Brushes.Red;
                add.BorderThickness = new Thickness(2, 2, 2, 2);
                valid = false;
                // MessageBox.Show("Name should not be Empty", "Enter add name", MessageBoxButton.OK, MessageBoxImage.Stop);
                //return;
            }
            if (!ph_no.IsMaskCompleted)
            {
                ph_no.BorderBrush     = Brushes.Red;
                ph_no.BorderThickness = new Thickness(2, 2, 2, 2);
                valid = false;
                // MessageBox.Show("Name should not be Empty", "Enter add name", MessageBoxButton.OK, MessageBoxImage.Stop);
                //return;
            }


            if (!valid)
            {
                MessageBox.Show("All field are required", "information", MessageBoxButton.OK, MessageBoxImage.Stop);
                return;
            }
            #endregion
            DateTime dob = new DateTime();
            dob = (DateTime)DOB.SelectedDate;
            DateTime LOD = new DateTime();
            LOD = (DateTime)lod.SelectedDate;
            System.Console.WriteLine(dob);

            if (DOB.Text == lod.Text)
            {
                MessageBox.Show("booking_date and leaving date should not be same", "information", MessageBoxButton.OK, MessageBoxImage.Stop);
                return;
            }

            else if (DateTime.Today > dob)
            {
                MessageBox.Show("invalid booking date", "information", MessageBoxButton.OK, MessageBoxImage.Stop);
                return;
            }
            else if (dob > LOD)
            {
                MessageBox.Show("invalid leaving date", "information", MessageBoxButton.OK, MessageBoxImage.Stop);
                return;
            }
            customer cus = new customer();
            booking  bk  = new booking();
            bk.booking_date = dob;
            bk.leave_date   = LOD;


            payment pay = new payment();

            cus.fname    = nam;
            cus.lastname = lnam;
            cus.cnic     = cnic_no;
            cus.cell_no  = cell;
            cus.Address  = address;



            TimeSpan diff = LOD - dob;
            var      days = diff.Days;
            if (hrs.getcnic(cnic_no) != null)
            {
                MessageBox.Show("CNIC ALREADY", "EXIST", MessageBoxButton.OK, MessageBoxImage.Stop);

                return;
            }
            else
            {
                hrs.addcust(cus);

                hrs.addbooking(bk, cus, type);
                clist = hrs.getcustomer();
                addgrid.ItemsSource     = clist;
                update_grid.ItemsSource = clist;
                addgrid.Items.Refresh();
                update_grid.Items.Refresh();
            }


            if (type == "single bed")
            {
                int amnt = days * 5000;
                pay.rent = amnt;
                hrs.addpayment(cus, bk, pay);
            }
            else
            {
                int rnt = days * 9000;
                pay.rent = rnt;
                hrs.addpayment(cus, bk, pay);
            }


            fnam.Text    = null;
            lname.Text   = null;
            cnic.Text    = null;
            ph_no.Text   = null;
            DOB.Text     = null;
            lod.Text     = null;
            add.Text     = null;
            rm_type.Text = "select room_type";

            plist = hrs.getpaydata();
            bill_grid.ItemsSource = plist;
            bill_grid.Items.Refresh();
        }