コード例 #1
0
 private void HeightPacketBox_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Tab)
     {
         if (HeightPacketBox.Text == "" || HeightPacketBox.Text == "0")
         {
             Dispatcher.BeginInvoke(DispatcherPriority.Input, new Action(delegate()
             {
                 WeightAccToFranchize.Focus();         // Set Logical Focus
                 Keyboard.Focus(WeightAccToFranchize); // Set Keyboard Focus
             }));
         }
     }
 }
コード例 #2
0
        private void LenghtPacketBox_LostFocus(object sender, RoutedEventArgs e)
        {
            double lenght, height, width, divisor, netweight;
            int    pieces;

            if (!double.TryParse(LenghtPacketBox.Text, out lenght))
            {
                lenght = 0;
            }
            if (!double.TryParse(WidthPacketBox.Text, out width))
            {
                width = 0;
            }
            if (!double.TryParse(HeightPacketBox.Text, out height))
            {
                height = 0;
            }
            if (!double.TryParse(DivisorBox.Text, out divisor))
            {
                divisor = 0;
            }

            if (!int.TryParse(PiecesBox.Text, out pieces))
            {
                pieces = 0;
            }
            if (divisor != 0)
            {
                netweight           = (lenght * width * height * ((double)pieces) / divisor);
                NetWeightBlock.Text = string.Format("{0:0.00}", netweight);
            }
            else
            {
                netweight = 0;
            }
            double fileWeight;

            if (!double.TryParse(WeightAccToDTDC.Text, out fileWeight))
            {
                fileWeight = 0;
            }
            netweight = netweight > fileWeight ? netweight : fileWeight;
            BilledWeightTextBox.Text = string.Format("{0:0.00}", netweight);
            Dispatcher.BeginInvoke(DispatcherPriority.Input, new Action(delegate()
            {
                WeightAccToFranchize.Focus();         // Set Logical Focus
                Keyboard.Focus(WeightAccToFranchize); // Set Keyboard Focus
            }));
        }