Ejemplo n.º 1
0
        //*******************************************************************
        /// <summary>OKボタンクリック</summary>
        /// <param name="sender">源</param>
        /// <param name="e">マウスイベント</param>
        //*******************************************************************
        private void ok_Click(object sender, EventArgs e)
        {
            // 開始ログ
            base.WriteStartLog("ok_Click", Consts.PROCESS_012);

            // 入力チェック
            if (!InputCheck())
            {
                return;
            }
            System.IO.StreamWriter file = null;
            try
            {
                file =
                    new System.IO.StreamWriter(textBox_fileName.Text, false);
                //DataSet ds = DBUtil.Export(_objectId, _objectType, _rows);//org

                if (_rows != null && _rows.Length > 1)
                {
                    for (int i = 0; i < _rows.Length; i++)
                    {
                        DataRow row = _rows[i];
                        _objectId = row["object_id"].ToString();
                    }
                    DataSet ds = DBUtil.Export(_objectId, _objectType, _rows);
                    ds.WriteXml(file);
                }
                else
                {
                    if (_objectId == null && _rows != null)
                    {
                        DataRow row = _rows[0];
                        _objectId = row["object_id"].ToString();
                    }

                    DataSet ds = DBUtil.Export(_objectId, _objectType, _rows);
                    ds.WriteXml(file);
                }

                /* org
                 * ds.WriteXml(file);
                 * file.Close();
                 * this.Close();
                 *
                 * System.IO.DirectoryInfo dirInfoBar = new System.IO.DirectoryInfo(textBox_fileName.Text);
                 * System.IO.DirectoryInfo dirInfo = dirInfoBar.Parent;
                 *
                 * Consts.EXPORT_PATH = dirInfo.FullName;
                 *
                 */
            }
            catch (ArgumentException ex)
            {
                CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_019);
            }
            catch (NotSupportedException ex)
            {
                CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_019);
            }
            catch (DirectoryNotFoundException ex)
            {
                CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_022);
            }
            catch (UnauthorizedAccessException ex)
            {
                CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_023);
            }
            catch (System.IO.IOException ex)
            {
                CommonDialog.ShowErrorDialogFromMessage(ex.Message);
            }
            catch (Exception ex)
            {
                CommonDialog.ShowErrorDialogFromMessage(ex.Message);
            }
            finally
            {
                file.Close();
                this.Close();

                System.IO.DirectoryInfo dirInfoBar = new System.IO.DirectoryInfo(textBox_fileName.Text);
                System.IO.DirectoryInfo dirInfo    = dirInfoBar.Parent;

                Consts.EXPORT_PATH = dirInfo.FullName;
            }
            // 終了ログ
            base.WriteEndLog("ok_Click", Consts.PROCESS_012);
        }
Ejemplo n.º 2
0
        //*******************************************************************
        /// <summary>OKボタンクリック</summary>
        /// <param name="sender">源</param>
        /// <param name="e">マウスイベント</param>
        //*******************************************************************
        private void ok_Click(object sender, EventArgs e)
        {
            // 開始ログ
            base.WriteStartLog("ok_Click", Consts.PROCESS_013);

            // 入力チェック
            if (!InputCheck())
            {
                return;
            }

            try
            {
                System.IO.FileStream    fs         = new System.IO.FileStream(textBox_fileName.Text, System.IO.FileMode.Open);
                System.IO.DirectoryInfo dirInfoBar = new System.IO.DirectoryInfo(textBox_fileName.Text);
                System.IO.DirectoryInfo dirInfo    = dirInfoBar.Parent;

                Consts.IMPORT_PATH = dirInfo.FullName;

                DataSet ds = new DataSet();
                try
                {
                    ds.ReadXml(fs, XmlReadMode.InferSchema);
                }
                catch (Exception ex)
                {
                    CommonDialog.ShowErrorDialog(Consts.ERROR_IMPORT_001);
                    return;
                }
                try
                {
                    DataTable userInfo = checkUserInfo(ds);
                    if (userInfo == null)
                    {
                        CommonDialog.ShowErrorDialog(Consts.ERROR_IMPORT_002);
                        return;
                    }
                    if (!checkImportAuth(userInfo))
                    {
                        CommonDialog.ShowErrorDialog(Consts.ERROR_IMPORT_003);
                        return;
                    }

                    Consts.ImportResultType result = DBUtil.ImportForm(ds, (bool)CheckBoxOverride.IsChecked);
                    if (result == Consts.ImportResultType.DubleKeyErr)
                    {
                        CommonDialog.ShowErrorDialog(Consts.ERROR_IMPORT_004);
                        return;
                    }
                    if (result == Consts.ImportResultType.RelationErr)
                    {
                        CommonDialog.ShowErrorDialog(Consts.ERROR_IMPORT_005);
                        return;
                    }
                    fs.Close();
                    Close();
                    _jobArrangerWindow.RefreshObjectList();
                }
                catch (Exception ex1)
                {
                    throw ex1;
                }
                finally
                {
                    fs.Close();
                }
            }
            catch (ArgumentException ex)
            {
                CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_019);
            }
            catch (NotSupportedException ex)
            {
                CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_019);
            }
            catch (DirectoryNotFoundException ex)
            {
                CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_022);
            }
            catch (FileNotFoundException ex)
            {
                CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_011);
            }
            catch (UnauthorizedAccessException ex)
            {
                CommonDialog.ShowErrorDialog(Consts.ERROR_COMMON_023);
            }
            catch (System.IO.IOException ex)
            {
                CommonDialog.ShowErrorDialogFromMessage(ex.Message);
            }
            catch (Exception ex)
            {
                CommonDialog.ShowErrorDialogFromMessage(ex.Message);
            }

            // 終了ログ
            base.WriteEndLog("ok_Click", Consts.PROCESS_013);
        }