From 086ec74e94654e92b3a1c6f42612d12ef33ff4b2 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 28 十月 2022 14:41:08 +0800 Subject: [PATCH] '优化自启动机制' --- app/codesDataDlog.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 56 insertions(+), 1 deletions(-) diff --git a/app/codesDataDlog.cpp b/app/codesDataDlog.cpp index 43ac6fd..c4cb55d 100644 --- a/app/codesDataDlog.cpp +++ b/app/codesDataDlog.cpp @@ -1,6 +1,8 @@ 锘�// codesDataDlog.cpp: 瀹炵幇鏂囦欢 // - +#include <iostream> +#include <string> +#include "StringUtils.h" #include "pch.h" #include "codesDataDlog.h" #include "afxdialogex.h" @@ -10,6 +12,7 @@ #include "app.h" #include "SocketManager.h" #include "JsonUtil.h" +#include "tool.h" @@ -38,6 +41,7 @@ DDX_Control(pDX, IDC_BUTTON1, uploadBtn); + DDX_Control(pDX, IDC_EDIT2, codesEdit); } BOOL codesDataDlog::OnInitDialog() @@ -99,10 +103,61 @@ // codesDataDlog 娑堟伅澶勭悊绋嬪簭 +std::string trim(const std::string source, const std::string chars) { + std::string other(source); + int start = other.find_first_of(chars); + int end = other.find_first_not_of(chars, start); + while (start > -1) { + other.erase(start, end - start); + start = other.find_first_of(chars); + end = other.find_first_not_of(chars, start); + } + return other; +} + void codesDataDlog::OnBnClickedButton1() { + if (codeData.size() == 0 ) { + CString text; + codesEdit.GetWindowTextW(text); + string datas = Tool::cstring2String( text); + //鍒嗛殧 + int p = 0; + do { + int start = p; + p = datas.find("\n", p + 1); + string temp = datas.substr(start, p - start); + if (temp.length() > 2) { + + int splitIndex = temp.find("\t"); + if (splitIndex < 0) { + splitIndex = temp.find(" "); + } + string zylt = trim(temp.substr(0, splitIndex),"\t\r\n "); + string code= trim( temp.substr(splitIndex, temp.length() - splitIndex),"\t\r\n "); + code = code.substr(2, code.length()-2); + + IndustryData data; + data.code = code; + + if (zylt.find("浜�",0) > 0) { + data.zyltMoneyUnit = MONEY_UNIT_Y; + data.zyltMoney = zylt.substr(0, zylt.length() - 2); + } + else if (zylt.find("涓�",0) > 0) { + data.zyltMoneyUnit = MONEY_UNIT_W; + data.zyltMoney = zylt.substr(0, zylt.length() - 2); + } + codeData.push_back(data); + } + if (p < 0) { + break; + } + } while (TRUE); + + } if (codeData.size() == 0) { AfxMessageBox(_T("娌℃湁鍙笂浼犵殑浠g爜")); return; -- Gitblit v1.8.0