Exemplo n.º 1
0
        //String[] shop = new String[112];
        public Window1()
        {
            WindowStartupLocation = WindowStartupLocation.CenterScreen;
            InitializeComponent();

            dgl = TransDGL.GetInstance();

            ShowTime();                                          //在这里窗体加载的时候不执行文本框赋值,窗体上不会及时的把时间显示出来,而是等待了片刻才显示了出来
            ShowTimer          = new System.Windows.Threading.DispatcherTimer();
            ShowTimer.Tick    += new EventHandler(ShowCurTimer); //起个Timer一直获取当前时间
            ShowTimer.Interval = new TimeSpan(0, 0, 0, 1, 0);
            ShowTimer.Start();

            List <Store> ls = new List <Store>();

            ls = dgl.GetStores();

            stores = ls.ToArray();
            //stores = dgl.GetStores();

            RadioButton[] rads = { r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16, r17, r18 };
            if (stores.Length >= 18)
            {
                for (int i = 0; i < 18; i++)
                {
                    if (stores[i].id != "")
                    {
                        rads[i].DataContext = stores[i];
                        //rads[i].Content = stores[i].GetName();
                    }
                    else
                    {
                        break;
                    }
                }
            }
            else
            {
                for (int i = 0; i < stores.Length; i++)
                {
                    if (stores[i].id != "")
                    {
                        rads[i].DataContext = stores[i];
                        //rads[i].Content = stores[i].GetName();
                    }
                    else
                    {
                        break;
                    }
                }
                for (int j = stores.Length; j < 18; j++)
                {
                    rads[j].Visibility = Visibility.Hidden;
                }
            }
            page = 0;
        }
Exemplo n.º 2
0
 private void FButton_Click_Delete(object sender, RoutedEventArgs e)
 {
     RadioButton[] rads = { r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16, r17, r18 };
     for (int i = 0; i < 18; i++)
     {
         if (rads[i].IsChecked == true)
         {
             Store ss = new Store();
             ss = rads[i].DataContext as Store;
             if (ss != null)
             {
                 int result = dgl.DeleteStore(ss.id);
                 if (result == 1)
                 {
                     MessageBox.Show("删除成功");
                     //Console.WriteLine("删除成功");
                     for (int a = 0; a < 18; a++)
                     {
                         rads[a].Visibility = Visibility.Visible;
                     }
                     List <Store> ls = new List <Store>();
                     ls     = dgl.GetStores();
                     stores = ls.ToArray();
                     RadioButton[] rads2 = { r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16, r17, r18 };
                     if (stores.Length >= 18)
                     {
                         for (int j = 0; j < 18; j++)
                         {
                             if (stores[j].GetName() != null)
                             {
                                 rads2[j].DataContext = stores[j];
                             }
                             else
                             {
                                 break;
                             }
                         }
                     }
                     else
                     {
                         for (int j = 0; j < stores.Length; j++)
                         {
                             if (stores[j].GetName() != null)
                             {
                                 rads[j].DataContext = stores[j];
                             }
                             else
                             {
                                 break;
                             }
                         }
                         for (int j = stores.Length; j < 18; j++)
                         {
                             rads[j].Visibility = Visibility.Hidden;
                         }
                     }
                     page = 0;
                 }
                 else if (result == 0)
                 {
                     MessageBox.Show("删除失败");
                     //Console.WriteLine("删除失败");
                 }
                 else
                 {
                     MessageBox.Show("未知错误");
                     //Console.WriteLine("未知错误");
                 }
             }
             else
             {
                 MessageBox.Show("请选择店铺后点击!");
             }
         }
     }
 }