コード例 #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;
            }

            try
            {
                System.Text.Encoding enc = System.Text.Encoding.GetEncoding("Shift_JIS");

                //開く
                System.IO.StreamWriter sr =
                    new System.IO.StreamWriter(textBox_fileName.Text, false, enc);


                int colCount     = CSV_COLUMN_NAMES.Length;
                int lastColIndex = CSV_COLUMN_NAMES.Length - 1;

                //ヘッダを書き込む
                for (int i = 0; i < CSV_COLUMN_NAMES.Length; i++)
                {
                    //ヘッダの取得
                    string field = CSV_COLUMN_NAMES[i];

                    field = "\"" + field.Replace("_", " ") + "\"";
                    //フィールドを書き込む
                    sr.Write(field);
                    //カンマを書き込む
                    if (lastColIndex > i)
                    {
                        sr.Write(',');
                    }
                }
                //改行する
                sr.Write("\r\n");

                //レコードを書き込む
                foreach (DataRow row in _resultDt.Rows)
                {
                    for (int i = 0; i < colCount; i++)
                    {
                        //フィールドの取得
                        string field = row[CSV_COLUMN_NAMES[i]].ToString();
                        if (CSV_MSEC_DATE_CONVERT.ContainsKey(CSV_COLUMN_NAMES[i]))
                        {
                            field = (ConvertUtil.ConverIntYYYYMMDDHHMISS2Date(Convert.ToDecimal(field))).ToString("yyyy/MM/dd HH:mm:ss.fff");
                        }
                        if (CSV_DATE_CONVERT.ContainsKey(CSV_COLUMN_NAMES[i]))
                        {
                            field = (ConvertUtil.ConverIntYYYYMMDDHHMISS2Date(Convert.ToDecimal(field))).ToString("yyyy/MM/dd HH:mm:ss");
                        }

                        if (field.IndexOf('"') > -1)
                        {
                            //"を""とする
                            field = field.Replace("\"", "\"\"");
                        }
                        field = "\"" + field + "\"";
                        //フィールドを書き込む
                        sr.Write(field);
                        //カンマを書き込む
                        if (lastColIndex > i)
                        {
                            sr.Write(',');
                        }
                    }
                    //改行する
                    sr.Write("\r\n");
                }

                //閉じる
                sr.Close();
                this.Close();

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

                Consts.CSV_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);
            }

            // 終了ログ
            base.WriteEndLog("ok_Click", Consts.PROCESS_012);
        }
コード例 #2
0
        //*******************************************************************
        /// <summary>ファイル読込クリック</summary>
        /// <param name="sender">源</param>
        /// <param name="e">マウスイベント</param>
        //*******************************************************************
        private void fileRead_Click(object sender, EventArgs e)
        {
            // 開始ログ
            base.WriteStartLog("fileRead_Click", Consts.PROCESS_001);

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

            string          line;
            List <DateTime> selectedDates = new List <DateTime>();
            String          format_str    = ((FormatComboBoxItem)formatComboBox.SelectedItem).Format;

            try
            {
                System.IO.StreamReader file = new System.IO.StreamReader(textBox_fileName.Text);

                if (!System.IO.File.Exists(textBox_fileName.Text))
                {
                    throw new FileException(Consts.SYSERR_002, null);
                }

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

                Consts.FILEREAD_PATH = dirInfo.FullName;

                while ((line = file.ReadLine()) != null)
                {
                    try
                    {
                        DateTime operationDate = DateTime.ParseExact(line, format_str,
                                                                     System.Globalization.DateTimeFormatInfo.InvariantInfo, System.Globalization.DateTimeStyles.NoCurrentDateDefault);
                        selectedDates.Add(operationDate);
                    }
                    catch (Exception ex)
                    {
                        CommonDialog.ShowErrorDialog(Consts.ERROR_CALENDAR_FILE_READ_001);
                        return;
                    }
                }
                _calendarEdit.container.CalendarDetailTable.Rows.Clear();

                foreach (DateTime operationDate in selectedDates)
                {
                    DataRow row = _calendarEdit.container.CalendarDetailTable.NewRow();
                    _calendarEdit.container.CalendarDetailTable.Rows.Add(row);

                    row["calendar_id"]    = _calendarEdit.CalendarId;
                    row["update_date"]    = _calendarEdit.UpdateDate;
                    row["operating_date"] = ConvertUtil.ConverDate2IntYYYYMMDD(operationDate);
                }
                _calendarEdit.container.SetYearCalendarDetail(null);
                file.Close();
                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("fileRead_Click", Consts.PROCESS_001);
        }
コード例 #3
0
        //*******************************************************************
        /// <summary>OKボタンクリック</summary>
        /// <param name="sender">源</param>
        /// <param name="e">マウスイベント</param>
        //*******************************************************************
        private void ok_Click(object sender, EventArgs e)
        {
            char[] removeChars = new char[] { '/', ' ', ':' };      // 削除する文字の配列
            String time        = textBox_time.Text;                 // 画面からの入力値
            int    intNum      = -1;

            // 開始ログ
            base.WriteStartLog("ok_Click", Consts.PROCESS_012);

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

                // 英語圏の場合、西暦を和暦に変換
                if (!(LoginSetting.Lang.StartsWith("ja_")))
                {
                    time = getJPtime(time);
                }

                // 月/日/時/分の先頭を"0"で埋める
                time = ZeroPadding(time);

                // DBへの書き込み前のフォーマットのチェック
                if (!(IsFormat(time)))
                {
                    CommonDialog.ShowErrorDialog(Consts.ERROR_SCHEDULE_006);
                    return;
                }

                //削除する文字("/" ":")を1文字ずつ削除する
                foreach (char c in removeChars)
                {
                    time = time.Replace(c.ToString(), "");
                }

                intNum = DBUtil.SetScheduledTime(_innerJobnetId.ToString(), time);

                if (intNum != 2)
                {
                    CommonDialog.ShowErrorDialog(Consts.ERROR_SCHEDULE_005);
                }

                this.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 (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_012);
        }