private void DGV_Invoice_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                prtInv = new PrintInvoice();
                object item = DGV_Invoice.SelectedItem;
                prtInv.flwdoc = new FlowDocument();
                prtInv.flwdoc.Blocks.Add(new Paragraph(new Run("Service Plan: " + (DGV_Invoice.SelectedCells[1].Column.GetCellContent(item) as TextBlock).Text.ToString())));
                prtInv.flwdoc.Blocks.Add(new Paragraph(new Run((DGV_Invoice.SelectedCells[2].Column.GetCellContent(item) as TextBlock).Text.ToString())));
                prtInv.flwdoc.Blocks.Add(new Paragraph(new Run("Date issued: " + (DGV_Invoice.SelectedCells[3].Column.GetCellContent(item) as TextBlock).Text.ToString())));
                prtInv.flwdoc.Blocks.Add(new Paragraph(new Run((DGV_Invoice.SelectedCells[4].Column.GetCellContent(item) as TextBlock).Text.ToString())));
                prtInv.flwdoc.Blocks.Add(new Paragraph(new Run((DGV_Invoice.SelectedCells[5].Column.GetCellContent(item) as TextBlock).Text.ToString())));
                prtInv.flwdoc.Blocks.Add(new Paragraph(new Run((DGV_Invoice.SelectedCells[6].Column.GetCellContent(item) as TextBlock).Text.ToString())));
                prtInv.flwdoc.Blocks.Add(new Paragraph(new Run((DGV_Invoice.SelectedCells[7].Column.GetCellContent(item) as TextBlock).Text.ToString())));
                prtInv.flwdoc.Blocks.Add(new Paragraph(new Run((DGV_Invoice.SelectedCells[8].Column.GetCellContent(item) as TextBlock).Text.ToString())));


                prtInv.RICH_Invoice.Document = prtInv.flwdoc;
                prtInv.Department            = Department;

                if (RoleType == "SalesMan" || RoleType == "Mechanic" || RoleType == "Surbordinate")
                {
                    prtInv.Can_AddInvoice.Visibility = Visibility.Collapsed;
                    Invoice_page.Navigate(prtInv);
                }

                else
                {
                    if (DGV_Invoice.Items.IsEmpty)
                    {
                        issInv = new IssueInvoice();
                        Invoice_page.Navigate(issInv);
                    }

                    else
                    {
                        prtInv.Department = Department;
                        Invoice_page.Navigate(prtInv);
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Exemple #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)
                {
                }
            }
        }