Esempio n. 1
0
        /// <summary>
        /// データ取得
        /// </summary>
        /// <returns></returns>
        private List <CreaterData> getData()
        {
            MySqlConnection cn     = null;
            MySqlCommand    cmd    = null;
            MySqlDataReader reader = null;

            try
            {
                cn = new MySqlConnection(this.connectionString);
                cn.Open();

                cmd             = cn.CreateCommand();
                cmd.CommandText = @"
select
  id,
  name,
  password as pass,
  pixiv_id as pixiv,
  twitter_id as twitter
from
  creater
order by
  name asc
;";
                reader          = cmd.ExecuteReader();

                List <CreaterData> data = new List <CreaterData>();
                while (reader.Read())
                {
                    CreaterData doc = new CreaterData();
                    doc.ID        = reader["id"].ToString();
                    doc.Name      = reader["name"].ToString();
                    doc.PixivID   = reader["pixiv"].ToString();
                    doc.TwitterID = reader["twitter"].ToString();
                    doc.Password  = reader["pass"].ToString();
                    data.Add(doc);
                }

                return(data);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                if (cmd != null)
                {
                    cmd.Dispose();
                }
                if (cn != null)
                {
                    cn.Close();
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 「編集」
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_Update_Click(object sender, EventArgs e)
        {
            if (this.listView_Display.SelectedItems.Count < 1)
            {
                MessageBox.Show("項目が選択されていません。",
                                "Error!!",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);

                return;
            }

            ListViewItem item = this.listView_Display.SelectedItems[0];

            using (Form_UpdateCharacter f = new Form_UpdateCharacter())
            {
                CharacterData doc = new CharacterData();
                doc.ID           = item.SubItems[6].Text;
                doc.Name         = item.SubItems[1].Text;
                doc.Kana         = item.SubItems[9].Text;
                doc.Sex          = item.SubItems[2].Text;
                doc.Type         = item.SubItems[0].Text;
                doc.Race         = item.SubItems[10].Text;
                doc.Age          = item.SubItems[11].Text;
                doc.Grade        = item.SubItems[3].Text;
                doc.Skill        = item.SubItems[4].Text;
                doc.Club         = item.SubItems[12].Text;
                doc.Organization = item.SubItems[13].Text;
                doc.Remarks      = item.SubItems[14].Text.Replace(",", Environment.NewLine);
                CreaterData creater = new CreaterData();
                creater.ID  = item.SubItems[7].Text;
                doc.Creater = creater;
                string[] urlArray = item.Tag.ToString().Split(',');
                doc.URLToWiki = urlArray[2];
                string url = string.Empty;
                for (int i = 3; i < urlArray.Length; i++)
                {
                    url += urlArray[i] + Environment.NewLine;
                }
                doc.URLToPixiv = url.Substring(0, url.Length - 1);
                f.Character    = doc;
                f.Pass         = item.SubItems[8].Text;
                doc.ImageData  = this.imageList[this.listView_Display.SelectedIndices[0]];

                DialogResult dr = f.ShowDialog();
                if (dr != DialogResult.OK)
                {
                    return;
                }

                // 更新
                loadDisplay();
            }
        }
        private void updateCreater(CreaterData doc)
        {
            string          sql   = @"
update
 creater 
set
  name = @name,
  pixiv_id = @pixiv,
  twitter_id = @twitter
where
  id = @id
;";
            List <string[]> param = new List <string[]>();

            param.Add(new string[] { "name", doc.Name });
            param.Add(new string[] { "pixiv", doc.PixivID });
            param.Add(new string[] { "twitter", doc.TwitterID });
            param.Add(new string[] { "id", doc.ID });

            executeQuery(sql, param);
        }
        private void insertCreater(CreaterData doc)
        {
            string sql = @"
insert into
  creater
values (
  null,
  @name,
  @pass,
  @pixiv,
  @twitter
);";

            List <string[]> param = new List <string[]>();

            param.Add(new string[] { "name", doc.Name });
            param.Add(new string[] { "pass", doc.Password });
            param.Add(new string[] { "pixiv", doc.PixivID });
            param.Add(new string[] { "twitter", doc.TwitterID });

            executeQuery(sql, param);
        }
Esempio n. 5
0
        private void validateAndUpdate()
        {
            #region 入力チェック
            // パスワード
            string pass = this.textBox_Pass.Text.Trim();
            if (pass == string.Empty)
            {
                MessageBox.Show("パスワードが未入力です。",
                                "Error!!",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            if (!pass.Equals(this.Pass))
            {
                MessageBox.Show("登録時のパスワードと一致しません。",
                                "Error!!",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            // 名前
            if (this.textBox_Name.Text.Trim() == string.Empty)
            {
                MessageBox.Show("名前が未入力です。",
                                "Error!!",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            // よみがな
            if (this.textBox_Kana.Text.Trim() == string.Empty)
            {
                MessageBox.Show("よみがなが未入力です。",
                                "Error!!",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            // 種族
            if (this.textBox_Race.Text.Trim() == string.Empty)
            {
                MessageBox.Show("種族が未入力です。",
                                "Error!!",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            // 年齢
            string age = this.textBox_Age.Text.Trim();
            if (age == string.Empty)
            {
                MessageBox.Show("年齢が未入力です。",
                                "Error!!",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            age = Strings.StrConv(age, VbStrConv.Narrow);

            // 学年
            string grade = this.textBox_Grade.Text.Trim();
            if (grade == string.Empty)
            {
                MessageBox.Show("学年が未入力です。",
                                "Error!!",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            grade = Strings.StrConv(grade, VbStrConv.Narrow);

            // キャラクターシートURL
            if (this.textBox_URLToPixiv.Text.Trim() == string.Empty)
            {
                MessageBox.Show("キャラクターシートURLが未入力です。",
                                "Error!!",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            // 魔砲
            string skill = this.textBox_Skill.Text.Trim();
            if (skill == string.Empty)
            {
                skill = "NoData";
            }

            // 部活
            string club = string.Empty;
            if (this.textBox_Club.Text.Trim() != string.Empty)
            {
                club = this.textBox_Club.Text.Trim();
            }

            // 組織
            string organization = string.Empty;
            if (this.textBox_Organization.Text.Trim() != string.Empty)
            {
                organization = this.textBox_Organization.Text.Trim();
            }

            // 親御さん情報
            CreaterData creater = new CreaterData();
            creater.ID = this.createrID[this.comboBox_Creater.SelectedIndex];

            // キャラクターシートURL
            if (this.textBox_URLToPixiv.Text.Trim() == string.Empty)
            {
                MessageBox.Show("キャラクターシートURLが未入力です。",
                                "Error!!",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
            string url = this.textBox_URLToPixiv.Text.Trim();
            #endregion

            DialogResult dr = MessageBox.Show(string.Format(@"
以下の情報で登録してよろしいですか?

名前 : {0}
よみがな : {1}
性別 : {2}
属性 : {3}
種族 : {4}
年齢 : {5}
学年 : {6}
魔砲 : {7}
部活 : {8}
組織 : {9}
備考 : {10}
キャラクターシートURL :
{11}
WikiURL :
{12}

親御さん情報
名前 : {13}",
                                                            this.textBox_Name.Text.Trim(),
                                                            this.textBox_Kana.Text.Trim(),
                                                            this.comboBox_Sex.SelectedItem.ToString(),
                                                            this.comboBox_Type.SelectedItem.ToString(),
                                                            this.textBox_Race.Text.Trim(),
                                                            age,
                                                            grade,
                                                            skill,
                                                            club,
                                                            organization,
                                                            this.textBox_Remarks.Text.Trim(),
                                                            url,
                                                            this.textBox_Wiki.Text.Trim() != string.Empty ? this.textBox_Wiki.Text.Trim() : "なし",
                                                            this.comboBox_Creater.Text.Trim()
                                                            ),
                                              "Question.",
                                              MessageBoxButtons.OKCancel,
                                              MessageBoxIcon.Question);

            if (dr != DialogResult.OK)
            {
                return;
            }

            CharacterData doc = new CharacterData();
            doc.Type         = this.typeID[this.comboBox_Type.SelectedIndex];
            doc.Name         = this.textBox_Name.Text.Trim();
            doc.Kana         = this.textBox_Kana.Text.Trim();
            doc.Sex          = this.sexID[this.comboBox_Sex.SelectedIndex];
            doc.Race         = this.textBox_Race.Text.Trim();
            doc.Age          = age;
            doc.Grade        = grade;
            doc.Skill        = skill;
            doc.Club         = club;
            doc.Organization = organization;
            doc.Remarks      = this.textBox_Remarks.Text.Trim().Replace(Environment.NewLine, ",");
            doc.URLToWiki    = this.textBox_Wiki.Text.Trim();
            doc.URLToPixiv   = url.Replace(Environment.NewLine, ",");
            doc.Creater      = new CreaterData();
            doc.Creater.ID   = this.createrID[this.comboBox_Creater.SelectedIndex];
            byte[] imageData = new byte[0];
            if (this.picturePath != string.Empty)
            {
                imageData = File.ReadAllBytes(this.picturePath);
            }
            else if (this.pictureBox_Character.Image != null)
            {
                imageData = convertImageToByteArray(this.pictureBox_Character.Image);
            }
            doc.ImageData = imageData;

            try
            {
                // データ更新
                update(doc, this.Character.ID);
                MessageBox.Show("Success!!");
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                string message = @"Error!!

" + ex.Message;
                if (ex.Message.StartsWith("Unable to connect to any of the specified "))
                {
                    message = @"データベースに接続できませんでした。
サーバーが立ち上がっていない可能性がありますので、今しばらくお待ち下さい。
現在のサーバーの状況は、以下のTwitterアカウントにて随時報告されております。

https://twitter.com/mikaze_Atlantis";
                    MessageBox.Show(message,
                                    "Error!!",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show(message,
                                    "Error!!",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }

            this.Close();
        }
Esempio n. 6
0
        /// <summary>
        /// データ取得
        /// </summary>
        /// <returns></returns>
        private List<CharacterData> getData()
        {
            MySqlConnection cn = null;
            MySqlCommand cmd = null;
            MySqlDataReader reader = null;

            try
            {
                cn = new MySqlConnection(this.connectionString);
                cn.Open();

                cmd = cn.CreateCommand();
                cmd.CommandText = @"
            select
              ch.id as id,
              ch.name as name,
              ch.kana as kana,
              t.name as type,
              g.name as gender,
              ch.race as race,
              ch.age as age,
              ch.grade as grade,
              ch.skill as skill,
              ch.club as club,
              ch.organization as org,
              ch.remarks as rem,
              cr.id as cr_id,
              cr.name as cr_name,
              cr.pixiv_id as pixiv,
              cr.twitter_id as twitter,
              ch.wiki_url as wiki,
              ch.sheet_url as sheet,
              cr.password as pass
            from
              chara ch
              join creater cr
            on ch.creater_id = cr.id
            join type t
              on ch.type_id = t.id
              join gender g
            on ch.gender_id = g.id
            order by
              t.id asc,
              ch.kana asc
            ;";
                reader = cmd.ExecuteReader();

                List<CharacterData> data = new List<CharacterData>();
                //this.imageList.Clear();
                while (reader.Read())
                {
                    CharacterData doc = new CharacterData();
                    doc.ID = reader["id"].ToString();
                    doc.Name = reader["name"].ToString();
                    doc.Kana = reader["kana"].ToString();
                    doc.Type = reader["type"].ToString();
                    doc.Race = reader["race"].ToString();
                    doc.Sex = reader["gender"].ToString();
                    doc.Age = reader["age"].ToString();
                    doc.Grade = reader["grade"].ToString();
                    doc.Skill = reader["skill"].ToString();
                    doc.Club = reader["club"].ToString();
                    doc.Organization = reader["org"].ToString();
                    doc.Remarks = reader["rem"].ToString();
                    doc.URLToWiki = reader["wiki"].ToString();
                    doc.URLToPixiv = reader["sheet"].ToString();

                    CreaterData creater = new CreaterData();
                    creater.ID = reader["cr_id"].ToString();
                    creater.Name = reader["cr_name"].ToString();
                    creater.PixivID = reader["pixiv"].ToString();
                    creater.TwitterID = reader["twitter"].ToString();
                    creater.Password = reader["pass"].ToString();
                    doc.Creater = creater;

                    data.Add(doc);
                    /*
                    byte[] imageData = new byte[0];
                    if (reader["IMAGE"].ToString() != string.Empty)
                    {
                        imageData = (byte[])reader["IMAGE"];
                    }
                    this.imageList.Add(imageData);*/
                }

                return data;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                if (cmd != null)
                {
                    cmd.Dispose();
                }
                if (cn != null)
                {
                    cn.Close();
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 「編集」
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_Update_Click(object sender, EventArgs e)
        {
            if (this.listView_Display.SelectedItems.Count < 1)
            {
                MessageBox.Show("項目が選択されていません。",
                    "Error!!",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);

                return;
            }

            ListViewItem item = this.listView_Display.SelectedItems[0];

            using (Form_UpdateCharacter f = new Form_UpdateCharacter())
            {
                CharacterData doc = new CharacterData();
                doc.ID = item.SubItems[6].Text;
                doc.Name = item.SubItems[1].Text;
                doc.Kana = item.SubItems[9].Text;
                doc.Sex = item.SubItems[2].Text;
                doc.Type = item.SubItems[0].Text;
                doc.Race = item.SubItems[10].Text;
                doc.Age = item.SubItems[11].Text;
                doc.Grade = item.SubItems[3].Text;
                doc.Skill = item.SubItems[4].Text;
                doc.Club = item.SubItems[12].Text;
                doc.Organization = item.SubItems[13].Text;
                doc.Remarks = item.SubItems[14].Text.Replace(",", Environment.NewLine);
                CreaterData creater = new CreaterData();
                creater.ID = item.SubItems[7].Text;
                doc.Creater = creater;
                string[] urlArray = item.Tag.ToString().Split(',');
                doc.URLToWiki = urlArray[2];
                string url = string.Empty;
                for (int i = 3; i < urlArray.Length; i++)
                {
                    url += urlArray[i] + Environment.NewLine;
                }
                doc.URLToPixiv = url.Substring(0, url.Length - 1);
                f.Character = doc;
                f.Pass = item.SubItems[8].Text;
                doc.ImageData = this.imageList[this.listView_Display.SelectedIndices[0]];

                DialogResult dr = f.ShowDialog();
                if (dr != DialogResult.OK)
                {
                    return;
                }

                // 更新
                loadDisplay();
            }
        }
        private void validateAndUpdate()
        {
            string name    = this.textBox_Name.Text.Trim();
            string pass    = this.textBox_Pass.Text.Trim();
            string pixiv   = this.textBox_Pixiv.Text.Trim();
            string twitter = this.textBox_Twitter.Text.Trim();

            if (name == string.Empty ||
                pass == string.Empty ||
                pixiv == string.Empty)
            {
                MessageBox.Show("未入力の項目があります。",
                                "Error!!",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            if (!pass.Equals(this.Pass))
            {
                MessageBox.Show("登録時のパスワードと一致しません。",
                                "Error!!",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            // TwitterIDから @ を削除
            if (twitter.Length != 0 &&
                twitter[0] == '@')
            {
                twitter = twitter.Substring(1, twitter.Length - 1);
            }

            string confirmMessage = string.Format(@"
以下の内容で編集します。
よろしいですか?

名前 : {0}
PixivID : {1}
TwitterID : {2}",
                                                  name,
                                                  pixiv,
                                                  twitter != string.Empty ? "@" + twitter : "なし"
                                                  );
            DialogResult dr = MessageBox.Show(confirmMessage,
                                              "Question.",
                                              MessageBoxButtons.OKCancel,
                                              MessageBoxIcon.Question);

            if (dr != DialogResult.OK)
            {
                return;
            }

            CreaterData doc = new CreaterData();

            doc.Name      = name;
            doc.PixivID   = pixiv;
            doc.TwitterID = twitter;
            doc.ID        = this.ID;

            try
            {
                // 登録
                updateCreater(doc);

                MessageBox.Show("Success!");
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                string message = @"Error!!

" + ex.Message;
                if (ex.Message.StartsWith("Unable to connect to any of the specified "))
                {
                    message = @"データベースに接続できませんでした。
サーバーが立ち上がっていない可能性がありますので、今しばらくお待ち下さい。
現在のサーバーの状況は、以下のTwitterアカウントにて随時報告されております。

https://twitter.com/mikaze_Atlantis";
                    MessageBox.Show(message,
                                    "Error!!",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show(message,
                                    "Error!!",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }
        }
        private void validateAndUpdate()
        {
            #region 入力チェック
            // パスワード
            string pass = this.textBox_Pass.Text.Trim();
            if (pass == string.Empty)
            {
                MessageBox.Show("パスワードが未入力です。",
                    "Error!!",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }
            if (!pass.Equals(this.Pass))
            {
                MessageBox.Show("登録時のパスワードと一致しません。",
                    "Error!!",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }

            // 名前
            if (this.textBox_Name.Text.Trim() == string.Empty)
            {
                MessageBox.Show("名前が未入力です。",
                    "Error!!",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }

            // よみがな
            if (this.textBox_Kana.Text.Trim() == string.Empty)
            {
                MessageBox.Show("よみがなが未入力です。",
                    "Error!!",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }

            // 種族
            if (this.textBox_Race.Text.Trim() == string.Empty)
            {
                MessageBox.Show("種族が未入力です。",
                    "Error!!",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }

            // 年齢
            string age = this.textBox_Age.Text.Trim();
            if (age == string.Empty)
            {
                MessageBox.Show("年齢が未入力です。",
                    "Error!!",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }
            age = Strings.StrConv(age, VbStrConv.Narrow);

            // 学年
            string grade = this.textBox_Grade.Text.Trim();
            if (grade == string.Empty)
            {
                MessageBox.Show("学年が未入力です。",
                    "Error!!",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }
            grade = Strings.StrConv(grade, VbStrConv.Narrow);

            // キャラクターシートURL
            if (this.textBox_URLToPixiv.Text.Trim() == string.Empty)
            {
                MessageBox.Show("キャラクターシートURLが未入力です。",
                    "Error!!",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }

            // 魔砲
            string skill = this.textBox_Skill.Text.Trim();
            if (skill == string.Empty)
            {
                skill = "NoData";
            }

            // 部活
            string club = string.Empty;
            if (this.textBox_Club.Text.Trim() != string.Empty)
            {
                club = this.textBox_Club.Text.Trim();
            }

            // 組織
            string organization = string.Empty;
            if (this.textBox_Organization.Text.Trim() != string.Empty)
            {
                organization = this.textBox_Organization.Text.Trim();
            }

            // 親御さん情報
            CreaterData creater = new CreaterData();
            creater.ID = this.createrID[this.comboBox_Creater.SelectedIndex];

            // キャラクターシートURL
            if (this.textBox_URLToPixiv.Text.Trim() == string.Empty)
            {
                MessageBox.Show("キャラクターシートURLが未入力です。",
                    "Error!!",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }
            string url = this.textBox_URLToPixiv.Text.Trim();
            #endregion

            DialogResult dr = MessageBox.Show(string.Format(@"
            以下の情報で登録してよろしいですか?

            名前 : {0}
            よみがな : {1}
            性別 : {2}
            属性 : {3}
            種族 : {4}
            年齢 : {5}
            学年 : {6}
            魔砲 : {7}
            部活 : {8}
            組織 : {9}
            備考 : {10}
            キャラクターシートURL :
            {11}
            WikiURL :
            {12}

            親御さん情報
            名前 : {13}",
                 this.textBox_Name.Text.Trim(),
                 this.textBox_Kana.Text.Trim(),
                 this.comboBox_Sex.SelectedItem.ToString(),
                 this.comboBox_Type.SelectedItem.ToString(),
                 this.textBox_Race.Text.Trim(),
                 age,
                 grade,
                 skill,
                 club,
                 organization,
                 this.textBox_Remarks.Text.Trim(),
                 url,
                 this.textBox_Wiki.Text.Trim() != string.Empty ? this.textBox_Wiki.Text.Trim() : "なし",
                 this.comboBox_Creater.Text.Trim()
                 ),
                "Question.",
                MessageBoxButtons.OKCancel,
                MessageBoxIcon.Question);

            if (dr != DialogResult.OK)
            {
                return;
            }

            CharacterData doc = new CharacterData();
            doc.Type = this.typeID[this.comboBox_Type.SelectedIndex];
            doc.Name = this.textBox_Name.Text.Trim();
            doc.Kana = this.textBox_Kana.Text.Trim();
            doc.Sex = this.sexID[this.comboBox_Sex.SelectedIndex];
            doc.Race = this.textBox_Race.Text.Trim();
            doc.Age = age;
            doc.Grade = grade;
            doc.Skill = skill;
            doc.Club = club;
            doc.Organization = organization;
            doc.Remarks = this.textBox_Remarks.Text.Trim().Replace(Environment.NewLine, ",");
            doc.URLToWiki = this.textBox_Wiki.Text.Trim();
            doc.URLToPixiv = url.Replace(Environment.NewLine, ",");
            doc.Creater = new CreaterData();
            doc.Creater.ID = this.createrID[this.comboBox_Creater.SelectedIndex];
            byte[] imageData = new byte[0];
            if (this.picturePath != string.Empty)
            {
                imageData = File.ReadAllBytes(this.picturePath);
            }
            else if (this.pictureBox_Character.Image != null)
            {
                imageData = convertImageToByteArray(this.pictureBox_Character.Image);
            }
            doc.ImageData = imageData;

            try
            {
                // データ更新
                update(doc, this.Character.ID);
                MessageBox.Show("Success!!");
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                string message = @"Error!!

            " + ex.Message;
                if (ex.Message.StartsWith("Unable to connect to any of the specified "))
                {
                    message = @"データベースに接続できませんでした。
            サーバーが立ち上がっていない可能性がありますので、今しばらくお待ち下さい。
            現在のサーバーの状況は、以下のTwitterアカウントにて随時報告されております。

            https://twitter.com/mikaze_Atlantis";
                    MessageBox.Show(message,
                        "Error!!",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show(message,
                        "Error!!",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
            }

            this.Close();
        }
Esempio n. 10
0
        /// <summary>
        /// データ取得
        /// </summary>
        /// <returns></returns>
        private List <CharacterData> getData()
        {
            MySqlConnection cn     = null;
            MySqlCommand    cmd    = null;
            MySqlDataReader reader = null;

            try
            {
                cn = new MySqlConnection(this.connectionString);
                cn.Open();

                cmd             = cn.CreateCommand();
                cmd.CommandText = @"
select
  ch.id as id,
  ch.name as name,
  ch.kana as kana,
  t.name as type, 
  g.name as gender,
  ch.race as race, 
  ch.age as age, 
  ch.grade as grade,
  ch.skill as skill, 
  ch.club as club,
  ch.organization as org,
  ch.remarks as rem, 
  cr.id as cr_id, 
  cr.name as cr_name,
  cr.pixiv_id as pixiv, 
  cr.twitter_id as twitter, 
  ch.wiki_url as wiki, 
  ch.sheet_url as sheet,
  cr.password as pass
from
  chara ch
  join creater cr
    on ch.creater_id = cr.id
    join type t
      on ch.type_id = t.id 
      join gender g
        on ch.gender_id = g.id
order by
  t.id asc,
  ch.kana asc
;";
                reader          = cmd.ExecuteReader();

                List <CharacterData> data = new List <CharacterData>();
                //this.imageList.Clear();
                while (reader.Read())
                {
                    CharacterData doc = new CharacterData();
                    doc.ID           = reader["id"].ToString();
                    doc.Name         = reader["name"].ToString();
                    doc.Kana         = reader["kana"].ToString();
                    doc.Type         = reader["type"].ToString();
                    doc.Race         = reader["race"].ToString();
                    doc.Sex          = reader["gender"].ToString();
                    doc.Age          = reader["age"].ToString();
                    doc.Grade        = reader["grade"].ToString();
                    doc.Skill        = reader["skill"].ToString();
                    doc.Club         = reader["club"].ToString();
                    doc.Organization = reader["org"].ToString();
                    doc.Remarks      = reader["rem"].ToString();
                    doc.URLToWiki    = reader["wiki"].ToString();
                    doc.URLToPixiv   = reader["sheet"].ToString();

                    CreaterData creater = new CreaterData();
                    creater.ID        = reader["cr_id"].ToString();
                    creater.Name      = reader["cr_name"].ToString();
                    creater.PixivID   = reader["pixiv"].ToString();
                    creater.TwitterID = reader["twitter"].ToString();
                    creater.Password  = reader["pass"].ToString();
                    doc.Creater       = creater;

                    data.Add(doc);

                    /*
                     * byte[] imageData = new byte[0];
                     * if (reader["IMAGE"].ToString() != string.Empty)
                     * {
                     *  imageData = (byte[])reader["IMAGE"];
                     * }
                     * this.imageList.Add(imageData);*/
                }

                return(data);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                if (cmd != null)
                {
                    cmd.Dispose();
                }
                if (cn != null)
                {
                    cn.Close();
                }
            }
        }
        private void validateAndUpdate()
        {
            string name = this.textBox_Name.Text.Trim();
            string pass = this.textBox_Pass.Text.Trim();
            string pixiv = this.textBox_Pixiv.Text.Trim();
            string twitter = this.textBox_Twitter.Text.Trim();

            if (name == string.Empty ||
                pass == string.Empty ||
                pixiv == string.Empty)
            {
                MessageBox.Show("未入力の項目があります。",
                    "Error!!",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }

            if (!pass.Equals(this.Pass))
            {
                MessageBox.Show("登録時のパスワードと一致しません。",
                    "Error!!",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }

            // TwitterIDから @ を削除
            if (twitter.Length != 0 &&
                twitter[0] == '@')
            {
                twitter = twitter.Substring(1, twitter.Length - 1);
            }

            string confirmMessage = string.Format(@"
            以下の内容で編集します。
            よろしいですか?

            名前 : {0}
            PixivID : {1}
            TwitterID : {2}",
                name,
                pixiv,
                twitter != string.Empty ? "@" + twitter : "なし"
            );
            DialogResult dr = MessageBox.Show(confirmMessage,
                "Question.",
                MessageBoxButtons.OKCancel,
                MessageBoxIcon.Question);

            if (dr != DialogResult.OK)
            {
                return;
            }

            CreaterData doc = new CreaterData();
            doc.Name = name;
            doc.PixivID = pixiv;
            doc.TwitterID = twitter;
            doc.ID = this.ID;

            try
            {
                // 登録
                updateCreater(doc);

                MessageBox.Show("Success!");
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                string message = @"Error!!

            " + ex.Message;
                if (ex.Message.StartsWith("Unable to connect to any of the specified "))
                {
                    message = @"データベースに接続できませんでした。
            サーバーが立ち上がっていない可能性がありますので、今しばらくお待ち下さい。
            現在のサーバーの状況は、以下のTwitterアカウントにて随時報告されております。

            https://twitter.com/mikaze_Atlantis";
                    MessageBox.Show(message,
                        "Error!!",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show(message,
                        "Error!!",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
            }
        }
        private void updateCreater(CreaterData doc)
        {
            string sql = @"
            update
             creater
            set
              name = @name,
              pixiv_id = @pixiv,
              twitter_id = @twitter
            where
              id = @id
            ;";
            List<string[]> param = new List<string[]>();
            param.Add(new string[] { "name", doc.Name });
            param.Add(new string[] { "pixiv", doc.PixivID });
            param.Add(new string[] { "twitter", doc.TwitterID });
            param.Add(new string[] { "id", doc.ID });

            executeQuery(sql, param);
        }
Esempio n. 13
0
        /// <summary>
        /// データ取得
        /// </summary>
        /// <returns></returns>
        private List<CreaterData> getData()
        {
            MySqlConnection cn = null;
            MySqlCommand cmd = null;
            MySqlDataReader reader = null;

            try
            {
                cn = new MySqlConnection(this.connectionString);
                cn.Open();

                cmd = cn.CreateCommand();
                cmd.CommandText = @"
            select
              id,
              name,
              password as pass,
              pixiv_id as pixiv,
              twitter_id as twitter
            from
              creater
            order by
              name asc
            ;";
                reader = cmd.ExecuteReader();

                List<CreaterData> data = new List<CreaterData>();
                while (reader.Read())
                {
                    CreaterData doc = new CreaterData();
                    doc.ID = reader["id"].ToString();
                    doc.Name = reader["name"].ToString();
                    doc.PixivID = reader["pixiv"].ToString();
                    doc.TwitterID = reader["twitter"].ToString();
                    doc.Password = reader["pass"].ToString();
                    data.Add(doc);
                }

                return data;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                if (cmd != null)
                {
                    cmd.Dispose();
                }
                if (cn != null)
                {
                    cn.Close();
                }
            }
        }