Exemplo n.º 1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            cr.LoadPromotionType();
            cr.LoadAllAreaForAvailableProduct();
            cr.LoadAllAreaForExistingPromotion();
            cr.LoadAllGroupForExistingPromotion();
            DataSet ds = client.SQSAdmin_Promotion_GetPromotionDetails(promotionid);

            promotiontypeid = int.Parse(ds.Tables[0].Rows[0]["fkidpromotiontypeid"].ToString());
            textBlock1.Text = @"Configure promotion products for promotion -- " + ds.Tables[0].Rows[0]["promotionname"].ToString() + @".         Type: " + ds.Tables[0].Rows[0]["promotiontype"].ToString() + @"            Base Product: " + ds.Tables[0].Rows[0]["baseproductid"].ToString();
            //SearchAvailableProducts(null,null, int.Parse(cmbArea.SelectedValue.ToString()), int.Parse(cmbGroup.SelectedValue.ToString()),txtProductID.Text, txtPAGID.Text);

            this.loadingimage.Image = global::SQSAdmin_WpfCustomControlLibrary.Properties.Resources.processingImage;
            SearchAvailableProducts_MultiThread();
            SearchExistingProducts();
        }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            string selectedpagids = "";
            var    itemsSource    = dataGrid1.ItemsSource as IEnumerable;

            if (itemsSource != null)
            {
                foreach (var item in itemsSource)
                {
                    var row = dataGrid1.ItemContainerGenerator.ContainerFromItem(item) as Microsoft.Windows.Controls.DataGridRow;
                    ContentPresenter contentPresenter = dataGrid1.Columns[0].GetCellContent(item) as ContentPresenter;
                    if (contentPresenter != null)
                    {
                        DataTemplate editingTemplate = contentPresenter.ContentTemplate;
                        CheckBox     chk             = editingTemplate.FindName("chkSelected", contentPresenter) as CheckBox;
                        TextBlock    tx = dataGrid1.Columns[1].GetCellContent(row) as TextBlock;
                        if ((bool)chk.IsChecked)
                        {
                            if (selectedpagids.Length == 0)
                            {
                                selectedpagids = tx.Text;
                            }
                            else
                            {
                                selectedpagids = selectedpagids + "," + tx.Text;
                            }
                        }
                    }
                }
            }

            if (selectedpagids.Length != 0)
            {
                AddProductsToPromotion(selectedpagids);
                //SearchAvailableProducts(null, null, int.Parse(cmbArea.SelectedValue.ToString()), int.Parse(cmbGroup.SelectedValue.ToString()), txtProductID.Text, txtPAGID.Text);
                cr.LoadAllAreaForExistingPromotion();
                cmbArea2.SelectedValue = 0;
                cr.LoadAllGroupForExistingPromotion();
                cmbGroup2.SelectedIndex = 0;
                SearchAvailableProducts();
                SearchNewProducts();
            }
        }