You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

155 lines
4.5 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include "epm_handler_common.h"
#include <tccore\aom_prop.h>
#include <tccore\aom.h>
#include <epm\epm.h>
#include <objbase.h>
#include <tc\preferences.h>
#import "C:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename("EOF","adoEOF")rename("BOF","adoBOF")
#define DOFREE(obj) \
{ \
if(obj) \
{ \
MEM_free(obj); \
obj = NULL; \
} \
}
//分割字符串函数
void split_img2(char* src, const char* separator, char** dest, int* num) {
/*
src 源字符串的首地址(buf的地址)
separator 指定的分割字符
dest 接收子字符串的数组
num 分割后子字符串的个数
*/
char* pNext;
int count = 0;
if (src == NULL || strlen(src) == 0) //如果传入的地址为空或长度为0直接终止
return;
if (separator == NULL || strlen(separator) == 0) //如未指定分割的字符串,直接终止
return;
pNext = (char*)strtok(src, separator); //必须使用(char *)进行强制类型转换(虽然不写有的编译器中不会出现指针错误)
while (pNext != NULL) {
*dest++ = pNext;
++count;
pNext = (char*)strtok(NULL, separator); //必须使用(char *)进行强制类型转换
}
*num = count;
}
int JL_form_save(METHOD_message_t *msg, va_list args){
//表单属性修改保存后同步修改超级BOM的状态
printf("开始判断是否要修改超级BOM\n");
tag_t formTag = NULLTAG;
tag_t revTag = NULLTAG;
char *item_id;
//获取属性对象
tag_t prop_tag = va_arg(args, tag_t);
//获取值
char * values = va_arg(args, char*);
printf_s("修改的值:%s\n",values);
ITKCALL(PROP_ask_owning_object(prop_tag, &formTag));
printf_s("foem:%d\n",formTag);
ITKCALL(AOM_ask_value_tag(formTag,"item_revision",&revTag));
printf_s("rev:%d\n",revTag);
ITKCALL(AOM_ask_value_string(revTag,"item_id",&item_id));
printf_s("id:%s\n",item_id);
//修改数据库
::CoInitialize(NULL); //初始化OLE/COM库环境
HRESULT hr = NULL;
_ConnectionPtr m_pConnection; // 数据库
_RecordsetPtr m_pRecordset; // 命令
_CommandPtr m_pCommand; // 记录
char* server_address;
int valueNum=0;
PREF_ask_char_value("TC11_SqlServer_Link_ITK", valueNum, &server_address);
hr = m_pConnection.CreateInstance(_uuidof(Connection));//创建连接对象实例
if (SUCCEEDED(hr))
{
/*
Provider=SQLOLEDB.1 ------打开数据库用oledb的方式连接bai
Persist Security Info ----是否保存安全信息du
User ID-------------------用户名
PassWord------------------密码zhi
Initial Catalog-----------数据库的名称或者数据库ip或者目dao录
Data Source---------------数据源
*/
m_pConnection->ConnectionString = (server_address);
//printf("\n==========================================================\n");
hr = m_pConnection->Open("", "", "", adConnectUnspecified);//打开数据库
if (FAILED(hr))
{
printf("Open Failed!");
return 1;
}
else
{
//char* updateLable = (char*)calloc(1024, sizeof(char));
//sprintf(updateLable, "update GD_ORDERBOM_LABLE set Lable = '更新中' where ItemID = '%s'", "50HS502");
//m_pConnection->Execute(_bstr_t(updateLable), 0, adCmdText);
//updateLable = NULL;
//printf("更新成功");
char * sjzl = "";
char * mz = "";
char * wlfl = "";
char * dw = "";
char * jcjwlh = "";
char * sfqdj = "";
char * gyzy = "";
AOM_ask_value_string(formTag, "gd6_sjzl", &sjzl);
AOM_ask_value_string(formTag, "gd6_mz", &mz);
AOM_ask_value_string(formTag, "gd6_wlfl", &wlfl);
AOM_ask_value_string(formTag, "gd6_dw", &dw);
AOM_ask_value_string(formTag, "gd6_jcjwlh", &jcjwlh);
AOM_ask_value_string(formTag, "gd6_sfqdj", &sfqdj);
AOM_ask_value_string(formTag, "gd6_gyzy", &gyzy);
char* updateSql = (char*)calloc(1024, sizeof(char));
sprintf(updateSql, "UPDATE GD_ORDERBOM_DATA SET sjzl = '%s',mz = '%s',wlfl='%s',dw='%s',jcjwlh='%s',sfqdj='%s',gyzy='%s' where id = '%s'",sjzl,mz,wlfl,dw,jcjwlh,sfqdj,gyzy,item_id);
printf("%s",updateSql);
m_pConnection->Execute(_bstr_t(updateSql), 0, adCmdText);
DOFREE(sjzl);
DOFREE(mz);
DOFREE(wlfl);
DOFREE(dw);
DOFREE(jcjwlh);
DOFREE(sfqdj);
DOFREE(gyzy);
//sjzl = NULL;
//mz = NULL;
//wlfl = NULL;
//dw = NULL;
//jcjwlh = NULL;
//sfqdj = NULL;
//gyzy = NULL;
updateSql = NULL;
}
}
else
{
printf("Create instance of connection failed!");
return 1;
}
DOFREE(server_address);
DOFREE(item_id);
//int self_num = 0;
//char* revbuf_test[8] = { }; //存放分割后的子字符串
//split_img2(object_name,"/", revbuf_test, &self_num);
//char self_new_name[WSO_name_size_c + 1] = "";
//strcat(self_new_name,revbuf_test[0]);
//printf("id号为%s",self_new_name);
printf("=========================修改超级BOM END ===================\n");
return 0;
}