private void UpdateJob()
        {
            if (!NotDefaultValues())
            {
                Update_Job_Error_TextBlock.Visibility = Visibility.Visible;
                Update_Job_Error_TextBlock.Text       = "Nothing to update";
                return;
            }
            Update_Job_Error_TextBlock.Visibility = Visibility.Collapsed;
            string updatedJobStatus = Update_Job_Job_Status_ComboBox.Text;

            try
            {
                Job updatedJob = new Job()
                {
                    Job_Number = selectedJob.Job_Number,
                    Job_Status = updatedJobStatus
                };
                DataController.GetInstance.StartTransaction();
                if (DataController.GetInstance.UpdateJob(updatedJob) &&
                    DataController.GetInstance.InsertLog(new List <Log>()
                {
                    new Log()
                    {
                        Log_Date_Time = DateTime.Now,
                        Log_Performed_Action = "Job Updated",
                        Log_Job_Number = updatedJob.Job_Number,
                        Log_User = GlobalSingleton.GetInstance.Logged_In_User.User_Name
                    }
                }))
                {
                    DataController.GetInstance.Commit();
                    MessageBox.Show("Job " + selectedJob.Job_Number + " successfully updated");
                    mainWindow.RefreshAllData();
                    isUpdateButtonPressed = true;
                    Close();
                }
                else
                {
                    DataController.GetInstance.Rollback();
                    Update_Job_Error_TextBlock.Visibility = Visibility.Visible;
                    Update_Job_Error_TextBlock.Text       = "Something went wrong";
                }
            }
            catch (MySqlException ex)
            {
                Update_Job_Error_TextBlock.Visibility = Visibility.Visible;
                Update_Job_Error_TextBlock.Text       = ex.Message;
            }
        }
        private void ReturnPart()
        {
            if (selectedJob.Job_Status.Equals("Closed"))
            {
                MessageBox.Show("Job " + selectedJob.Job_Number + " is closed");
                return;
            }
            bool   isValidEntries = true;
            string partNumber = "", partDescription = "", jobNumber = "";
            int    partQuantity = -1;

            if (Return_Part_Part_Number_ComboBox.SelectedItem == null)
            {
                Return_Part_Part_Number_Error_TextBlock.Visibility = Visibility.Visible;
                Return_Part_Part_Number_Error_TextBlock.Text       = "*Please select a part number";
                isValidEntries = false;
            }
            else
            {
                Return_Part_Part_Number_Error_TextBlock.Visibility = Visibility.Collapsed;
                partNumber = Return_Part_Part_Number_ComboBox.Text;
            }
            if (Return_Part_Part_Description_ComboBox.SelectedItem == null)
            {
                Return_Part_Part_Description_Error_TextBlock.Visibility = Visibility.Visible;
                Return_Part_Part_Description_Error_TextBlock.Text       = "*Please select a part description";
                isValidEntries = false;
            }
            else
            {
                Return_Part_Part_Description_Error_TextBlock.Visibility = Visibility.Collapsed;
                partDescription = Return_Part_Part_Description_ComboBox.Text;
            }
            if (selectedJob == null)
            {
                Return_Part_Job_Number_Error_TextBlock.Visibility = Visibility.Visible;
                Return_Part_Job_Number_Error_TextBlock.Text       = "*Please select a job number";
                isValidEntries = false;
            }
            else
            {
                Return_Part_Job_Number_Error_TextBlock.Visibility = Visibility.Collapsed;
                jobNumber = Return_Part_Job_Number_ComboBox.Text;
            }
            if (Return_Part_Part_Quantity_TextBox.Text.Length == 0)
            {
                Return_Part_Part_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                Return_Part_Part_Quantity_Error_TextBlock.Text       = "*Please enter a value";
                isValidEntries = false;
            }
            else
            {
                bool isValidNumber = int.TryParse(Return_Part_Part_Quantity_TextBox.Text, out partQuantity);
                if (!isValidNumber)
                {
                    Return_Part_Part_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                    Return_Part_Part_Quantity_Error_TextBlock.Text       = "Please enter a valid number";
                    isValidEntries = false;
                }
                else
                {
                    if (partQuantity <= 0)
                    {
                        Return_Part_Part_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                        Return_Part_Part_Quantity_Error_TextBlock.Text       = "Please enter a value greater than zero";
                        isValidEntries = false;
                    }
                    else
                    {
                        Return_Part_Part_Quantity_Error_TextBlock.Visibility = Visibility.Collapsed;
                    }
                }
            }
            if (isValidEntries)
            {
                try
                {
                    if (DataController.GetInstance.JobPartReturnNotZero(partNumber, partQuantity, jobNumber))
                    {
                        Return_Part_Part_Number_Error_TextBlock.Visibility      = Visibility.Collapsed;
                        Return_Part_Part_Description_Error_TextBlock.Visibility = Visibility.Collapsed;
                        Return_Part_Job_Number_Error_TextBlock.Visibility       = Visibility.Collapsed;
                        Return_Part_Part_Quantity_Error_TextBlock.Visibility    = Visibility.Collapsed;
                        DataController.GetInstance.StartTransaction();
                        if (DataController.GetInstance.JobPartReturnNotZero(partNumber, partQuantity, jobNumber) &&
                            DataController.GetInstance.ReturnJobPart(partNumber, jobNumber, partQuantity) &&
                            DataController.GetInstance.CheckInPart(partNumber, partQuantity) &&
                            DataController.GetInstance.ClearJobEmptyParts(jobNumber) &&
                            DataController.GetInstance.InsertLog(new List <Log>()
                        {
                            new Log()
                            {
                                Log_Part_Number = partNumber,
                                Log_Part_Description = partDescription,
                                Log_Part_Quantity = partQuantity,
                                Log_Job_Number = jobNumber,
                                Log_Performed_Action = "Part Returned",
                                Log_Date_Time = DateTime.Now,
                                Log_User = GlobalSingleton.GetInstance.Logged_In_User.User_Name
                            }
                        }))
                        {
                            DataController.GetInstance.Commit();
                            MessageBox.Show("Part " + partNumber + " successfully returned");
                            mainWindow.RefreshAllData();
                            isReturnButtonPressed = true;
                            Close();
                        }
                        else
                        {
                            DataController.GetInstance.Rollback();
                            Return_Part_Part_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                            Return_Part_Part_Quantity_Error_TextBlock.Text       = "Something went wrong!";
                        }
                    }
                    else
                    {
                        Return_Part_Part_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                        Return_Part_Part_Quantity_Error_TextBlock.Text       = "This return will result in a negative part quantity for this part in this job!";
                    }
                }
                catch (MySqlException ex)
                {
                    DataController.GetInstance.Rollback();
                    Return_Part_Part_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                    Return_Part_Part_Quantity_Error_TextBlock.Text       = ex.Message;
                }
            }
        }
        private void PartOrdered(string action)
        {
            string orderedPartNumber = "", orderedPartDescription = "";
            string orderedPartSupplier   = Part_Ordered_Part_Supplier_TextBox.Text;
            string orderedPartCostPrice  = Part_Ordered_Part_Cost_Price_TextBox.Text;
            string orderedPartMarkupPerc = Part_Ordered_Part_Markup_Perc_TextBox.Text;
            string orderedPartSellPrice  = Part_Ordered_Part_Sell_Price_TextBox.Text;
            string orderedPartQuantity   = Part_Ordered_Part_Quantity_TextBox.Text;

            bool orderedPartSellPriceFixed = Part_Ordered_Part_Sell_Price_Fixed_CheckBox.IsChecked.Value;

            double orderedPartCostPriceValue = -1, orderedPartMarkupPercValue = -1, orderedPartSellPriceValue = -1;

            int orderedPartQuantityValue = -1;

            bool isValidEntries = true;

            if (Part_Ordered_Part_Number_ComboBox.SelectedItem == null)
            {
                Part_Ordered_Part_Number_Error_TextBlock.Visibility = Visibility.Visible;
                Part_Ordered_Part_Number_Error_TextBlock.Text       = "*Please select a part number";
                isValidEntries = false;
            }
            else
            {
                Part_Ordered_Part_Number_Error_TextBlock.Visibility = Visibility.Collapsed;
                orderedPartNumber = Part_Ordered_Part_Number_ComboBox.Text;
            }

            if (Part_Ordered_Part_Description_ComboBox.SelectedItem == null)
            {
                Part_Ordered_Part_Description_Error_TextBlock.Visibility = Visibility.Visible;
                Part_Ordered_Part_Description_Error_TextBlock.Text       = "*Please select a part description";
                isValidEntries = false;
            }
            else
            {
                Part_Ordered_Part_Description_Error_TextBlock.Visibility = Visibility.Collapsed;
                orderedPartDescription = Part_Ordered_Part_Description_ComboBox.Text;
            }

            if (orderedPartSupplier.Length == 0)
            {
                Part_Ordered_Part_Supplier_Error_TextBlock.Visibility = Visibility.Visible;
                Part_Ordered_Part_Supplier_Error_TextBlock.Text       = "*Please enter a part supplier";
                isValidEntries = false;
            }
            else
            {
                Part_Ordered_Part_Supplier_Error_TextBlock.Visibility = Visibility.Collapsed;
            }

            if (orderedPartCostPrice.Length == 0)
            {
                Part_Ordered_Part_Cost_Price_Error_TextBlock.Visibility = Visibility.Visible;
                Part_Ordered_Part_Cost_Price_Error_TextBlock.Text       = "*Please enter a value";
                isValidEntries = false;
            }
            else
            {
                bool isValidNumber = double.TryParse(orderedPartCostPrice, out orderedPartCostPriceValue);
                if (!isValidNumber)
                {
                    Part_Ordered_Part_Cost_Price_Error_TextBlock.Visibility = Visibility.Visible;
                    Part_Ordered_Part_Cost_Price_Error_TextBlock.Text       = "*Please enter a valid number";
                    isValidEntries = false;
                }
                else
                {
                    if (orderedPartCostPriceValue < 0)
                    {
                        Part_Ordered_Part_Cost_Price_Error_TextBlock.Visibility = Visibility.Visible;
                        Part_Ordered_Part_Cost_Price_Error_TextBlock.Text       = "*Cannot enter a value less than zero";
                        isValidEntries = false;
                    }
                    else
                    {
                        Part_Ordered_Part_Cost_Price_Error_TextBlock.Visibility = Visibility.Collapsed;
                    }
                }
            }

            if (orderedPartMarkupPerc.Length == 0)
            {
                isValidEntries = false;
                Part_Ordered_Part_Markup_Perc_Error_TextBlock.Visibility = Visibility.Visible;
                Part_Ordered_Part_Markup_Perc_Error_TextBlock.Text       = "*Please enter a value";
            }
            else
            {
                bool validNumber = double.TryParse(orderedPartMarkupPerc, out orderedPartMarkupPercValue);
                if (!validNumber)
                {
                    isValidEntries = false;
                    Part_Ordered_Part_Markup_Perc_Error_TextBlock.Visibility = Visibility.Visible;
                    Part_Ordered_Part_Markup_Perc_Error_TextBlock.Text       = "*Please enter a valid number";
                }
                else
                {
                    if (orderedPartMarkupPercValue < 0)
                    {
                        isValidEntries = false;
                        Part_Ordered_Part_Markup_Perc_Error_TextBlock.Visibility = Visibility.Visible;
                        Part_Ordered_Part_Markup_Perc_Error_TextBlock.Text       = "*Markup percentage cannot be less than zero";
                    }
                    else
                    {
                        Part_Ordered_Part_Markup_Perc_Error_TextBlock.Visibility = Visibility.Collapsed;
                    }
                }
            }
            if (orderedPartSellPrice.Length == 0)
            {
                isValidEntries = false;
                Part_Ordered_Part_Sell_Price_Error_TextBlock.Visibility = Visibility.Visible;
                Part_Ordered_Part_Sell_Price_Error_TextBlock.Text       = "*Please enter a value";
            }
            else
            {
                bool validNumber = double.TryParse(orderedPartSellPrice, out orderedPartSellPriceValue);
                if (!validNumber)
                {
                    isValidEntries = false;
                    Part_Ordered_Part_Sell_Price_Error_TextBlock.Visibility = Visibility.Visible;
                    Part_Ordered_Part_Sell_Price_Error_TextBlock.Text       = "*Please enter a valid number";
                }
                else
                {
                    if (orderedPartSellPriceValue < 0)
                    {
                        isValidEntries = false;
                        Part_Ordered_Part_Sell_Price_Error_TextBlock.Visibility = Visibility.Visible;
                        Part_Ordered_Part_Sell_Price_Error_TextBlock.Text       = "*Sell price cannot be less than zero";
                    }
                    else
                    {
                        Part_Ordered_Part_Sell_Price_Error_TextBlock.Visibility = Visibility.Collapsed;
                    }
                }
            }

            if (orderedPartQuantity.Length == 0)
            {
                Part_Ordered_Part_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                Part_Ordered_Part_Quantity_Error_TextBlock.Text       = "*Please enter a value";
                isValidEntries = false;
            }
            else
            {
                bool isValidNumber = int.TryParse(orderedPartQuantity, out orderedPartQuantityValue);
                if (!isValidNumber)
                {
                    Part_Ordered_Part_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                    Part_Ordered_Part_Quantity_Error_TextBlock.Text       = "*Please enter a valid number";
                    isValidEntries = false;
                }
                else
                {
                    if (orderedPartQuantityValue <= 0)
                    {
                        Part_Ordered_Part_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                        Part_Ordered_Part_Quantity_Error_TextBlock.Text       = "*Please enter a value greater than zero";
                        isValidEntries = false;
                    }
                    else
                    {
                        Part_Ordered_Part_Quantity_Error_TextBlock.Visibility = Visibility.Collapsed;
                    }
                }
            }
            if (isValidEntries)
            {
                try
                {
                    Part_Ordered_Part_Number_Error_TextBlock.Visibility      = Visibility.Collapsed;
                    Part_Ordered_Part_Description_Error_TextBlock.Visibility = Visibility.Collapsed;
                    Part_Ordered_Part_Supplier_Error_TextBlock.Visibility    = Visibility.Collapsed;
                    Part_Ordered_Part_Cost_Price_Error_TextBlock.Visibility  = Visibility.Collapsed;
                    Part_Ordered_Part_Markup_Perc_Error_TextBlock.Visibility = Visibility.Collapsed;
                    Part_Ordered_Part_Sell_Price_Error_TextBlock.Visibility  = Visibility.Collapsed;
                    Part_Ordered_Part_Quantity_Error_TextBlock.Visibility    = Visibility.Collapsed;
                    Part_Ordered_Error_TextBlock.Visibility = Visibility.Collapsed;
                    Part part = new Part()
                    {
                        Part_Number            = orderedPartNumber,
                        Part_Supplier          = orderedPartSupplier,
                        Part_Cost_Price        = orderedPartCostPriceValue,
                        Part_Markup_Percentage = orderedPartMarkupPercValue,
                        Part_Sell_Price        = orderedPartSellPriceValue,
                        Part_Sell_Price_Fixed  = orderedPartSellPriceFixed,
                        Part_Ordered_Quantity  = orderedPartQuantityValue
                    };
                    DataController.GetInstance.StartTransaction();
                    if (DataController.GetInstance.PartOrdered(part) &&
                        DataController.GetInstance.InsertLog(new List <Log>()
                    {
                        new Log()
                        {
                            Log_Part_Number = part.Part_Number,
                            Log_Part_Description = part.Part_Description,
                            Log_Part_Quantity = orderedPartQuantityValue,
                            Log_Performed_Action = "Part Ordered",
                            Log_Date_Time = DateTime.Now,
                            Log_User = GlobalSingleton.GetInstance.Logged_In_User.User_Name
                        }
                    }))
                    {
                        DataController.GetInstance.Commit();
                        MessageBox.Show("Part " + part.Part_Number + " successfully ordered");
                        mainWindow.RefreshAllData();
                        if (action.Equals("Next"))
                        {
                            Part_Ordered_Part_Number_ComboBox.SelectedIndex      = -1;
                            Part_Ordered_Part_Description_ComboBox.SelectedIndex = -1;
                            Part_Ordered_Part_Quantity_TextBox.Text = "0";
                        }
                        else
                        {
                            if (pow != null)
                            {
                                pow.RefreshPurchaseOrderList();
                            }
                            isOkButtonPressed = true;
                            Close();
                        }
                    }
                    else
                    {
                        DataController.GetInstance.Rollback();
                        Part_Ordered_Error_TextBlock.Visibility = Visibility.Visible;
                        Part_Ordered_Error_TextBlock.Text       = "Something went wrong!";
                    }
                }
                catch (MySqlException ex)
                {
                    DataController.GetInstance.Rollback();
                    Part_Ordered_Error_TextBlock.Visibility = Visibility.Visible;
                    Part_Ordered_Error_TextBlock.Text       = ex.Message;
                }
            }
        }
        private void AddNewJob()
        {
            string newJobNumber   = New_Job_Job_Number_TextBox.Text;
            bool   isValidEntries = true;

            if (newJobNumber.Length == 0)
            {
                isValidEntries = false;
                New_Job_Job_Number_Error_TextBlock.Visibility = Visibility.Visible;
                New_Job_Job_Number_Error_TextBlock.Text       = "*Please enter a job number";
            }
            else
            {
                if (DataController.GetInstance.CheckIfJobNumberExists(newJobNumber))
                {
                    isValidEntries = false;
                    New_Job_Job_Number_Error_TextBlock.Visibility = Visibility.Visible;
                    New_Job_Job_Number_Error_TextBlock.Text       = "*Job number already in use";
                }
                else
                {
                    New_Job_Job_Number_Error_TextBlock.Visibility = Visibility.Collapsed;
                }
            }
            if (isValidEntries)
            {
                New_Job_Job_Number_Error_TextBlock.Visibility = Visibility.Collapsed;
                try
                {
                    DataController.GetInstance.StartTransaction();
                    if (DataController.GetInstance.InsertNewJob(newJobNumber) &&
                        DataController.GetInstance.InsertLog(new List <Log>()
                    {
                        new Log()
                        {
                            Log_Date_Time = DateTime.Now,
                            Log_Performed_Action = "New Job",
                            Log_Job_Number = newJobNumber,
                            Log_User = GlobalSingleton.GetInstance.Logged_In_User.User_Name
                        }
                    }))
                    {
                        DataController.GetInstance.Commit();
                        MessageBox.Show("New job " + newJobNumber + " successfully created");
                        mainWindow.RefreshAllData();
                        isAddButtonPressed = true;
                        Close();
                    }
                    else
                    {
                        DataController.GetInstance.Rollback();
                        New_Job_Job_Number_Error_TextBlock.Visibility = Visibility.Visible;
                        New_Job_Job_Number_Error_TextBlock.Text       = "Something went wrong";
                    }
                }
                catch (MySqlException ex)
                {
                    DataController.GetInstance.Rollback();
                    New_Job_Job_Number_Error_TextBlock.Visibility = Visibility.Visible;
                    New_Job_Job_Number_Error_TextBlock.Text       = ex.Message;
                }
            }
        }
        private void AddNewPart()
        {
            bool isValidEntries = true;

            string newPartNumber         = New_Part_Part_Number_TextBox.Text;
            string newPartDescription    = New_Part_Part_Description_TextBox.Text;
            string newPartSupplier       = New_Part_Part_Supplier_TextBox.Text;
            string newPartCurQuantity    = New_Part_Part_Cur_Quantity_TextBox.Text;
            string newPartOrdQuantity    = New_Part_Part_Ord_Quantity_TextBox.Text;
            string newPartMinQuantity    = New_Part_Part_Min_Quantity_TextBox.Text;
            string newPartMaxQuantity    = New_Part_Part_Max_Quantity_TextBox.Text;
            string newPartCostPrice      = New_Part_Part_Cost_Price_TextBox.Text;
            string newPartMarkupPerc     = New_Part_Part_Markup_Perc_TextBox.Text;
            string newPartSellPrice      = New_Part_Part_Sell_Price_TextBox.Text;
            bool   newPartSellPriceFixed = New_Part_Part_Sell_Price_Fixed_CheckBox.IsChecked.Value;

            int newPartCurQuantityValue = -1, newPartOrdQuantityValue = -1, newPartMinQuantityValue = -1,
                newPartMaxQuantityValue = -1;
            double newPartCostPriceValue = -1, newPartMarkupPercValue = -1, newPartSellPriceValue = -1;

            if (newPartNumber.Length == 0)
            {
                isValidEntries = false;
                New_Part_Part_Number_Error_TextBlock.Visibility = Visibility.Visible;
                New_Part_Part_Number_Error_TextBlock.Text       = "*Please enter a part number";
            }
            else
            {
                if (DataController.GetInstance.CheckIfPartNumberExists(newPartNumber))
                {
                    isValidEntries = false;
                    New_Part_Part_Number_Error_TextBlock.Visibility = Visibility.Visible;
                    New_Part_Part_Number_Error_TextBlock.Text       = "*Part number already in use";
                }
                else
                {
                    New_Part_Part_Number_Error_TextBlock.Visibility = Visibility.Collapsed;
                }
            }

            if (newPartDescription.Length == 0)
            {
                isValidEntries = false;
                New_Part_Part_Description_Error_TextBlock.Visibility = Visibility.Visible;
                New_Part_Part_Description_Error_TextBlock.Text       = "*Please enter a part description";
            }
            else
            {
                New_Part_Part_Description_Error_TextBlock.Visibility = Visibility.Collapsed;
            }

            if (newPartSupplier.Length == 0)
            {
                isValidEntries = false;
                New_Part_Part_Supplier_Error_TextBlock.Visibility = Visibility.Visible;
                New_Part_Part_Supplier_Error_TextBlock.Text       = "*Please enter a part supplier";
            }
            else
            {
                New_Part_Part_Supplier_Error_TextBlock.Visibility = Visibility.Collapsed;
            }

            if (newPartCurQuantity.Length == 0)
            {
                isValidEntries = false;
                New_Part_Part_Cur_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                New_Part_Part_Cur_Quantity_Error_TextBlock.Text       = "*Please enter a value";
            }
            else
            {
                bool validNumber = int.TryParse(newPartCurQuantity, out newPartCurQuantityValue);
                if (!validNumber)
                {
                    isValidEntries = false;
                    New_Part_Part_Cur_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                    New_Part_Part_Cur_Quantity_Error_TextBlock.Text       = "*Please enter a valid number";
                }
                else
                {
                    if (newPartCurQuantityValue < 0)
                    {
                        isValidEntries = false;
                        New_Part_Part_Cur_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                        New_Part_Part_Cur_Quantity_Error_TextBlock.Text       = "*Current quantity cannot be less than zero";
                    }
                    else
                    {
                        New_Part_Part_Cur_Quantity_Error_TextBlock.Visibility = Visibility.Collapsed;
                    }
                }
            }

            if (newPartOrdQuantity.Length == 0)
            {
                isValidEntries = false;
                New_Part_Part_Ord_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                New_Part_Part_Ord_Quantity_Error_TextBlock.Text       = "*Please enter a value";
            }
            else
            {
                bool validNumber = int.TryParse(newPartOrdQuantity, out newPartOrdQuantityValue);
                if (!validNumber)
                {
                    isValidEntries = false;
                    New_Part_Part_Ord_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                    New_Part_Part_Ord_Quantity_Error_TextBlock.Text       = "*Please enter a valid number";
                }
                else
                {
                    if (newPartOrdQuantityValue < 0)
                    {
                        isValidEntries = false;
                        New_Part_Part_Ord_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                        New_Part_Part_Ord_Quantity_Error_TextBlock.Text       = "*Ordered quantity cannot be less than zero";
                    }
                    else
                    {
                        New_Part_Part_Ord_Quantity_Error_TextBlock.Visibility = Visibility.Collapsed;
                    }
                }
            }

            if (newPartMinQuantity.Length == 0)
            {
                isValidEntries = false;
                New_Part_Part_Min_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                New_Part_Part_Min_Quantity_Error_TextBlock.Text       = "*Please enter a value";
            }
            else
            {
                bool validNumber = int.TryParse(newPartMinQuantity, out newPartMinQuantityValue);
                if (!validNumber)
                {
                    isValidEntries = false;
                    New_Part_Part_Min_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                    New_Part_Part_Min_Quantity_Error_TextBlock.Text       = "*Please enter a valid number";
                }
                else
                {
                    if (newPartMinQuantityValue < 0)
                    {
                        isValidEntries = false;
                        New_Part_Part_Min_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                        New_Part_Part_Min_Quantity_Error_TextBlock.Text       = "*Minimum quantity cannot be less than zero";
                    }
                    else
                    {
                        New_Part_Part_Min_Quantity_Error_TextBlock.Visibility = Visibility.Collapsed;
                    }
                }
            }

            if (newPartMaxQuantity.Length == 0)
            {
                isValidEntries = false;
                New_Part_Part_Max_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                New_Part_Part_Max_Quantity_Error_TextBlock.Text       = "*Please enter a value";
            }
            else
            {
                bool validNumber = int.TryParse(newPartMaxQuantity, out newPartMaxQuantityValue);
                if (!validNumber)
                {
                    isValidEntries = false;
                    New_Part_Part_Max_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                    New_Part_Part_Max_Quantity_Error_TextBlock.Text       = "*Please enter a valid number";
                }
                else
                {
                    if (newPartMaxQuantityValue < 0)
                    {
                        isValidEntries = false;
                        New_Part_Part_Max_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                        New_Part_Part_Max_Quantity_Error_TextBlock.Text       = "*Maximum quantity cannot be less than zero";
                    }
                    else
                    {
                        New_Part_Part_Max_Quantity_Error_TextBlock.Visibility = Visibility.Collapsed;
                    }
                }
            }

            if (newPartCostPrice.Length == 0)
            {
                isValidEntries = false;
                New_Part_Part_Cost_Price_Error_TextBlock.Visibility = Visibility.Visible;
                New_Part_Part_Cost_Price_Error_TextBlock.Text       = "*Please enter a value";
            }
            else
            {
                bool validNumber = double.TryParse(newPartCostPrice, out newPartCostPriceValue);
                if (!validNumber)
                {
                    isValidEntries = false;
                    New_Part_Part_Cost_Price_Error_TextBlock.Visibility = Visibility.Visible;
                    New_Part_Part_Cost_Price_Error_TextBlock.Text       = "*Please enter a valid number";
                }
                else
                {
                    if (newPartCostPriceValue < 0)
                    {
                        isValidEntries = false;
                        New_Part_Part_Cost_Price_Error_TextBlock.Visibility = Visibility.Visible;
                        New_Part_Part_Cost_Price_Error_TextBlock.Text       = "*Cost price cannot be less than zero";
                    }
                    else
                    {
                        New_Part_Part_Cost_Price_Error_TextBlock.Visibility = Visibility.Collapsed;
                    }
                }
            }
            if (newPartMarkupPerc.Length == 0)
            {
                isValidEntries = false;
                New_Part_Part_Markup_Perc_Error_TextBlock.Visibility = Visibility.Visible;
                New_Part_Part_Markup_Perc_Error_TextBlock.Text       = "*Please enter a value";
            }
            else
            {
                bool validNumber = double.TryParse(newPartMarkupPerc, out newPartMarkupPercValue);
                if (!validNumber)
                {
                    isValidEntries = false;
                    New_Part_Part_Markup_Perc_Error_TextBlock.Visibility = Visibility.Visible;
                    New_Part_Part_Markup_Perc_Error_TextBlock.Text       = "*Please enter a valid number";
                }
                else
                {
                    if (newPartMarkupPercValue < 0.00)
                    {
                        isValidEntries = false;
                        New_Part_Part_Markup_Perc_Error_TextBlock.Visibility = Visibility.Visible;
                        New_Part_Part_Markup_Perc_Error_TextBlock.Text       = "*Markup percentage cannot be less than zero";
                    }
                    else
                    {
                        New_Part_Part_Markup_Perc_Error_TextBlock.Visibility = Visibility.Collapsed;
                    }
                }
            }

            if (newPartSellPrice.Length == 0)
            {
                isValidEntries = false;
                New_Part_Part_Sell_Price_Error_TextBlock.Visibility = Visibility.Visible;
                New_Part_Part_Sell_Price_Error_TextBlock.Text       = "*Please enter a value";
            }
            else
            {
                bool validNumber = double.TryParse(newPartSellPrice, out newPartSellPriceValue);
                if (!validNumber)
                {
                    isValidEntries = false;
                    New_Part_Part_Sell_Price_Error_TextBlock.Visibility = Visibility.Visible;
                    New_Part_Part_Sell_Price_Error_TextBlock.Text       = "*Please enter a valid number";
                }
                else
                {
                    if (newPartSellPriceValue < 0.00)
                    {
                        isValidEntries = false;
                        New_Part_Part_Sell_Price_Error_TextBlock.Visibility = Visibility.Visible;
                        New_Part_Part_Sell_Price_Error_TextBlock.Text       = "*Sell price cannot be less than zero";
                    }
                    else
                    {
                        New_Part_Part_Sell_Price_Error_TextBlock.Visibility = Visibility.Collapsed;
                    }
                }
            }

            if (newPartMinQuantityValue > newPartMaxQuantityValue)
            {
                isValidEntries = false;
                if (New_Part_Part_Min_Quantity_Error_TextBlock.Visibility == Visibility.Collapsed)
                {
                    New_Part_Part_Min_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                    New_Part_Part_Min_Quantity_Error_TextBlock.Text       = "*Minimum part quantity cannot be less than maximum part quantity";
                }
                if (New_Part_Part_Max_Quantity_Error_TextBlock.Visibility == Visibility.Collapsed)
                {
                    New_Part_Part_Max_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                    New_Part_Part_Max_Quantity_Error_TextBlock.Text       = "*Minimum part quantity cannot be less than maximum part quantity";
                }
            }
            else
            {
                New_Part_Part_Min_Quantity_Error_TextBlock.Visibility = Visibility.Collapsed;
                New_Part_Part_Max_Quantity_Error_TextBlock.Visibility = Visibility.Collapsed;
            }
            if (newPartCostPriceValue > newPartSellPriceValue)
            {
                isValidEntries = false;
                if (New_Part_Part_Sell_Price_Error_TextBlock.Visibility == Visibility.Collapsed)
                {
                    New_Part_Part_Sell_Price_Error_TextBlock.Visibility = Visibility.Visible;
                    New_Part_Part_Sell_Price_Error_TextBlock.Text       = "*Sell price cannot be less than cost price";
                }
            }
            else
            {
                New_Part_Part_Sell_Price_Error_TextBlock.Visibility = Visibility.Collapsed;
            }
            if (isValidEntries)
            {
                New_Part_Part_Number_Error_TextBlock.Visibility       = Visibility.Collapsed;
                New_Part_Part_Description_Error_TextBlock.Visibility  = Visibility.Collapsed;
                New_Part_Part_Supplier_Error_TextBlock.Visibility     = Visibility.Collapsed;
                New_Part_Part_Cur_Quantity_Error_TextBlock.Visibility = Visibility.Collapsed;
                New_Part_Part_Min_Quantity_Error_TextBlock.Visibility = Visibility.Collapsed;
                New_Part_Part_Max_Quantity_Error_TextBlock.Visibility = Visibility.Collapsed;
                New_Part_Part_Cost_Price_Error_TextBlock.Visibility   = Visibility.Collapsed;
                New_Part_Part_Markup_Perc_Error_TextBlock.Visibility  = Visibility.Collapsed;
                New_Part_Part_Sell_Price_Error_TextBlock.Visibility   = Visibility.Collapsed;
                New_Part_Error_TextBlock.Visibility = Visibility.Collapsed;
                try
                {
                    Part newPart = new Part()
                    {
                        Part_Number            = newPartNumber,
                        Part_Description       = newPartDescription,
                        Part_Supplier          = newPartSupplier,
                        Part_Current_Quantity  = newPartCurQuantityValue,
                        Part_Min_Quantity      = newPartMinQuantityValue,
                        Part_Max_Quantity      = newPartMaxQuantityValue,
                        Part_Cost_Price        = newPartCostPriceValue,
                        Part_Markup_Percentage = newPartMarkupPercValue,
                        Part_Sell_Price        = newPartSellPriceValue,
                        Part_Sell_Price_Fixed  = newPartSellPriceFixed
                    };
                    DataController.GetInstance.StartTransaction();
                    if (DataController.GetInstance.InsertNewPart(newPart) &&
                        DataController.GetInstance.InsertLog(new List <Log>()
                    {
                        new Log()
                        {
                            Log_Date_Time = DateTime.Now,
                            Log_Performed_Action = "New Part",
                            Log_Part_Number = newPartNumber,
                            Log_Part_Description = newPartDescription,
                            Log_Part_Quantity = newPartCurQuantityValue,
                            Log_User = GlobalSingleton.GetInstance.Logged_In_User.User_Name
                        }
                    }))
                    {
                        DataController.GetInstance.Commit();
                        MessageBox.Show("New part " + newPartNumber + " successfully created");
                        mainWindow.RefreshAllData();
                        isAddButtonPressed = true;
                        Close();
                    }
                    else
                    {
                        DataController.GetInstance.Rollback();
                        New_Part_Error_TextBlock.Visibility = Visibility.Visible;
                        New_Part_Error_TextBlock.Text       = "Something went wrong";
                    }
                }
                catch (MySqlException ex)
                {
                    DataController.GetInstance.Rollback();
                    New_Part_Error_TextBlock.Visibility = Visibility.Visible;
                    New_Part_Error_TextBlock.Text       = ex.Message;
                }
            }
        }
        public void UpdatePart()
        {
            if (!NotDefaultValues())
            {
                Update_Part_Error_TextBlock.Visibility = Visibility.Visible;
                Update_Part_Error_TextBlock.Text       = "Nothing to update";
                return;
            }
            Update_Part_Error_TextBlock.Visibility = Visibility.Collapsed;
            string updatedPartDescription = Update_Part_Part_Description_TextBox.Text;
            string updatedPartSupplier    = Update_Part_Part_Supplier_TextBox.Text;
            string updatedPartCurQuantity = Update_Part_Part_Cur_Quantity_TextBox.Text;
            string updatedPartOrdQuantity = Update_Part_Part_Ord_Quantity_TextBox.Text;
            string updatedPartMinQuantity = Update_Part_Part_Min_Quantity_TextBox.Text;
            string updatedPartMaxQuantity = Update_Part_Part_Max_Quantity_TextBox.Text;
            string updatedPartCostPrice   = Update_Part_Part_Cost_Price_TextBox.Text;
            string updatedPartMarkupPerc  = Update_Part_Part_Markup_Perc_TextBox.Text;
            string updatedPartSellPrice   = Update_Part_Part_Sell_Price_TextBox.Text;

            bool updatedPartSellPriceFixed = Update_Part_Part_Sell_Price_Fixed_CheckBox.IsChecked.Value;

            int updatedPartCurQuantityValue = -1, updatedPartOrdQuantityValue = -1, updatedPartMinQuantityValue = -1,
                updatedPartMaxQuantityValue = -1;

            double updatedPartCostPriceValue = -1, updatedPartMarkupPercValue = -1, updatedPartSellPriceValue = -1;

            bool isValidEntries = true;

            if (updatedPartDescription.Length == 0)
            {
                isValidEntries = false;
                Update_Part_Part_Description_Error_TextBlock.Visibility = Visibility.Visible;
                Update_Part_Part_Description_Error_TextBlock.Text       = "*Please enter a value";
            }
            else
            {
                Update_Part_Part_Description_Error_TextBlock.Visibility = Visibility.Collapsed;
            }

            if (updatedPartSupplier.Length == 0)
            {
                isValidEntries = false;
                Update_Part_Part_Supplier_Error_TextBlock.Visibility = Visibility.Visible;
                Update_Part_Part_Supplier_Error_TextBlock.Text       = "*Please enter a part supplier";
            }
            else
            {
                Update_Part_Part_Supplier_Error_TextBlock.Visibility = Visibility.Collapsed;
            }

            if (updatedPartCurQuantity.Length == 0)
            {
                isValidEntries = false;
                Update_Part_Part_Cur_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                Update_Part_Part_Cur_Quantity_Error_TextBlock.Text       = "*Please enter a value";
            }
            else
            {
                bool validNumber = int.TryParse(updatedPartCurQuantity, out updatedPartCurQuantityValue);
                if (!validNumber)
                {
                    isValidEntries = false;
                    Update_Part_Part_Cur_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                    Update_Part_Part_Cur_Quantity_Error_TextBlock.Text       = "*Please enter a valid number";
                }
                else
                {
                    if (updatedPartCurQuantityValue < 0)
                    {
                        isValidEntries = false;
                        Update_Part_Part_Cur_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                        Update_Part_Part_Cur_Quantity_Error_TextBlock.Text       = "*Current quantity cannot be less than zero";
                    }
                    else
                    {
                        Update_Part_Part_Cur_Quantity_Error_TextBlock.Visibility = Visibility.Collapsed;
                    }
                }
            }

            if (updatedPartOrdQuantity.Length == 0)
            {
                isValidEntries = false;
                Update_Part_Part_Ord_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                Update_Part_Part_Ord_Quantity_Error_TextBlock.Text       = "*Please enter a value";
            }
            else
            {
                bool validNumber = int.TryParse(updatedPartOrdQuantity, out updatedPartOrdQuantityValue);
                if (!validNumber)
                {
                    isValidEntries = false;
                    Update_Part_Part_Ord_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                    Update_Part_Part_Ord_Quantity_Error_TextBlock.Text       = "*Please enter a valid number";
                }
                else
                {
                    if (updatedPartOrdQuantityValue < 0)
                    {
                        isValidEntries = false;
                        Update_Part_Part_Ord_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                        Update_Part_Part_Ord_Quantity_Error_TextBlock.Text       = "*Ordered quantity cannot be less than zero";
                    }
                    else
                    {
                        Update_Part_Part_Ord_Quantity_Error_TextBlock.Visibility = Visibility.Collapsed;
                    }
                }
            }

            if (updatedPartMinQuantity.Length == 0)
            {
                isValidEntries = false;
                Update_Part_Part_Min_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                Update_Part_Part_Min_Quantity_Error_TextBlock.Text       = "*Please enter a value";
            }
            else
            {
                bool validNumber = int.TryParse(updatedPartMinQuantity, out updatedPartMinQuantityValue);
                if (!validNumber)
                {
                    isValidEntries = false;
                    Update_Part_Part_Min_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                    Update_Part_Part_Min_Quantity_Error_TextBlock.Text       = "*Please enter a valid number";
                }
                else
                {
                    if (updatedPartMinQuantityValue < 0)
                    {
                        isValidEntries = false;
                        Update_Part_Part_Min_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                        Update_Part_Part_Min_Quantity_Error_TextBlock.Text       = "*Minimum quantity cannot be less than zero";
                    }
                    else
                    {
                        Update_Part_Part_Min_Quantity_Error_TextBlock.Visibility = Visibility.Collapsed;
                    }
                }
            }

            if (updatedPartMaxQuantity.Length == 0)
            {
                isValidEntries = false;
                Update_Part_Part_Max_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                Update_Part_Part_Max_Quantity_Error_TextBlock.Text       = "*Please enter a value";
            }
            else
            {
                bool validNumber = int.TryParse(updatedPartMaxQuantity, out updatedPartMaxQuantityValue);
                if (!validNumber)
                {
                    isValidEntries = false;
                    Update_Part_Part_Max_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                    Update_Part_Part_Max_Quantity_Error_TextBlock.Text       = "*Please enter a valid number";
                }
                else
                {
                    if (updatedPartMaxQuantityValue < 0)
                    {
                        isValidEntries = false;
                        Update_Part_Part_Max_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                        Update_Part_Part_Max_Quantity_Error_TextBlock.Text       = "*Maximum quantity cannot be less than zero";
                    }
                    else
                    {
                        Update_Part_Part_Max_Quantity_Error_TextBlock.Visibility = Visibility.Collapsed;
                    }
                }
            }

            if (updatedPartCostPrice.Length == 0)
            {
                isValidEntries = false;
                Update_Part_Part_Cost_Price_Error_TextBlock.Visibility = Visibility.Visible;
                Update_Part_Part_Cost_Price_Error_TextBlock.Text       = "*Please enter a value";
            }
            else
            {
                bool validNumber = double.TryParse(updatedPartCostPrice, out updatedPartCostPriceValue);
                if (!validNumber)
                {
                    isValidEntries = false;
                    Update_Part_Part_Cost_Price_Error_TextBlock.Visibility = Visibility.Visible;
                    Update_Part_Part_Cost_Price_Error_TextBlock.Text       = "*Please enter a valid number";
                }
                else
                {
                    if (updatedPartCostPriceValue < 0)
                    {
                        isValidEntries = false;
                        Update_Part_Part_Cost_Price_Error_TextBlock.Visibility = Visibility.Visible;
                        Update_Part_Part_Cost_Price_Error_TextBlock.Text       = "*Cost price cannot be less than zero";
                    }
                    else
                    {
                        Update_Part_Part_Cost_Price_Error_TextBlock.Visibility = Visibility.Collapsed;
                    }
                }
            }
            if (updatedPartMarkupPerc.Length == 0)
            {
                isValidEntries = false;
                Update_Part_Part_Markup_Perc_Error_TextBlock.Visibility = Visibility.Visible;
                Update_Part_Part_Markup_Perc_Error_TextBlock.Text       = "*Please enter a value";
            }
            else
            {
                bool validNumber = double.TryParse(updatedPartMarkupPerc, out updatedPartMarkupPercValue);
                if (!validNumber)
                {
                    isValidEntries = false;
                    Update_Part_Part_Markup_Perc_Error_TextBlock.Visibility = Visibility.Visible;
                    Update_Part_Part_Markup_Perc_Error_TextBlock.Text       = "*Please enter a valid number";
                }
                else
                {
                    if (updatedPartMarkupPercValue < 0)
                    {
                        isValidEntries = false;
                        Update_Part_Part_Markup_Perc_Error_TextBlock.Visibility = Visibility.Visible;
                        Update_Part_Part_Markup_Perc_Error_TextBlock.Text       = "*Markup percentage cannot be less than zero";
                    }
                    else
                    {
                        Update_Part_Part_Markup_Perc_Error_TextBlock.Visibility = Visibility.Collapsed;
                    }
                }
            }
            if (updatedPartSellPrice.Length == 0)
            {
                isValidEntries = false;
                Update_Part_Part_Sell_Price_Error_TextBlock.Visibility = Visibility.Visible;
                Update_Part_Part_Sell_Price_Error_TextBlock.Text       = "*Please enter a value";
            }
            else
            {
                bool validNumber = double.TryParse(updatedPartSellPrice, out updatedPartSellPriceValue);
                if (!validNumber)
                {
                    isValidEntries = false;
                    Update_Part_Part_Sell_Price_Error_TextBlock.Visibility = Visibility.Visible;
                    Update_Part_Part_Sell_Price_Error_TextBlock.Text       = "*Please enter a valid number";
                }
                else
                {
                    if (updatedPartSellPriceValue < 0)
                    {
                        isValidEntries = false;
                        Update_Part_Part_Sell_Price_Error_TextBlock.Visibility = Visibility.Visible;
                        Update_Part_Part_Sell_Price_Error_TextBlock.Text       = "*Sell price cannot be less than zero";
                    }
                    else
                    {
                        Update_Part_Part_Sell_Price_Error_TextBlock.Visibility = Visibility.Collapsed;
                    }
                }
            }
            if (updatedPartMinQuantityValue > updatedPartMaxQuantityValue)
            {
                isValidEntries = false;
                if (Update_Part_Part_Min_Quantity_Error_TextBlock.Visibility == Visibility.Collapsed)
                {
                    Update_Part_Part_Min_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                    Update_Part_Part_Min_Quantity_Error_TextBlock.Text       = "*Minimum part quantity cannot be less than maximum part quantity";
                }
                if (Update_Part_Part_Max_Quantity_Error_TextBlock.Visibility == Visibility.Collapsed)
                {
                    Update_Part_Part_Max_Quantity_Error_TextBlock.Visibility = Visibility.Visible;
                    Update_Part_Part_Max_Quantity_Error_TextBlock.Text       = "*Minimum part quantity cannot be less than maximum part quantity";
                }
            }
            else
            {
                Update_Part_Part_Min_Quantity_Error_TextBlock.Visibility = Visibility.Collapsed;
                Update_Part_Part_Max_Quantity_Error_TextBlock.Visibility = Visibility.Collapsed;
            }
            if (updatedPartCostPriceValue > updatedPartSellPriceValue)
            {
                isValidEntries = false;
                if (Update_Part_Part_Sell_Price_Error_TextBlock.Visibility == Visibility.Collapsed)
                {
                    Update_Part_Part_Sell_Price_Error_TextBlock.Visibility = Visibility.Visible;
                    Update_Part_Part_Sell_Price_Error_TextBlock.Text       = "*Sell price cannot be less than cost price";
                }
            }
            else
            {
                Update_Part_Part_Sell_Price_Error_TextBlock.Visibility = Visibility.Collapsed;
            }
            if (isValidEntries)
            {
                Update_Part_Part_Description_Error_TextBlock.Visibility  = Visibility.Collapsed;
                Update_Part_Part_Supplier_Error_TextBlock.Visibility     = Visibility.Collapsed;
                Update_Part_Part_Cur_Quantity_Error_TextBlock.Visibility = Visibility.Collapsed;
                Update_Part_Part_Min_Quantity_Error_TextBlock.Visibility = Visibility.Collapsed;
                Update_Part_Part_Max_Quantity_Error_TextBlock.Visibility = Visibility.Collapsed;
                Update_Part_Part_Ord_Quantity_Error_TextBlock.Visibility = Visibility.Collapsed;
                Update_Part_Part_Cost_Price_Error_TextBlock.Visibility   = Visibility.Collapsed;
                Update_Part_Part_Markup_Perc_Error_TextBlock.Visibility  = Visibility.Collapsed;
                Update_Part_Part_Sell_Price_Error_TextBlock.Visibility   = Visibility.Collapsed;
                Update_Part_Error_TextBlock.Visibility = Visibility.Collapsed;
                try
                {
                    Part updatedPart = new Part()
                    {
                        Part_Number            = selectedPart.Part_Number,
                        Part_Description       = updatedPartDescription,
                        Part_Supplier          = updatedPartSupplier,
                        Part_Current_Quantity  = updatedPartCurQuantityValue,
                        Part_Min_Quantity      = updatedPartMinQuantityValue,
                        Part_Max_Quantity      = updatedPartMaxQuantityValue,
                        Part_Ordered_Quantity  = updatedPartOrdQuantityValue,
                        Part_Cost_Price        = updatedPartCostPriceValue,
                        Part_Markup_Percentage = updatedPartMarkupPercValue,
                        Part_Sell_Price        = updatedPartSellPriceValue,
                        Part_Sell_Price_Fixed  = updatedPartSellPriceFixed
                    };
                    DataController.GetInstance.StartTransaction();
                    if (DataController.GetInstance.UpdatePart(updatedPart) &&
                        DataController.GetInstance.InsertLog(new List <Log>()
                    {
                        new Log()
                        {
                            Log_Date_Time = DateTime.Now,
                            Log_Performed_Action = "Part Updated",
                            Log_Part_Number = selectedPart.Part_Number,
                            Log_Part_Description = updatedPartDescription,
                            Log_Part_Quantity = (updatedPartCurQuantityValue + updatedPartOrdQuantityValue),
                            Log_User = GlobalSingleton.GetInstance.Logged_In_User.User_Name
                        }
                    }))
                    {
                        DataController.GetInstance.Commit();
                        MessageBox.Show("Part " + selectedPart.Part_Number + " successfully updated");
                        mainWindow.RefreshAllData();
                        isUpdateButtonPressed = true;
                        Close();
                    }
                    else
                    {
                        DataController.GetInstance.Rollback();
                        Update_Part_Error_TextBlock.Visibility = Visibility.Visible;
                        Update_Part_Error_TextBlock.Text       = "Something went wrong";
                    }
                }
                catch (MySqlException ex)
                {
                    Update_Part_Error_TextBlock.Visibility = Visibility.Visible;
                    Update_Part_Error_TextBlock.Text       = ex.Message;
                }
            }
        }