/// <summary>
 /// 
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void db_UpdateRequisitionCompleted(object sender, UpdateRequisitionCompletedEventArgs e)
 {
     Result result = null;
     if (e.Error == null)
     {
         result = e.Result;
         if (result.Msg == "成功")
         {
             Windows.CWRPrompt prompt = new Windows.CWRPrompt(result.No);
             prompt.Show();
             prompt.OKButtonClicked += new EventHandler(SetFormClear);
         }
         else
             MessageBox.Show(result.Msg);
     }
     else
     {
         MessageBox.Show(e.Error.Message);
     }
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ContextMenuItem_Click(object sender, RoutedEventArgs e)
 {
     switch ((sender as MenuItem).Name)
     {
         case "mnuCopy":
             rdtail = dgRequisition.SelectedItem as RDetails;
             break;
         case "mnuClear":
             if (dgRequisition.SelectedItem == null) return;
             ((TextBlock)dgRequisition.Columns[0].GetCellContent(dgRequisition.SelectedItem)).Text = string.Empty;
             ((TextBlock)dgRequisition.Columns[1].GetCellContent(dgRequisition.SelectedItem)).Text = string.Empty;
             ((TextBlock)dgRequisition.Columns[2].GetCellContent(dgRequisition.SelectedItem)).Text = string.Empty;
             ((TextBlock)dgRequisition.Columns[3].GetCellContent(dgRequisition.SelectedItem)).Text = string.Empty;
             ((TextBlock)dgRequisition.Columns[4].GetCellContent(dgRequisition.SelectedItem)).Text = string.Empty;
             ((TextBlock)dgRequisition.Columns[5].GetCellContent(dgRequisition.SelectedItem)).Text = string.Empty;
             ((TextBlock)dgRequisition.Columns[6].GetCellContent(dgRequisition.SelectedItem)).Text = string.Empty;
             ((TextBlock)dgRequisition.Columns[7].GetCellContent(dgRequisition.SelectedItem)).Text = string.Empty;
             (dgRequisition.SelectedItem as RDetails).Product = string.Empty;
             (dgRequisition.SelectedItem as RDetails).Amount = 0;
             (dgRequisition.SelectedItem as RDetails).Quantity = 0;
             hasError = false;
             CalculateAmt(); 
             break;
         case "mnuPaste":
             if (rdtail == null) return;
             if (dgRequisition.SelectedItem == null) return;
             ((TextBlock)dgRequisition.Columns[0].GetCellContent(dgRequisition.SelectedItem)).Text = rdtail.Product;
             (dgRequisition.SelectedItem as RDetails).Product = rdtail.Product;                    
             ((TextBlock)dgRequisition.Columns[1].GetCellContent(dgRequisition.SelectedItem)).Text = rdtail.Quantity.ToString();
             (dgRequisition.SelectedItem as RDetails).Quantity = rdtail.Quantity;
             ((TextBlock)dgRequisition.Columns[2].GetCellContent(dgRequisition.SelectedItem)).Text = rdtail.UnitName;
             (dgRequisition.SelectedItem as RDetails).UnitName = rdtail.UnitName;
             ((TextBlock)dgRequisition.Columns[3].GetCellContent(dgRequisition.SelectedItem)).Text = rdtail.UCost.ToString();
             (dgRequisition.SelectedItem as RDetails).UCost = rdtail.UCost;
             ((TextBlock)dgRequisition.Columns[4].GetCellContent(dgRequisition.SelectedItem)).Text = rdtail.Amount.ToString();
             (dgRequisition.SelectedItem as RDetails).Amount = rdtail.Amount;
             ((TextBlock)dgRequisition.Columns[5].GetCellContent(dgRequisition.SelectedItem)).Text = rdtail.TaxRate.ToString();
             (dgRequisition.SelectedItem as RDetails).TaxRate = rdtail.TaxRate;
             ((TextBlock)dgRequisition.Columns[6].GetCellContent(dgRequisition.SelectedItem)).Text = rdtail.SCost.ToString();
             (dgRequisition.SelectedItem as RDetails).SCost = rdtail.SCost;
             ((TextBlock)dgRequisition.Columns[7].GetCellContent(dgRequisition.SelectedItem)).Text = rdtail.SupplierName;
             (dgRequisition.SelectedItem as RDetails).SupplierName = rdtail.SupplierName;
             (dgRequisition.SelectedItem as RDetails).SCode = rdtail.SCode;
             (dgRequisition.SelectedItem as RDetails).UCode = rdtail.UCode;
             CalculateAmt(); 
             break;
         case "mnuExcel":
             Windows.CWRPrompt prompt = new Windows.CWRPrompt(req.Code);
             prompt.Show();
             prompt.OKButtonClicked += new EventHandler(SetFormClearX);
             break;
         case "mnuClose":
             db.CloseAsync();
             Frame fm = (Frame)this.Parent;
             if (fm != null) fm.Source = new Uri("/Pages/UIGraph.xaml", UriKind.Relative);
             break;
     }
     
 }
        public void Print()
        {
            Windows.CWRPrompt prompt = new Windows.CWRPrompt(req.Code);
            prompt.Show();
            prompt.OKButtonClicked += new EventHandler(SetFormClear);

        }