private void Btn_Invoice_Click(object sender, RoutedEventArgs e)
        {
            viewIn            = new ViewInvoice();
            viewIn.RoleType   = RoleType;
            viewIn.Department = Department;

            if (Department == 1)
            {
                viewIn.Stck_Parts.Visibility = Visibility.Collapsed;
            }

            else if (Department == 2)
            {
                viewIn.Stck_Parts.Visibility = Visibility.Collapsed;
            }

            else if (Department == 3)
            {
                viewIn.Stck_Parts.Visibility    = Visibility.Collapsed;
                viewIn.Stck_ServPlan.Visibility = Visibility.Collapsed;
            }

            else if (Department == 4)
            {
                viewIn.Stck_ServPlan.Visibility = Visibility.Collapsed;
                viewIn.Stack_Vehicle.Visibility = Visibility.Collapsed;
            }

            if (RoleType == "SalesMan" || RoleType == "Mechanic" || RoleType == "Surbordinate")
            {
                viewIn.can_Delete.Visibility = Visibility.Collapsed;
                _mainFrame.Navigate(viewIn);
            }

            else
            {
                _mainFrame.Navigate(viewIn);
            }
        }
Пример #2
0
        private void Can_AddInvoice_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            viewinvoice = new ViewInvoice();
            AddInvoice  = new IssueInvoice();
            connect     = new CTUConnection();


            viewinvoice.Invoice_page = null;
            DependencyObject currParent = VisualTreeHelper.GetParent(this);

            while (currParent != null && viewinvoice.Invoice_page == null)
            {
                viewinvoice.Invoice_page = currParent as Frame;
                currParent = VisualTreeHelper.GetParent(currParent);
            }

            if (viewinvoice.Invoice_page != null)
            {
                try
                {
                    if (Department == 1)
                    {
                        AddInvoice.Stck_Prob.Visibility  = Visibility.Collapsed;
                        AddInvoice.Stck_Parts.Visibility = Visibility.Collapsed;
                        AddInvoice.Stck_Mech.Visibility  = Visibility.Collapsed;
                        AddInvoice.Stck_Price.Visibility = Visibility.Collapsed;

                        connect.SelectNewVehicle();
                        AddInvoice.cmbx_Car.ItemsSource       = connect.table.DefaultView;
                        AddInvoice.cmbx_Car.DisplayMemberPath = "Model";
                        AddInvoice.cmbx_Car.SelectedValuePath = "ID";

                        connect.SelectInvoiceCustomer2();
                        AddInvoice.cmbx_Cust.ItemsSource       = connect.table2.DefaultView;
                        AddInvoice.cmbx_Cust.DisplayMemberPath = "[Name]";
                        AddInvoice.cmbx_Cust.SelectedValuePath = "ID";

                        connect.SelectInvoiceEmployeeSalesMen();
                        AddInvoice.cmbx_SalesMan.ItemsSource       = connect.table3.DefaultView;
                        AddInvoice.cmbx_SalesMan.DisplayMemberPath = "[EmName]";
                        AddInvoice.cmbx_SalesMan.SelectedValuePath = "ID";
                    }

                    else if (Department == 2)
                    {
                        AddInvoice.Stck_Prob.Visibility  = Visibility.Collapsed;
                        AddInvoice.Stck_Parts.Visibility = Visibility.Collapsed;
                        AddInvoice.Stck_Mech.Visibility  = Visibility.Collapsed;
                        AddInvoice.Stck_Price.Visibility = Visibility.Collapsed;

                        connect.SelectOldVehicle();
                        AddInvoice.cmbx_Car.ItemsSource       = connect.table.DefaultView;
                        AddInvoice.cmbx_Car.DisplayMemberPath = "Model";
                        AddInvoice.cmbx_Car.SelectedValuePath = "ID";

                        connect.SelectInvoiceCustomer2();
                        AddInvoice.cmbx_Cust.ItemsSource       = connect.table2.DefaultView;
                        AddInvoice.cmbx_Cust.DisplayMemberPath = "[Name]";
                        AddInvoice.cmbx_Cust.SelectedValuePath = "ID";

                        connect.SelectInvoiceEmployeeSalesMen();
                        AddInvoice.cmbx_SalesMan.ItemsSource       = connect.table3.DefaultView;
                        AddInvoice.cmbx_SalesMan.DisplayMemberPath = "[EmName]";
                        AddInvoice.cmbx_SalesMan.SelectedValuePath = "ID";
                    }

                    else if (Department == 3)
                    {
                        AddInvoice.Stck_Car.Visibility   = Visibility.Collapsed;
                        AddInvoice.Stck_Parts.Visibility = Visibility.Collapsed;
                        AddInvoice.Stck_Sales.Visibility = Visibility.Collapsed;
                        AddInvoice.Stck_Serv.Visibility  = Visibility.Collapsed;


                        connect.SelectInvoiceCustomer2();
                        AddInvoice.cmbx_Cust.ItemsSource       = connect.table2.DefaultView;
                        AddInvoice.cmbx_Cust.DisplayMemberPath = "[Name]";
                        AddInvoice.cmbx_Cust.SelectedValuePath = "ID";

                        connect.SelectInvoiceEmployeeMech();
                        AddInvoice.cmbx_Mech.ItemsSource       = connect.table3.DefaultView;
                        AddInvoice.cmbx_Mech.DisplayMemberPath = "[EmName]";
                        AddInvoice.cmbx_Mech.SelectedValuePath = "ID";
                    }

                    else if (Department == 4)
                    {
                        AddInvoice.Stck_Car.Visibility   = Visibility.Collapsed;
                        AddInvoice.Stck_Sales.Visibility = Visibility.Collapsed;
                        AddInvoice.Stck_Mech.Visibility  = Visibility.Collapsed;
                        AddInvoice.Stck_Serv.Visibility  = Visibility.Collapsed;
                        AddInvoice.Stck_Price.Visibility = Visibility.Collapsed;

                        connect.SelectInvoiceCustomer2();
                        AddInvoice.cmbx_Cust.ItemsSource       = connect.table2.DefaultView;
                        AddInvoice.cmbx_Cust.DisplayMemberPath = "[Name]";
                        AddInvoice.cmbx_Cust.SelectedValuePath = "ID";

                        connect.Selectparts();
                        AddInvoice.cmbx_Parts.ItemsSource       = connect.table.DefaultView;
                        AddInvoice.cmbx_Parts.DisplayMemberPath = "Details";
                        AddInvoice.cmbx_Parts.SelectedValuePath = "ID";
                    }

                    AddInvoice.Department = Department;
                    viewinvoice.Invoice_page.Navigate(AddInvoice);
                }

                catch (Exception)
                {
                }
            }
        }