Example #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //the next button
            if (TBCustomer.Text != null && CBBicycle.SelectedValue != null)
            {
                stack1.Visibility  = Visibility.Visible;
                LBCustomer.Text    = TBCustomer.Text;
                LBBike.Text        = CBBicycle.Text;
                LBBookingDate.Text = Convert.ToString(DateTime.Now);

                LBCustomer.Visibility    = Visibility.Visible;
                LBBike.Visibility        = Visibility.Visible;
                LBBookingDate.Visibility = Visibility.Visible;
                rect.Visibility          = Visibility.Visible;
                TBRemarks.Visibility     = Visibility.Visible;
                LB1.Visibility           = Visibility.Visible;
                LB2.Visibility           = Visibility.Visible;
                LB3.Visibility           = Visibility.Visible;
            }

            else
            {
                PopWindow pop = new PopWindow(ImageType.Error, "Error", "Please Fill in all blanks", "OK");
                pop.ShowDialog();
            }
        }
Example #2
0
        private void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            if (LBTitle.Text == "Bicycle")
            {
                TBikeDAL MyDAL = new TBikeDAL();


                ConfirmWindow confirm = new ConfirmWindow(ImageType.Question, "Delete?", "Are you sure to delete this bicycle?", "Yes", "No! Turn Back!");
                if (confirm.Confirmed)
                {
                    MyDAL.DeleteBicycleByID(LBID.Text);
                    PopulateBikeDataTable();
                    PopWindow pop = new PopWindow(ImageType.Information, "Bicycle Deleted", "Bicycle: " + LBName.Text + " Has been Deleted By " + TLUsername.Text, "Okay");
                    pop.ShowDialog();
                }
            }
            else if (LBTitle.Text == "Snacks")
            {
                TBikeDAL MyDAL = new TBikeDAL();

                ConfirmWindow confirm = new ConfirmWindow(ImageType.Question, "Delete?", "Are you sure to delete this Snack?", "Yes", "No! Turn Back!");
                if (confirm.Confirmed)
                {
                    MyDAL.DeleteSnackByID(LBID.Text);
                    PopulateBikeDataTable();
                    PopWindow pop = new PopWindow(ImageType.Information, "Snack Deleted", "Snack: " + LBName.Text + " Has been Deleted By " + TLUsername.Text, "Okay");
                    pop.ShowDialog();
                }
            }
        }
Example #3
0
 private void BTNAddon_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (ListBooking.SelectedIndex >= 0)
         {
             TBikeDAL  MyDAl       = new TBikeDAL();
             DataTable ResultTable = MyDAl.SelectSnackSalesByBookIDCustomer(TBBookID.Text.Trim(), TBCustomer.Text.Trim());
             if (ResultTable.Rows.Count > 0)
             {
                 PopWindow pop = new PopWindow(ImageType.Information, "Addon Details", "Item :" + Convert.ToString(ResultTable.Rows[0]["SnackName"]).Trim() + " , Quantity :" + Convert.ToInt32(ResultTable.Rows[0]["Quantity"]) + " , Total Price :" + Convert.ToDouble(ResultTable.Rows[0]["TotalPrice"]), "OK");
                 pop.ShowDialog();
             }
             else
             {
                 PopWindow pop = new PopWindow(ImageType.Warning, "No Detail", "No Data Found for this booking", "OK");
                 pop.ShowDialog();
             }
         }
         else
         {
             PopWindow pop = new PopWindow(ImageType.Warning, "No Data..", "Please Select a List", "OK");
             pop.ShowDialog();
         }
     }
     catch (Exception ex) {
         PopWindow pop = new PopWindow(ImageType.Error, "Error", "Error: " + ex.Message, "OK");
         pop.ShowDialog();
     }
 }
Example #4
0
        private void BTNPromote_Click(object sender, RoutedEventArgs e)
        {
            TBikeDAL  MyDAL       = new TBikeDAL();
            DataTable ResultTable = MyDAL.SelectEmployeeByEmployeeID(LBEmployeeID.Text);

            Rank = Convert.ToInt32(ResultTable.Rows[0]["EmployeeRank"]);
            try
            {
                if (RankID > Rank)
                {
                    ConfirmWindow com = new ConfirmWindow(ImageType.Question, "Confirm?", "Are you sure to Promote " + LBEmployeeName.Text + " ?", "Yes", "No");
                    com.ShowDialog();
                    if (com.Confirmed)
                    {
                        MyDAL.UpdateEmployeePromotion(LBEmployeeID.Text, Rank + 1, TLUsername.Text);
                        ResultTable             = MyDAL.SelectEmployeeByEmployeeID(LBEmployeeID.Text);
                        LBEmployeeRankDesc.Text = Convert.ToString(ResultTable.Rows[0]["EmployeeRankDesc"]);
                    }
                }
                else
                {
                    ConfirmWindow com = new ConfirmWindow(ImageType.Error, "Error", "Cant Promote Rank Higher than self", "Ok", "Cancel");
                    com.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                PopWindow pop = new PopWindow(ImageType.Error, "Error", Convert.ToString(ex).Trim(), "OK");
                pop.ShowDialog();
            }
        }
Example #5
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //button for creating new employee
                string   Address;
                TBikeDAL MyDal = new TBikeDAL();

                //String Builder
                StringBuilder striBuild = new StringBuilder();
                striBuild.AppendLine(TBAddress1.Text);
                striBuild.AppendLine(TBAddress2.Text);
                striBuild.AppendLine(TBAddress3.Text);
                striBuild.Append(TBCity.Text);
                striBuild.Append(" , " + TBZipCode.Text);
                Address = striBuild.ToString().Trim();

                MyDal.AddNewEmployeeDetails(TBEmpName.Text, DOBText.SelectedDate.Value.Date, TBEmail.Text, TBPhoneNo.Text, Address, "Tommy");
                CreateNewUser emp = new CreateNewUser();
                this.Close();
                emp.PopulateDataFromLogin(username);
                emp.Show();
                PopWindow pop = new PopWindow(ImageType.Information, "Congratulations", "Create New User Success!!!", "OK");
            }
            catch (Exception ex)
            {
                PopWindow pop = new PopWindow(ImageType.Error, "Error", ex.Message, "OK");
                pop.ShowDialog();
            }
        }
