Exemplo n.º 1
0
        //print button on the client list clicked event
        private void printIDBtn_Click(object sender, RoutedEventArgs e)
        {
            GlobalVariables.dataRowView = (DataRowView)((Button)e.Source).DataContext;
            //query to get the client info on the selected row
            string           query = "SELECT [Client ID], Name, [Last Name],Gender FROM Clients WHERE [Client ID] = '" + GlobalVariables.dataRowView[0] + "'";
            SqlCeDataAdapter adapt = new SqlCeDataAdapter(query, databaseConnection);
            DataTable        data  = new DataTable();

            adapt.Fill(data);
            //instanciating an object from the print user control for the client info selected
            printClientUserControl obj = new printClientUserControl(int.Parse(data.Rows[0]["Client ID"].ToString()), data.Rows[0]["Name"].ToString(), data.Rows[0]["Last Name"].ToString(), data.Rows[0]["Gender"].ToString());

            obj.print();
        }
Exemplo n.º 2
0
 //print button event
 private void printBtn_Click(object sender, RoutedEventArgs e)
 {
     // print only if the boxes arent empty
     if (addClientNameBox.Text.Length > 0 && addClientFnameBox.Text.Length > 0 && addClientAgeBox.Text.Length > 0 && addClientGenderBox.Text.Length > 0)
     {
         string           query = "SELECT [Client ID], [Name], [Last Name], Gender FROM Clients WHERE [Name] ='" + addClientNameBox.Text + "' AND [Last Name] ='" + addClientFnameBox.Text + "'";
         SqlCeDataAdapter adapt = new SqlCeDataAdapter(query, databaseConnection);
         DataTable        data  = new DataTable();
         databaseConnection.Open();
         adapt.Fill(data);
         databaseConnection.Close();
         //opening the print dialog and printing
         printClientUserControl instance = new printClientUserControl(int.Parse(data.Rows[0]["Client ID"].ToString()), data.Rows[0]["Name"].ToString(), data.Rows[0]["Last Name"].ToString(), data.Rows[0]["Gender"].ToString());
         instance.print();
         //dispatcher
         printSnackBar.IsActive = true;
         DispatcherTimerprintSnack();
     }
 }