Пример #1
0
        public DataTable ExecuteQuery(MyCommand myCmd)
        {
            DataTable rs = null;

            //可能上次操作关闭失败,先关闭再打开避免后面操作卡住
            if (mySqlConnection.State == ConnectionState.Open)
            {
                mySqlConnection.Close();
            }
            try
            {
                mySqlConnection.Open();
                Debug.Log("打开链接");
                MySqlCommand cmd = mySqlConnection.CreateCommand();
                MyCommandHelper.Inject(myCmd, cmd);
                DataSet          ds = new DataSet();
                MySqlDataAdapter da = new MySqlDataAdapter(cmd);
                da.Fill(ds);
                rs = ds.Tables[0];
            }
            catch (Exception ee)
            {
                throw new Exception("SQL:" + myCmd.ToString() + "/n" + ee.Message.ToString());
            }
            finally
            {
                Debug.Log("关闭链接");
                mySqlConnection.Close();
            }
            return(rs);
        }
Пример #2
0
 static void InitializeCommands()
 {
     ChangeContentCommand = new RoutedCommand("ChangeContentCommand", typeof(JSwitcher));
     DoubleClickCommand   = new RoutedCommand("DoubleClickCommand", typeof(JSwitcher));
     //ClickCommand = new RoutedCommand("ClickCommand", typeof(JSwitcher));
     MyCommandHelper.RegisterCommandHandler(typeof(JSwitcher), ChangeContentCommand, new ExecutedRoutedEventHandler(ChangeContentExecute), new KeyGesture(Key.Enter));
     MyCommandHelper.RegisterCommandHandler(typeof(JSwitcher), DoubleClickCommand, new ExecutedRoutedEventHandler(DoubleClickExecute), new MouseGesture(MouseAction.LeftDoubleClick));
     //MyCommandHelper.RegisterCommandHandler(typeof(JSwitcher), ClickCommand, new ExecutedRoutedEventHandler(ClickExecute), new CanExecuteRoutedEventHandler(CanClickExecute), new MouseGesture(MouseAction.LeftClick));
 }
Пример #3
0
        public bool ExecuteNonQuery(MyCommand myCmd)
        {
            bool flag = false;

            try
            {
                mySqlConnection.Open();
                Debug.Log("打开链接");
                MySqlCommand cmd = mySqlConnection.CreateCommand();
                MyCommandHelper.Inject(myCmd, cmd);
                flag = cmd.ExecuteNonQuery() == 1;
            }
            catch (Exception ee)
            {
                throw new Exception("SQL:" + myCmd.ToString() + "/n" + ee.Message.ToString());
            }
            finally
            {
                Debug.Log("关闭链接");
                mySqlConnection.Close();
            }
            return(flag);
        }
Пример #4
0
 private static void IncreaseExecute(object sender, ExecutedRoutedEventArgs e)
 {
     if (sender is JSpinner spinner &&
         (spinner.SpinnerType == SpinnerType.ItemSource && spinner.Value < spinner._TextList.Count - 1 && spinner.Value >= 0 ||
          spinner.SpinnerType == SpinnerType.Range && spinner.Value >= spinner.Minimum && spinner.Value < spinner.Maximum ||
          spinner.SpinnerType == SpinnerType.ItemSources && spinner.Value < spinner._TextList.Count - 1 && spinner.Value >= 0))
     {
         spinner._ClickFireEvent = true;
         if (!spinner.IsUIFireEventDirectly)
         {
             spinner.Value++;
         }
         else
         {
             spinner.SendValue = spinner.Value + 1;
             spinner.ValueChangedEvent?.Invoke(spinner, spinner.SendValue);
         }
         if (spinner.CommonCommand != null)
         {
             MyCommandHelper.ExecuteCommand(spinner.CommonCommand, spinner.CommonCommandParameter, spinner);
         }
     }
 }