Example #6
0
        private void BTNUpdate_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                TBikeDAL MyDAL = new TBikeDAL();
                username = LBUsername.Text;
                ConfirmWindow com = new ConfirmWindow(ImageType.Error, "Update", "Are you sure to modify these changes?", "Yes", "No");
                com.ShowDialog();
                if (com.Confirmed)
                {
                    MyDAL.UpdateEmployee(LBEmployeeID.Text, LBEmployeeName.Text, Convert.ToDateTime(LBDob.Text), LBUsername.Text, LBEmployeeRankDesc.Text, LBEmail.Text, LBPhoneNo.Text, LBCity.Text, TLUsername.Text);
                    DataTable ResultTable = MyDAL.SelectEmployeeByEmployeeID(LBEmployeeID.Text);


                    LBEmployeeName.Text     = Convert.ToString(ResultTable.Rows[0]["EmployeeName"]).Trim();
                    LBEmployeeRankDesc.Text = Convert.ToString(ResultTable.Rows[0]["EmployeeRankDesc"]).Trim();
                    LBUsername.Text         = Convert.ToString(ResultTable.Rows[0]["Username"]).Trim();
                    LBEmail.Text            = Convert.ToString(ResultTable.Rows[0]["Email"]).Trim();
                    LBDob.Text       = Convert.ToString(ResultTable.Rows[0]["DateOfBirth"]).Trim();
                    LBPhoneNo.Text   = Convert.ToString(ResultTable.Rows[0]["PhoneNo"]).Trim();
                    LBCity.Text      = Convert.ToString(ResultTable.Rows[0]["Address"]).Trim();
                    LBLastLogin.Text = Convert.ToString(ResultTable.Rows[0]["LastLoginTime"]).Trim();

                    PopulateDataFromLogin(username);
                }
            }
            catch (Exception ex)
            {
                PopWindow pop = new PopWindow(ImageType.Error, "Error", ex.Message, "OK");
                pop.ShowDialog();
            }
        }
Example #7
0
        private void BTNsearch_Click(object sender, RoutedEventArgs e)
        {
            if (CBMode.SelectedValue.ToString().Trim() == "Employee")
            {
                if (RankID >= 3)
                {
                    initializeWorker();
                }
                else
                {
                    PopWindow pop = new PopWindow(ImageType.Warning, "Rank too low", "Sorry You do not have access to this feature", "Ok");
                    pop.ShowDialog();
                }
            }

            if (CBMode.SelectedValue.ToString().Trim() == "Snacks" || CBMode.SelectedValue.ToString().Trim() == "Bicycle" && CBMode.SelectedValue.ToString().Trim() != "Empoyee")
            {
                if (RankID >= 2)
                {
                    initializeWorker();
                }
                else
                {
                    PopWindow pop = new PopWindow(ImageType.Warning, "Rank too low", "Sorry You do not have access to this feature", "Ok");
                    pop.ShowDialog();
                }
            }

            else if (CBMode.SelectedValue.ToString().Trim() != "Employee")
            {
                initializeWorker();
            }
        }
Example #8
0
        public void LinkToEmployee()
        {
            TBikeDAL  MyDAL       = new TBikeDAL();
            int       index       = dataGrid1.Items.IndexOf(dataGrid1.CurrentItem);
            DataTable ResultTable = MyDAL.ShowAllEmployeeDetails();


            if (index == -1)
            {
                index = 0;
            }
            else
            {
                string id   = Convert.ToString(ResultTable.Rows[index]["EmployeeID"]);
                string self = Convert.ToString(ResultTable.Rows[index]["Username"]);
                if (id != null)
                {
                    if (RankID >= 4 || self == username)
                    {
                        EmployeeModify emp = new EmployeeModify();

                        emp.PopulateDataFromLogin(username);
                        emp.populateEmployee(id);
                        emp.ShowDialog();
                    }
                    else
                    {
                        PopWindow pop = new PopWindow(ImageType.Warning, "Error", "Rank too low to access this service", "Alright");
                        pop.ShowDialog();
                    }
                }
            }
        }
Example #9
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (LBStatus.Text == "Invalid")
         {
             //send to repair button
             string        repairCondition = ("Servicing, Reason: " + TBCondition.Text);
             TBikeDAL      MyDAL           = new TBikeDAL();
             ConfirmWindow confirm         = new ConfirmWindow(ImageType.Question, "Confirmation", "Are you sure to send this to Service? ", "Yes", "No");
             confirm.ShowDialog();
             if (confirm.Confirmed)
             {
                 MyDAL.UpdateBikeStatus(CBBicycle.SelectedValue.ToString().Trim(), "", "M", repairCondition.Trim(), PickStart.SelectedDate, PickEnd.SelectedDate, TLUsername.Text);
                 PopWindow pop = new PopWindow(ImageType.Information, "Done", "Bicycle Send for Service", "OK");
                 pop.ShowDialog();
             }
             BindComboBoxBicycle(CBBicycle);
         }
     }
     catch (Exception ex)
     {
         PopWindow pop = new PopWindow(ImageType.Error, "Error", ex.Message, "OK");
         pop.ShowDialog();
     }
 }
