static void Main() { Define.Init(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new FormMain()); }
private void btnOK_Click(object sender, EventArgs e) { string input = textBox1.Text; long v = Define.Convert(input); if (-1 == v) { Define.ErrorMessageBox("소수점은 8자리까지 입력할 수 있습니다."); return; } if (VotedVEOS < v) { Define.ErrorMessageBox("투표한 VEOS 양보다 더 많은 값이 입력되었습니다."); return; } DB.Open(); if (VotedVEOS == v) { DB.RunQuery($"DELETE FROM Vote WHERE UserId = {Define.MyUserId} AND NodeId = {SelectedNodeId}"); } else { DB.RunQuery($"UPDATE Vote SET VEOS = VEOS - {v} WHERE UserId = {Define.MyUserId} AND NodeId = {SelectedNodeId}"); } DB.RunQuery($"UPDATE User SET VEOS = VEOS + {v} WHERE Id = {Define.MyUserId}"); DB.Close(); MessageBox.Show("투표철회되었습니다."); Close(); }
private void FormVEOS2EOS_Load(object sender, EventArgs e) { DB.Open(); MyCurrentVEOS = 0; DB.RunReadQuery($"SELECT VEOS FROM User WHERE Id = {Define.MyUserId}", (r) => { MyCurrentVEOS = r.GetInt64(0); }); DB.Close(); textBox1.Text = Define.Convert(MyCurrentVEOS); }
private void btnOK_Click(object sender, EventArgs e) { string input = textBox1.Text; long v = Define.Convert(input); if (-1 == v) { Define.ErrorMessageBox("소수점은 8자리까지 입력할 수 있습니다."); return; } if (MyCurrentEOS < v) { Define.ErrorMessageBox("보유한 EOS 양보다 더 많은 값이 입력되었습니다."); return; } var dr = MessageBox.Show($"{Define.Convert(v)} EOS 코인을 VEOS 코인으로 전환하시겠습니까? 확인버튼을 누를경우 즉시 전환됩니다.", "확인", MessageBoxButtons.OKCancel); if (dr == DialogResult.Cancel) { return; } long vv = v; DB.Open(); foreach (var eos in EOSList) { if (vv < eos.Amount) { DB.RunQuery($"UPDATE Me SET EOS = EOS - {vv} WHERE Id = {eos.Id}"); break; } else if (vv > eos.Amount) { DB.RunQuery($"DELETE FROM Me WHERE Id = {eos.Id}"); vv -= eos.Amount; } else { DB.RunQuery($"DELETE FROM Me WHERE Id = {eos.Id}"); break; } } DB.RunQuery($"UPDATE User SET VEOS = VEOS + {v} WHERE Id = {Define.MyUserId}"); DB.Close(); MessageBox.Show("전환되었습니다."); Close(); }
private void FormVoteCancel_Load(object sender, EventArgs e) { DB.Open(); DB.RunReadQuery($"SELECT VEOS FROM Vote WHERE UserId = {Define.MyUserId} AND NodeId = {SelectedNodeId}", r => { VotedVEOS = r.GetInt64(0); }); DB.Close(); if (0 == VotedVEOS) { Define.ErrorMessageBox("해당 노드에 투표철회할 VEOS가 없습니다."); Close(); } textBox1.Text = Define.Convert(VotedVEOS); }
private void FormVote_Load(object sender, EventArgs e) { DB.Open(); MyCurrentVEOS = 0; DB.RunReadQuery($"SELECT VEOS FROM User WHERE Id = {Define.MyUserId}", (r) => { MyCurrentVEOS = r.GetInt64(0); }); DB.Close(); if (0 == MyCurrentVEOS) { Define.ErrorMessageBox("투표가능한 VEOS가 없습니다."); Close(); } textBox1.Text = Define.Convert(MyCurrentVEOS); }
private void btnOK_Click(object sender, EventArgs e) { string input = textBox1.Text; long v = Define.Convert(input); if (-1 == v) { Define.ErrorMessageBox("소수점은 8자리까지 입력할 수 있습니다."); return; } if (MyCurrentVEOS < v) { Define.ErrorMessageBox("보유한 VEOS 양보다 더 많은 값이 입력되었습니다."); return; } string time1 = Define.SecondsToMessage(Define.ConvertTimeSecond); string time2 = Define.SecondsToMessage(Define.ConvertStep * Define.ConvertTimeSecond); var dr = MessageBox.Show($"{Define.Convert(v)} VEOS 코인을 EOS 코인으로 전환하시겠습니까? 확인버튼을 누를경우 {time1} 경과시마다 1/{Define.ConvertStep}씩 전환되어 100% 전환되기까지 총 {time2}이(가) 소요됩니다.", "확인", MessageBoxButtons.OKCancel); if (dr == DialogResult.Cancel) { return; } long divideAmount = v / Define.ConvertStep; int mod = (int)(v % Define.ConvertStep); DB.Open(); DB.RunQuery($"UPDATE User SET VEOS = VEOS - {v} WHERE Id = {Define.MyUserId}"); for (int i = 1; i <= Define.ConvertStep; i++, mod--) { DB.RunQuery($"INSERT INTO Me (EOS, VTIME) VALUES ({divideAmount + ((0 < mod) ? 1 : 0)}, '{DateTime.Now.AddSeconds(Define.ConvertTimeSecond * i).ToString("yyyy-MM-dd HH:mm:ss") }')"); } DB.Close(); MessageBox.Show("전환되었습니다."); Close(); }
private void FormEOS2VEOS_Load(object sender, EventArgs e) { DB.Open(); DB.RunReadQuery("SELECT Id, EOS, VTIME FROM Me", (r) => { int id = r.GetInt32(0); long value = r.GetInt64(1); DateTime vtime = r.GetDateTime(2); if (vtime < DateTime.Now) { EOSList.Add(new EOSSplit() { Id = id, Amount = value }); } }); DB.Close(); MyCurrentEOS = EOSList.Sum(eos => eos.Amount); textBox1.Text = Define.Convert(MyCurrentEOS); }
private void btnOK_Click(object sender, EventArgs e) { string input = textBox1.Text; long v = Define.Convert(input); if (-1 == v) { Define.ErrorMessageBox("소수점은 8자리까지 입력할 수 있습니다."); return; } if (MyCurrentVEOS < v) { Define.ErrorMessageBox("보유한 VEOS 양보다 더 많은 값이 입력되었습니다."); return; } DB.Open(); DB.RunQuery($"UPDATE User SET VEOS = VEOS - {v} WHERE Id = {Define.MyUserId}"); int rowCount = 0; DB.RunReadQuery($"SELECT COUNT(*) FROM Vote WHERE UserId = {Define.MyUserId} AND NodeId = {SelectedNodeId}", r => { rowCount = r.GetInt32(0); }); if (0 == rowCount) { DB.RunQuery($"INSERT INTO Vote (UserId, NodeId, VEOS) VALUES ({Define.MyUserId}, {SelectedNodeId}, {v})"); } else { DB.RunQuery($"UPDATE Vote SET VEOS = VEOS + {v} WHERE UserId = {Define.MyUserId} AND NodeId = {SelectedNodeId}"); } DB.Close(); MessageBox.Show("투표되었습니다."); Close(); }
private void FormMain_Load(object sender, EventArgs e) { if (false == File.Exists(DB.SqliteFileName)) { var map = new Dictionary <string, bool>(); DB.Open(); DB.RunQuery( "CREATE TABLE Me (" + "Id INTEGER PRIMARY KEY," + "EOS INTEGER NOT NULL," + "VTIME DATETIME NOT NULL" + ")"); DB.RunQuery($"INSERT INTO Me (EOS, VTIME) VALUES ({Define.InitEOS * Define.SosuConvertValue}, '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}')"); DB.RunQuery( "CREATE TABLE User (" + "Id INTEGER PRIMARY KEY," + "Name TEXT NOT NULL," + "VEOS INTEGER NOT NULL" + ")"); DB.RunQuery($"INSERT INTO User (Id, Name, VEOS) VALUES ({Define.MyUserId}, '나자신', 0)"); map.Clear(); for (int i = 0; i < Define.AIUserCount;) { string name = Define.GetRandomName(); if (map.ContainsKey(name)) { continue; } map.Add(name, true); i++; DB.RunQuery($"INSERT INTO User (Id, Name, VEOS) VALUES ({100 + i}, '{name}', {Rn.Next(15000, 150000) * Define.SosuConvertValue})"); } DB.RunQuery( "CREATE TABLE Node (" + "Id INTEGER PRIMARY KEY," + "BP INTEGER NOT NULL," + "Name TEXT NOT NULL," + "Intro TEXT NOT NULL" + ")"); map.Clear(); for (int i = 0; i < Define.NodeCount;) { string name = Define.GetRandomName(); if (map.ContainsKey(name)) { continue; } map.Add(name, true); i++; DB.RunQuery($"INSERT INTO Node (Id, BP, Name, Intro) VALUES ({2000 + i}, 0, '{name}', '{name} 노드입니다. 잘 부탁드립니다.')"); } DB.RunQuery( "CREATE TABLE Vote (" + "UserId INTEGER NOT NULL," + "NodeId INTEGER NOT NULL," + "VEOS INTEGER NOT NULL" + ")"); DB.Close(); } RefreshTabPage(0); timer1.Start(); timer2.Start(); }
private void RefreshTabPage(int page) { switch (page) { case 0: // 개요 { long EOS = 0; long EOSing = 0; long VEOS = 0; long VEOSing = 0; var list = new List <EOSSplit>(); DB.Open(); DB.RunReadQuery("SELECT Id, EOS, VTIME FROM Me", (r) => { int id = r.GetInt32(0); long value = r.GetInt64(1); DateTime vtime = r.GetDateTime(2); if (DateTime.Now < vtime) { EOSing += value; list.Add(new EOSSplit() { Id = id, Amount = value, CompleteTime = vtime }); } else { EOS += value; } }); DB.RunReadQuery($"SELECT VEOS FROM Vote WHERE UserId = {Define.MyUserId}", (r) => { VEOSing += r.GetInt64(0); }); DB.RunReadQuery($"SELECT VEOS FROM User WHERE Id = {Define.MyUserId}", (r) => { VEOS = r.GetInt64(0); }); DB.Close(); lbEOS.Text = Define.Convert(EOS); lbEOSing.Text = Define.Convert(EOSing); lbVEOS.Text = Define.Convert(VEOS); lbVEOSing.Text = Define.Convert(VEOSing); lbTotal.Text = Define.Convert(EOS + EOSing + VEOS + VEOSing); lvEOSing.Items.Clear(); if (0 < list.Count) { label5.Visible = true; lvEOSing.Visible = true; foreach (var data in list) { var lvi = new ListViewItem(Define.Convert(data.Amount)); lvi.SubItems.Add(data.CompleteTime.ToString("yyyy-MM-dd HH:mm:ss")); lvi.Tag = data.Id; lvEOSing.Items.Add(lvi); } } else { label5.Visible = false; lvEOSing.Visible = false; } } break; case 3: // BP 투표 { var rankList = GetNodeRankList(); lvNodeList.Items.Clear(); int rank = 1; foreach (var node in rankList) { if (cbViewOnlyMyVoted.Checked && 0 == node.MyVote) { rank++; continue; } var lvi = new ListViewItem(rank.ToString()); lvi.SubItems.Add(node.Name); lvi.SubItems.Add(Define.Convert(node.Score)); lvi.SubItems.Add(Define.Convert(node.MyVote)); lvi.SubItems.Add(node.Intro); lvi.Tag = node.Id; if (node.BP) { lvi.BackColor = Color.Yellow; lvi.Font = new Font(lvi.Font, FontStyle.Bold); } lvNodeList.Items.Add(lvi); rank++; } } break; } }