Example #1
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();
        }
Example #2
0
        private void updat(object sender, RoutedEventArgs e)
        {
            String fnam    = fname.Text;
            String lnam    = clnam.Text;
            String cuscnic = ccnic.Text;
            String ph_no   = ccont.Text;
            String add     = cadd.Text;
            String type    = urm_type.Text;

            #region validation
            bool valid = true;
            if (fnam.Trim() == "")
            {
                fname.BorderBrush     = Brushes.Red;
                fname.BorderThickness = new Thickness(2, 2, 2, 2);
                valid = false;
            }
            if (!ccnic.IsMaskCompleted)
            {
                ccnic.BorderBrush     = Brushes.Red;
                ccnic.BorderThickness = new Thickness(2, 2, 2, 2);
                valid = false;
            }

            if (type == "select_type")
            {
                urm_type.BorderBrush     = Brushes.Red;
                urm_type.BorderThickness = new Thickness(2, 2, 2, 2);
                valid = false;
            }
            if (lnam.Trim() == "")
            {
                clnam.BorderBrush     = Brushes.Red;
                clnam.BorderThickness = new Thickness(2, 2, 2, 2);
                valid = false;
            }
            if (add.Trim() == "")
            {
                cadd.BorderBrush     = Brushes.Red;
                cadd.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 (!ccont.IsMaskCompleted)
            {
                ccont.BorderBrush     = Brushes.Red;
                ccont.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 dbo = new DateTime();
            dbo = (DateTime)db.SelectedDate;
            DateTime ldo = new DateTime();
            ldo = (DateTime)ld.SelectedDate;


            cust.Address  = add;
            cust.fname    = fnam;
            cust.lastname = lnam;
            cust.cell_no  = ph_no;

            cust.booking.booking_date = dbo;
            cust.booking.leave_date   = ldo;



            cust.Address  = add;
            cust.fname    = fnam;
            cust.lastname = lnam;
            cust.cell_no  = ph_no;

            hrs.update(cust, type);


            payment  paym = new payment();
            TimeSpan diff = cust.booking.leave_date - cust.booking.booking_date;
            var      days = diff.Days;

            if (type == "single bed")
            {
                int rnt = days * 5000;

                paym.rent = rnt;
                hrs.updatepaymnt(paym, cust);
            }
            else if (type == "double bed")
            {
                int rnt = days * 9000;
                paym.rent = rnt;
                hrs.updatepaymnt(paym, cust);
            }
            else
            {
                System.Console.WriteLine("hhhhh");
            }



            clist = hrs.getcustomer();
            update_grid.ItemsSource = clist;
            update_grid.Items.Refresh();
            addgrid.ItemsSource = clist;
            addgrid.Items.Refresh();
            plist = hrs.getpaydata();
            bill_grid.ItemsSource = plist;
            bill_grid.Items.Refresh();

            fname.Text = null;
            clnam.Text = null;
            ccnic.Text = null;
            ccont.Text = null;

            cadd.Text     = null;
            urm_type.Text = null;
        }