Example #10
0
 private void MyStartupBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     MyStartupBackgroundWorker.ReportProgress(5, "Checking SQL server ....");
     System.Threading.Thread.Sleep(50);
     MyStartupBackgroundWorker.ReportProgress(15, "Checking Table Mode ....");
     System.Threading.Thread.Sleep(50);
     MyStartupBackgroundWorker.ReportProgress(20, "Checking SQL for table ....");
     try
     {
         System.Threading.Thread.Sleep(50);
         MyStartupBackgroundWorker.ReportProgress(30, "Service started ....");
         System.Threading.Thread.Sleep(50);
         MyStartupBackgroundWorker.ReportProgress(40, "Service Running ....");
         System.Threading.Thread.Sleep(150);
         MyStartupBackgroundWorker.ReportProgress(50, "Service Done");
         System.Threading.Thread.Sleep(50);
         MyStartupBackgroundWorker.ReportProgress(60, "Found Data !!!!");
         System.Threading.Thread.Sleep(50);
         MyStartupBackgroundWorker.ReportProgress(70, "Input Data to Grid ....");
         System.Threading.Thread.Sleep(50);
         MyStartupBackgroundWorker.ReportProgress(80, "DataGrid Sorting ....");
         System.Threading.Thread.Sleep(50);
         MyStartupBackgroundWorker.ReportProgress(90, "Showing DataGrid ....");
         System.Threading.Thread.Sleep(50);
         MyStartupBackgroundWorker.ReportProgress(100, "Completed !!!!");
     }
     catch (Exception ex) {
         System.Threading.Thread.Sleep(50);
         MyStartupBackgroundWorker.ReportProgress(100, "Unhandled Exception Occured: " + ex.Message);
         PopWindow pop = new PopWindow(ImageType.Error, "Error SQL", ex.Message, "OK");
         pop.ShowDialog();
     }
 }
Example #11
0
 private void MyStartupBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     BTNsearch.IsEnabled      = true;
     CBMode.IsEnabled         = true;
     ProgressPanel.Visibility = Visibility.Hidden;
     if (CBMode.SelectedIndex != -1)
     {
         if (CBMode.SelectedValue.ToString().Trim() == "Employee")
         {
             StackService.Visibility = Visibility.Hidden;
             StackSnack.Visibility   = Visibility.Hidden;
             StackBook.Visibility    = Visibility.Hidden;
             StackEmp.Visibility     = Visibility.Visible;
             EmployeeMode();
         }
         else if (CBMode.SelectedValue.ToString().Trim() == "Booking")
         {
             StackBike.Visibility    = Visibility.Hidden;
             StackService.Visibility = Visibility.Hidden;
             StackSnack.Visibility   = Visibility.Hidden;
             StackEmp.Visibility     = Visibility.Hidden;
             StackBook.Visibility    = Visibility.Visible;
             BookingMode();
         }
         else if (CBMode.SelectedValue.ToString().Trim() == "Bicycle")
         {
             StackService.Visibility = Visibility.Hidden;
             StackSnack.Visibility   = Visibility.Hidden;
             StackBook.Visibility    = Visibility.Hidden;
             StackEmp.Visibility     = Visibility.Hidden;
             StackBike.Visibility    = Visibility.Visible;
             BicycleMode();
         }
         else if (CBMode.SelectedValue.ToString().Trim() == "Snacks")
         {
             StackService.Visibility = Visibility.Hidden;
             StackBook.Visibility    = Visibility.Hidden;
             StackEmp.Visibility     = Visibility.Hidden;
             StackBike.Visibility    = Visibility.Hidden;
             StackSnack.Visibility   = Visibility.Visible;
             SnackMode();
         }
         else if (CBMode.SelectedValue.ToString().Trim() == "Service")
         {
             StackSnack.Visibility   = Visibility.Hidden;
             StackBike.Visibility    = Visibility.Hidden;
             StackEmp.Visibility     = Visibility.Hidden;
             StackBook.Visibility    = Visibility.Hidden;
             StackService.Visibility = Visibility.Visible;
             ServiceMode();
         }
     }
     else
     {
         PopWindow pop = new PopWindow(ImageType.Error, "Error", "Please Choose a mode", "OK");
         pop.ShowDialog();
     }
 }
Example #12
0
        private void BTNReturn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string DamageStatus = "A";
                if ((CBStatus.IsChecked ?? true) || (CBStatus_Copy.IsChecked ?? true))
                {
                    DamageStatus = "I";
                }
                TBikeDAL MyDAL = new TBikeDAL();
                if (ExpiredStack.Visibility == Visibility.Hidden)
                {
                    if (CBBike.SelectedValue != null)
                    {
                        MyDAL.UpdateBookingStatus("S", CBBike.SelectedValue.ToString().Trim(), Customer, TLUsername.Text);
                        MyDAL.UpdateBikeStatus(CBBike.SelectedValue.ToString().Trim(), "", DamageStatus, TBConditionReal.Text, null, Convert.ToDateTime(null), TLUsername.Text);
                        PopWindow pop = new PopWindow(ImageType.Information, "Success", "Bicycle: " + CBBike.Text + " Returned", "Thank You");
                        pop.ShowDialog();
                        BindComboBox(CBBike);
                    }

                    else
                    {
                        PopWindow pop = new PopWindow(ImageType.Error, "Error", "No Bicycle is currently being rented out", "OK");
                        pop.ShowDialog();
                    }
                }
                else
                {
                    //this is for late return part
                    if (LBCustomer.Text != null)
                    {
                        MyDAL.UpdateBookingStatus("S", ListBicycle.SelectedValue.ToString().Trim(), LBName.Text, TLUsername.Text);
                        MyDAL.UpdateBikeStatus(ListBicycle.SelectedValue.ToString().Trim(), "", DamageStatus, TBCondition.Text, null, Convert.ToDateTime(null), TLUsername.Text);
                        PopWindow pop = new PopWindow(ImageType.Warning, "Late Return", "Late Returned Bicycle: " + ListBicycle.Text + " Returned", "OK");
                        pop.ShowDialog();
                        BindComboBoxCustomer(CBCustomer);
                    }
                    else
                    {
                        PopWindow pop = new PopWindow(ImageType.Error, "Error", "No Bicycle is currently being rented out", "Okay");
                        pop.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
                PopWindow pop = new PopWindow(ImageType.Error, "Error ", ex.Message, "Okay");
                pop.ShowDialog();
            }
        }
