Exemplo n.º 1
0
 private void ButtonApply_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         DataGridControllerResult.Save();
     }
     catch (Exception t)
     {
         Db2SourceContext ctx = Target.Context;
         ctx.OnLog(ctx.GetExceptionMessage(t), LogStatus.Error, Target.Context.LastSql);
         return;
     }
 }
Exemplo n.º 2
0
        public void OnTabClosing(object sender, ref bool cancel)
        {
            if (!DataGridControllerResult.IsModified)
            {
                return;
            }
            MainWindow.TabBecomeVisible(this);
            MessageBoxResult ret = MessageBox.Show(string.Format("\"{0}\"の変更が保存されていません。保存しますか?", Target.DisplayName),
                                                   "確認", MessageBoxButton.YesNoCancel, MessageBoxImage.Exclamation, MessageBoxResult.Yes);

            switch (ret)
            {
            case MessageBoxResult.Yes:
                DataGridControllerResult.Save();
                break;

            case MessageBoxResult.No:
                break;

            case MessageBoxResult.Cancel:
                cancel = true;
                break;
            }
        }
Exemplo n.º 3
0
        public void Fetch(bool force)
        {
            dataGridResult.CommitEdit();
            _fetched = false;
            if (!force && DataGridControllerResult.IsModified)
            {
                MessageBoxResult ret = MessageBox.Show("変更が保存されていません。保存しますか?", "確認", MessageBoxButton.YesNoCancel, MessageBoxImage.Exclamation, MessageBoxResult.Yes);
                switch (ret)
                {
                case MessageBoxResult.Yes:
                    DataGridControllerResult.Save();
                    break;

                case MessageBoxResult.No:
                    break;

                case MessageBoxResult.Cancel:
                    return;
                }
            }
            if (Target == null)
            {
                return;
            }
            Db2SourceContext ctx = Target.Context;

            if (ctx == null)
            {
                return;
            }
            int?limit = null;

            if (IsChecked(checkBoxLimitRow) && !string.IsNullOrEmpty(textBoxLimitRow.Text))
            {
                int l;
                if (!int.TryParse(textBoxLimitRow.Text, out l))
                {
                    MessageBox.Show("件数が数字ではありません", "エラー", MessageBoxButton.OK, MessageBoxImage.Error);
                    textBoxLimitRow.Focus();
                }
                limit = l;
            }
            string orderby = sortFields.GetOrderBySql(string.Empty);
            int    offset;
            string sql = Target.GetSelectSQL(null, textBoxCondition.Text, orderby, limit, VisibleLevel, out offset);

            try
            {
                using (IDbConnection conn = ctx.NewConnection(true))
                {
                    using (IDbCommand cmd = ctx.GetSqlCommand(sql, null, conn))
                    {
                        UpdateDataGridResult(cmd);
                    }
                }
            }
            catch (Exception t)
            {
                ctx.OnLog(ctx.GetExceptionMessage(t), LogStatus.Error, sql);
                Db2SrcDataSetController.ShowErrorPosition(t, textBoxCondition, ctx, offset);
            }
            finally
            {
                UpdateTextBlockWarningLimit();
                GC.Collect(0);
            }
            _fetched = true;
        }