Example #13
0
 public void AddNewItems()
 {
     DetermineItemStatus();
     try
     {
         if (LBName.Text != "")
         {
             if (LBTitle.Text == "Bicycle")
             {
                 PopulateBikeDataTable();
                 if (LBID.Text != null)
                 {
                     TBikeDAL      MyDAL = new TBikeDAL();
                     ConfirmWindow con   = new ConfirmWindow(ImageType.Question, "Are you sure to add new data?", "Confirmation", "Yes", "No");
                     con.ShowDialog();
                     if (con.Confirmed)
                     {
                         MyDAL.AddBicycleTable(TBName.Text, TBType.Text, Convert.ToInt32(TBQuantity.Text), Convert.ToDouble(TBPrice.Text), TBColor.Text, TLUsername.Text);
                         PopulateBikeDataTable();
                     }
                 }
             }
             else if (LBTitle.Text == "Snacks")
             {
                 PopulateSnackDataTable();
                 TBikeDAL      MyDAL = new TBikeDAL();
                 ConfirmWindow con   = new ConfirmWindow(ImageType.Question, "Confirmation", "Are you sure to add new data?", "Add Please", "No, don't add please");
                 con.ShowDialog();
                 if (con.Confirmed)
                 {
                     MyDAL.AddSnackTable(TBName.Text, TBType.Text, Convert.ToDouble(TBPrice.Text), Convert.ToInt32(TBColor.Text), TLUsername.Text);
                     PopulateSnackDataTable();
                 }
             }
         }
         else
         {
             PopWindow con = new PopWindow(ImageType.Error, "No field", "Please fill in all", "OK");
             con.ShowDialog();
         }
     }
     catch (Exception ex)
     {
         PopWindow pop = new PopWindow(ImageType.Information, "Error", ex.Message, "I will Fix this");
         pop.ShowDialog();
         pop.Dispose();
     }
 }
Example #14
0
        public void PopulateID(string Customer, string Status)
        {
            TBikeDAL MyDAL = new TBikeDAL();

            DataTable ResultTable = MyDAL.ShowBookingTableByCustomer(Customer, Status);

            Customer = Convert.ToString(ResultTable.Rows[0]["Customer"]);
            BindComboBoxCustomer(CBCustomer);
            CBCustomer.SelectedIndex = CBCustomer.Items.Count - 1;
            if (ResultTable.Rows.Count != 0)
            {
                if (Status == "R")
                {
                    BindComboBox(CBBike);
                    CBBike.SelectedIndex   = CBBike.Items.Count - 1;
                    LBCustomer.Text        = Customer;
                    StackReturn.Visibility = Visibility.Visible;
                    LBBookingDate.Text     = Convert.ToString(ResultTable.Rows[0]["BookingDate"]);
                    LBBicycle.Text         = Convert.ToString(ResultTable.Rows[0]["BicycleName"]);
                    LBRemarks.Text         = Convert.ToString(ResultTable.Rows[0]["Remark"]);
                }
                else
                {
                    // if Status is not return
                    StackHelo.Visibility     = Visibility.Hidden;
                    Rect1.Visibility         = Visibility.Hidden;
                    CBBike.Visibility        = Visibility.Hidden;
                    LBCustomer.Visibility    = Visibility.Hidden;
                    LBBookingDate.Visibility = Visibility.Hidden;
                    LBBicycle.Visibility     = Visibility.Hidden;
                    LBRemarks.Visibility     = Visibility.Hidden;
                    StackReturn.Visibility   = Visibility.Hidden;
                    BTNExpired.Foreground    = Brushes.Red;
                    ExpiredStack.Visibility  = Visibility.Visible;

                    LBName.Text = Convert.ToString(ResultTable.Rows[0]["Customer"]);
                    LBDate.Text = Convert.ToString(ResultTable.Rows[0]["BookingDate"]);
                }
            }
            else
            {
                PopWindow pop = new PopWindow(ImageType.Error, "Error", "No data Found!!!", "OK");
                pop.ShowDialog();
            }
        }
Example #15
0
        public void UpdateAllItems()
        {
            try
            {
                DetermineItemStatus();

                if (LBTitle.Text == "Bicycle")
                {
                    if (LBID.Text != null)
                    {
                        TBikeDAL      MyDAL = new TBikeDAL();
                        ConfirmWindow con   = new ConfirmWindow(ImageType.Question, "Confirmation", "Are you sure to make these changes?", "Yes, Change This", "No, Don't Change");
                        con.ShowDialog();
                        if (con.Confirmed)
                        {
                            MyDAL.UpdateBicycleTable(LBID.Text, TBName.Text, TBType.Text, Convert.ToInt32(TBQuantity.Text), ItemStatus, Convert.ToDouble(TBPrice.Text), TBColor.Text, TLUsername.Text);
                            PopulateBikeDataTable();
                            PopWindow pop = new PopWindow(ImageType.Information, "Success!", "Changes Made, Successfully!", "Ok");
                            pop.ShowDialog();
                        }
                    }
                }
                else if (LBTitle.Text == "Snacks")
                {
                    TBikeDAL      MyDAL = new TBikeDAL();
                    ConfirmWindow con   = new ConfirmWindow(ImageType.Question, "Confirmation", "Are you sure to make these changes?", "Yes, Change This", "No, Don't Change");
                    con.ShowDialog();
                    if (con.Confirmed)
                    {
                        MyDAL.UpdateSnackTable(LBID.Text, TBName.Text, TBType.Text, Convert.ToDouble(TBPrice.Text), Convert.ToInt32(TBColor.Text), ItemStatus, TLUsername.Text);
                        PopulateSnackDataTable();
                        PopWindow pop = new PopWindow(ImageType.Information, "Success!", "Changes Made, Successfully!", "Ok");
                        pop.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
                PopWindow pop = new PopWindow(ImageType.Error, "Error", ex.Message, "I will Fix this");
                pop.ShowDialog();
            }
        }
Example #16
0
 private void Button_Click_2(object sender, RoutedEventArgs e)
 {
     //return from repair btn
     try
     {
         if (LBStatus.Text == "Maintenance")
         {
             string   repairCondition = "";
             TBikeDAL MyDAL           = new TBikeDAL();
             string   BicycleID       = CBBicycle.SelectedValue.ToString().Trim();
             MyDAL.UpdateBikeStatus(BicycleID, "", "A", repairCondition.Trim(), PickStart.SelectedDate, PickEnd.SelectedDate, TLUsername.Text);
             PopWindow pop = new PopWindow(ImageType.Information, "Done", "Bicycle Has been Returned", "OK");
             pop.ShowDialog();
             BindComboBoxBicycle(CBBicycle);
         }
     }
     catch (Exception ex)
     {
         PopWindow pop = new PopWindow(ImageType.Information, "Error", ex.Message, "OK");
         pop.ShowDialog();
     }
 }
Example #17
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            TBikeDAL MyDal = new TBikeDAL();

            try {
                if (TBEmail.Text == "" && TBPassword.Password.ToString().Trim() == "" && TBUsername.Text == "")
                {
                    PopWindow pop = new PopWindow(ImageType.Information, "Error", "Please Fill in all texts", "Let me fill in");
                    pop.ShowDialog();
                }

                else
                {
                    VerifyRequirements();
                }
            }
            catch (Exception ex)
            {
                PopWindow pop = new PopWindow(ImageType.Information, "Error", ex.Message, "I will Fix this");
                pop.ShowDialog();
            }
        }
Example #18
0
        public void populateEmployee(string EmployeeID)
        {
            TBikeDAL  MyDAL       = new TBikeDAL();
            DataTable ResultTable = MyDAL.SelectEmployeeByEmployeeID(EmployeeID);

            if (ResultTable.Rows.Count != 0)
            {
                LBEmployeeID.Text       = EmployeeID;
                LBEmployeeName.Text     = Convert.ToString(ResultTable.Rows[0]["EmployeeName"]).Trim();
                LBEmployeeRankDesc.Text = Convert.ToString(ResultTable.Rows[0]["EmployeeRankDesc"]).Trim();
                LBUsername.Text         = Convert.ToString(ResultTable.Rows[0]["Username"]).Trim();
                LBEmail.Text            = Convert.ToString(ResultTable.Rows[0]["Email"]).Trim();
                LBDob.Text       = Convert.ToString(ResultTable.Rows[0]["DateOfBirth"]).Trim();
                LBPhoneNo.Text   = Convert.ToString(ResultTable.Rows[0]["PhoneNo"]).Trim();
                LBCity.Text      = Convert.ToString(ResultTable.Rows[0]["Address"]).Trim();
                LBLastLogin.Text = Convert.ToString(ResultTable.Rows[0]["LastLoginTime"]).Trim();
            }
            else
            {
                PopWindow pop = new PopWindow(ImageType.Error, "Error", "No data Found!!!", "Ok");
                pop.ShowDialog();
            }
        }
Example #19
0
        public void PopulateID(string Customer, string Status)
        {
            //Populate items from the booking datatable
            TBikeDAL MyDAL = new TBikeDAL();

            DataTable ResultTable = MyDAL.ShowBookingTableByCustomer(Customer, "A");

            if (ResultTable.Rows.Count != 0)
            {
                BindComboBox(CBBike);
                CBBike.SelectedIndex = CBBike.Items.Count - 1;
                LBCustomer.Text      = Customer;

                LBBookingDate.Text       = Convert.ToString(ResultTable.Rows[0]["BookingDate"]);
                LBBike.Text              = Convert.ToString(ResultTable.Rows[0]["BicycleName"]);
                TBRemarks.Text           = Convert.ToString(ResultTable.Rows[0]["Remark"]);
                LBCustomer.Visibility    = Visibility.Visible;
                LBBike.Visibility        = Visibility.Visible;
                LBBookingDate.Visibility = Visibility.Visible;
                rect.Visibility          = Visibility.Visible;
                TBRemarks.Visibility     = Visibility.Visible;
                LB1.Visibility           = Visibility.Visible;
                LB2.Visibility           = Visibility.Visible;
                LB3.Visibility           = Visibility.Visible;
                stack1.Visibility        = Visibility.Visible;
                TBCustomer.Visibility    = Visibility.Hidden;
                BTNNext.Visibility       = Visibility.Hidden;
                CBBicycle.Visibility     = Visibility.Hidden;
                LBNewTitle.Visibility    = Visibility.Hidden;
            }
            else
            {
                PopWindow pop = new PopWindow(ImageType.Error, "Error", "No data Found!!!", "OK");
                pop.ShowDialog();
            }
        }
Example #20
0
        private void BTNRent_Click(object sender, RoutedEventArgs e)
        {
            TBikeDAL MyDAL = new TBikeDAL();

            try
            {
                TimeSpan duration = TPEnd.SelectedTime.Value - TPStart.SelectedTime.Value;
                if (CBBike.SelectedIndex != -1)
                {
                    DataTable ResultTable = MyDAL.ShowBookingTableByCustomer(LBCustomer.Text.Trim(), "A");
                    string    Bike        = Convert.ToString(ResultTable.Rows[0]["BicycleID"]);
                    string    BikeName    = Convert.ToString(ResultTable.Rows[0]["BicycleName"]);
                    string    customer    = Convert.ToString(ResultTable.Rows[0]["CurrentRenter"]);
                    DateTime  bookTime    = Convert.ToDateTime(ResultTable.Rows[0]["BookingDate"]);
                    string    BookingID   = Convert.ToString(ResultTable.Rows[0]["BookingID"]).Trim();
                    //double Deposit = Convert.ToDouble(ResultTable.Rows[0]["BookingDeposit"]);
                    double Price = Convert.ToDouble(ResultTable.Rows[0]["Price"]);

                    //This is for booked rents
                    if (TPStart.SelectedTime < bookTime.TimeOfDay)
                    {
                        PopWindow pop = new PopWindow(ImageType.Error, "Sorry", "Can't rent time that is before booking time", "Okay");
                        pop.ShowDialog();
                    }
                    else
                    {
                        TimeSpan CheckTime = new TimeSpan(08, 00, 00);
                        TimeSpan endTime   = new TimeSpan(20, 00, 00);

                        if (TPEnd.SelectedTime < CheckTime || TPEnd.SelectedTime > endTime)
                        {
                            PopWindow pop = new PopWindow(ImageType.Error, "Error", "Please rent in working hours about 8am to 8pm", "Okay");
                            pop.ShowDialog();
                        }
                        else
                        {
                            if (TPEnd.SelectedTime - TPStart.SelectedTime <= new TimeSpan(0, 30, 0))
                            {
                                PopWindow pop = new PopWindow(ImageType.Warning, "Too less time", "Please rent At least 30mins", "Okay");
                                pop.ShowDialog();
                            }
                            else
                            {
                                //if bicycle status is Renting, dont rent bike
                                if (Convert.ToString(ResultTable.Rows[0]["BicycleStatus"]) == "R")
                                {
                                    PopWindow pop = new PopWindow(ImageType.Warning, "Sorry", "This Bike has been rented By, " + customer.Trim(), "Okay");
                                    pop.ShowDialog();
                                }
                                //if able to rent start process add
                                else
                                {
                                    double TotalPrice = (((double)duration.TotalHours) * Price);
                                    TotalPrice = System.Math.Round(TotalPrice, 2);


                                    ConfirmWindow confirm = new ConfirmWindow(ImageType.Question, "Confirm?", "Bicycle " + BikeName + ", for Renter " + LBCustomer.Text + ", Duration is " + duration + " Hours, " + " Total Price: RM" + TotalPrice, "Yes, Rent Out", "No, Don't Rent");
                                    confirm.ShowDialog();
                                    if (SnackPanel.Visibility == Visibility.Visible)
                                    {
                                        DataTable ResultTableSnack = MyDAL.SelectSnackBySnackID(CBSnack.SelectedValue.ToString().Trim());
                                        int       Sorter           = Convert.ToInt32(ResultTableSnack.Rows[0]["Quantity"]);
                                        double    price            = Convert.ToDouble(ResultTableSnack.Rows[0]["Price"]) * Convert.ToInt32(TBQuantity.Text);
                                        string    Snack            = Convert.ToString(ResultTableSnack.Rows[0]["SnackName"]).Trim();
                                        confirm = new ConfirmWindow(ImageType.Question, "Confirm?", "Snack: " + Snack + " , Total Price: " + price, "Confirm", "No, Don't Confirm");
                                        confirm.ShowDialog();
                                        if (Sorter >= Convert.ToInt32(TBQuantity.Text) && confirm.Confirmed)
                                        {
                                            MyDAL.AddSnackSales(CBSnack.SelectedValue.ToString().Trim(), Convert.ToInt32(TBQuantity.Text), LBCustomer.Text.Trim(), price, TLUsername.Text.Trim(), BookingID);
                                        }
                                        else if (confirm.Confirmed == false)
                                        {
                                            confirm.Confirmed = false;
                                        }
                                        else
                                        {
                                            PopWindow poper = new PopWindow(ImageType.Warning, "Can't Sale!!", "Item lack of stock, please Restock", "OK");
                                            poper.ShowDialog();
                                            confirm.Confirmed = false;
                                        }
                                    }
                                    //MessageBox.Show("Rented For " + LBCustomer.Text + " Duration is " + Convert.ToString(duration.Hours).Trim() + " Hours","Question",MessageBoxButton.YesNo,MessageBoxImage.Information);
                                    if (confirm.Confirmed)
                                    {
                                        MyDAL.UpdateBikeStatus(Bike, LBCustomer.Text.Trim(), "R", "", null, null, TLUsername.Text);
                                        MyDAL.UpdateBookingDate(Convert.ToDateTime(LBBookingDate.Text), Bike, LBCustomer.Text.Trim(), TotalPrice, "R", TLUsername.Text.Trim(), TPStart.SelectedTime, TPEnd.SelectedTime, TBRemarks.Text);
                                        PopWindow pop = new PopWindow(ImageType.Information, "Success rent", "Bicycle " + BikeName + ", for Renter " + LBCustomer.Text + ", Duration is " + duration + " Hours, " + " Total Price: RM" + TotalPrice + " ,has been Rented", "OK");
                                        CBBike.SelectedIndex = 0;
                                        stack1.Visibility    = Visibility.Hidden;
                                        TPStart.Visibility   = Visibility.Hidden;
                                        TPEnd.Visibility     = Visibility.Hidden;
                                    }
                                    else
                                    {
                                        PopWindow pop = new PopWindow(ImageType.Warning, "Cancel", "Rented Canceled by " + TLUsername.Text, "Okay");
                                        pop.ShowDialog();
                                    }
                                }
                            }
                        }
                    }
                }
                // This is for adding new rent
                else if (TPStart.SelectedTime < DateTime.Now.TimeOfDay)
                {
                    PopWindow pop = new PopWindow(ImageType.Warning, "Sorry", "Can't rent time that is before the current time", "Okay");
                    pop.ShowDialog();
                }
                //Must select a bicycle inorder to proceed next step...
                else if (CBBicycle.SelectedIndex != -1)
                {
                    TimeSpan CheckTime = new TimeSpan(08, 00, 00);
                    TimeSpan endTime   = new TimeSpan(20, 00, 00);

                    if (stack1.Visibility != Visibility.Hidden)
                    {
                        if (TPEnd.SelectedTime < CheckTime || TPEnd.SelectedTime > endTime)
                        {
                            PopWindow pop = new PopWindow(ImageType.Warning, "Error", "Please rent in working hours about 8am to 8pm", "Okay");
                            pop.ShowDialog();
                        }
                        else
                        {
                            if (TPEnd.SelectedTime - TPStart.SelectedTime <= new TimeSpan(0, 30, 0))
                            {
                                PopWindow pop = new PopWindow(ImageType.Warning, "Error", "Please rent At least 30mins", "Okay");
                                pop.ShowDialog();
                            }
                            else
                            {
                                DataTable ResultTable = MyDAL.SelectBicycleByID(CBBicycle.SelectedValue.ToString().Trim());
                                string    Bike        = Convert.ToString(ResultTable.Rows[0]["BicycleID"]);
                                string    BikeName    = Convert.ToString(ResultTable.Rows[0]["BicycleName"]);
                                string    customer    = TBCustomer.Text;

                                //double Deposit = Convert.ToDouble(ResultTable.Rows[0]["BookingDeposit"]);
                                double Price = Convert.ToDouble(ResultTable.Rows[0]["Price"]);

                                if (Convert.ToString(ResultTable.Rows[0]["BicycleStatus"]) == "R")
                                {
                                    PopWindow pop = new PopWindow(ImageType.Warning, "Sorry", "This Bike has been rented By, " + customer.Trim(), "Okay");
                                    pop.ShowDialog();
                                }
                                //if able to rent start process add
                                else
                                {
                                    double TotalPrice = (((double)duration.TotalHours) * Price);
                                    TotalPrice = System.Math.Round(TotalPrice, 2);

                                    ConfirmWindow con = new ConfirmWindow(ImageType.Question, "Confirm", "Bicycle " + BikeName + ", for Renter " + LBCustomer.Text + ", Duration is " + duration + " Hours, " + " Total Price: RM" + TotalPrice, "Yes, Rent", "No, Don't");
                                    con.ShowDialog();
                                    if (SnackPanel.Visibility == Visibility.Visible)
                                    {
                                        DataTable ResultTableSnack = MyDAL.SelectSnackBySnackID(CBSnack.SelectedValue.ToString().Trim());
                                        int       Sorter           = Convert.ToInt32(ResultTableSnack.Rows[0]["Quantity"]);
                                        double    price            = Convert.ToDouble(ResultTableSnack.Rows[0]["Price"]) * Convert.ToInt32(TBQuantity.Text);
                                        string    Snack            = Convert.ToString(ResultTableSnack.Rows[0]["SnackName"]).Trim();
                                        con = new ConfirmWindow(ImageType.Question, "Confirm?", "Snack: " + Snack + " , Total Price: " + price, "Confirm", "No, Don't Confirm");
                                        con.ShowDialog();
                                        if (Sorter >= Convert.ToInt32(TBQuantity.Text) && con.Confirmed)
                                        {
                                            MyDAL.AddSnackSales(CBSnack.SelectedValue.ToString().Trim(), Convert.ToInt32(TBQuantity.Text), LBCustomer.Text.Trim(), price, TLUsername.Text.Trim(), "");
                                        }
                                        else if (con.Confirmed == false)
                                        {
                                            con.Confirmed = false;
                                        }
                                        else
                                        {
                                            PopWindow poper = new PopWindow(ImageType.Warning, "Can't Sale!!", "Item lack of stock, please Restock", "OK");
                                            poper.ShowDialog();
                                            con.Confirmed = false;
                                        }
                                    }
                                    //MessageBox.Show("Rented For " + LBCustomer.Text + " Duration is " + Convert.ToString(duration.Hours).Trim() + " Hours","Question",MessageBoxButton.YesNo,MessageBoxImage.Information);
                                    if (con.Confirmed)
                                    {
                                        MyDAL.AddBookingTime(DateTime.Now.Date, Bike, "R", LBCustomer.Text.Trim(), TotalPrice, TLUsername.Text.Trim(), TPStart.SelectedTime, TPEnd.SelectedTime, TBRemarks.Text);

                                        PopWindow pop = new PopWindow(ImageType.Information, "Complete", "Rented Out by " + TLUsername.Text, "Okay");
                                        pop.ShowDialog();
                                        TBCustomer.Text         = "";
                                        CBBicycle.SelectedIndex = 0;
                                        stack1.Visibility       = Visibility.Hidden;
                                        TPStart.Visibility      = Visibility.Hidden;
                                        TPEnd.Visibility        = Visibility.Hidden;
                                    }
                                    else
                                    {
                                        PopWindow pop = new PopWindow(ImageType.Warning, "Cancel", "Rented Canceled by " + TLUsername.Text, "Okay");
                                        pop.ShowDialog();
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        PopWindow pop = new PopWindow(ImageType.Warning, "Sorry", "Please Click next to proceed rental", "Ok");
                        pop.ShowDialog();
                    }
                }
                BindComboBox(CBBike);
            }
            catch (Exception ex)
            {
                PopWindow pop = new PopWindow(ImageType.Information, "Error", ex.Message, "I will Fix this");
                pop.ShowDialog();
            }
        }
Example #21
0
        public void PopulateID(string ID, string Category, string Status)
        {
            MainStatus = Status;
            TBikeDAL MyDAL = new TBikeDAL();

            if (Status == "Modification")
            {
                BTNPro.Content       = "Update";
                BtnDelete.Visibility = Visibility.Visible;
                if (Category == "Bicycle")
                {
                    LBTitle.Text = "Bicycle";
                    DataTable ResultTable = MyDAL.SelectBicycleByID(ID);
                    if (ResultTable.Rows.Count != 0)
                    {
                        if (RankID > 3)
                        {
                            CBStatus.Visibility = Visibility.Visible;
                            LBStatus.Visibility = Visibility.Visible;
                        }

                        LBID.Text    = ID;
                        TBName.Text  = Convert.ToString(ResultTable.Rows[0]["BicycleName"]).Trim();
                        TBType.Text  = Convert.ToString(ResultTable.Rows[0]["BicycleType"]).Trim();
                        TBPrice.Text = Convert.ToString(ResultTable.Rows[0]["Price"]).Trim();
                        TBColor.Text = Convert.ToString(ResultTable.Rows[0]["Color"]).Trim();
                        string BikeStatus = Convert.ToString(ResultTable.Rows[0]["BicycleStatus"]).Trim();
                        TBQuantity.Text = Convert.ToString(ResultTable.Rows[0]["Quantity"]).Trim();

                        if (BikeStatus == "A")
                        {
                            CBStatus.SelectedIndex = 0;
                            ItemStatus             = "A";
                        }
                        else if (BikeStatus == "E")
                        {
                            CBStatus.SelectedIndex = 1;
                            ItemStatus             = "E";
                        }
                        else if (BikeStatus == "N")
                        {
                            CBStatus.SelectedIndex = 2;
                            ItemStatus             = "N";
                        }
                        else if (BikeStatus == "S")
                        {
                            CBStatus.SelectedIndex = 3;
                            ItemStatus             = "S";
                        }
                        else if (BikeStatus == "R")
                        {
                            CBStatus.SelectedIndex = 4;
                            ItemStatus             = "R";
                        }
                        else if (BikeStatus == "I")
                        {
                            CBStatus.SelectedIndex = 5;
                            ItemStatus             = "I";
                        }
                        else if (BikeStatus == "M")
                        {
                            CBStatus.SelectedIndex = 6;
                            ItemStatus             = "M";
                        }
                        PopulateBikeDataTable();
                    }
                    else
                    {
                        PopWindow pop = new PopWindow(ImageType.Information, "Error", "No data Found!!!", "OK");
                        pop.ShowDialog();
                    }
                }
                else if (Category == "Snacks")
                {
                    if (RankID > 3)
                    {
                        CBSnackStatus.Visibility = Visibility.Visible;
                        LBStatus.Visibility      = Visibility.Visible;
                    }
                    LBTitle.Text = "Snacks";
                    LBColor.Text = "Quantity";
                    DataTable ResultTable = MyDAL.SelectSnackByID(ID);
                    if (ResultTable.Rows.Count != 0)
                    {
                        LBID.Text = ID;
                    }
                    TBName.Text  = Convert.ToString(ResultTable.Rows[0]["SnackName"]).Trim();
                    TBType.Text  = Convert.ToString(ResultTable.Rows[0]["SnackType"]).Trim();
                    TBPrice.Text = Convert.ToString(ResultTable.Rows[0]["Price"]).Trim();
                    TBColor.Text = Convert.ToString(ResultTable.Rows[0]["Quantity"]).Trim();

                    CBSnackStatus.SelectedIndex = ComboIndex;
                    PopulateSnackDataTable();
                }
                else
                {
                    PopWindow pop = new PopWindow(ImageType.Information, "Error", "Incorrect Category", "OK");
                    pop.ShowDialog();
                }
            }

            else if (Status == "Add")
            {
                LBTitle.Text         = Category;
                LBID.Text            = "** New **";
                BTNPro.Content       = "Add";
                BtnDelete.Visibility = Visibility.Hidden;
                if (Category == "Snacks")
                {
                    LBColor.Text = "Quantity";
                    PopulateSnackDataTable();
                }
                else if (Category == "Bicycle")
                {
                    PopulateBikeDataTable();
                }
            }
        }
Example #22
0
        public async void VerifyRequirements()
        {
            TBikeDAL  MyDal               = new TBikeDAL();
            DataTable ResultTable         = MyDal.SelectEmployeeID("", TBUsername.Text);
            DataTable ResultTableEmployee = MyDal.ShowAllEmployeeDetails();
            int       i = 0;
            int       a = 0;
            string    Email;

            foreach (DataRow row in ResultTableEmployee.Rows)
            {
                Email = Convert.ToString(ResultTableEmployee.Rows[i]["Email"]);
                if (Email == TBEmail.Text)
                {
                    a = a + 1;
                }


                i++;
            }


            if (ResultTable.Rows.Count > 0)
            {
                if (TBUsername.Text == Convert.ToString(ResultTable.Rows[0]["Username"]).Trim())
                {
                    PopWindow pop = new PopWindow(ImageType.Information, "Error", "Username has been used", "ok, i will check again");
                    pop.ShowDialog();
                }



                else if (TBConfirmPassword != TBPassword)
                {
                    var res = await this.ShowMessageAsync("Password Not Match", "Password not match with confirm pasword");
                }

                //TLRankDesc.Text = Convert.ToString(ResultTable.Rows[0]["EmployeeRankDesc"]).Trim();
                //username = Convert.ToString(ResultTable.Rows[0]["Username"]).Trim();
                //RankID = Convert.ToInt32(ResultTable.Rows[0]["EmployeeRank"]);
            }
            else
            {
                if ((TBConfirmPassword.Password.ToString().Trim()) != (TBPassword.Password.ToString().Trim()))
                {
                    var res = await this.ShowMessageAsync("Password Not Match", "Password not match with confirm pasword");
                }
                else if (a == 0)
                {
                    var res = await this.ShowMessageAsync("Sorry", "This Email has no record");
                }
                else
                {
                    //var res = await this.ShowMessageAsync("No Record", "No Email address record found ");
                    MyDal.AddNewEmployeeLoginInfo(TBEmail.Text, TBUsername.Text, TBPassword.Password.ToString().Trim());
                    var res = await this.ShowMessageAsync("Registration Completed", " Please go back and Login");

                    this.Close();
                }
            }
        }