⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dmobimod.pc

📁 小灵通机卡分离模块的设计.建立在数据库服务器
💻 PC
📖 第 1 页 / 共 5 页
字号:
		for(i=0;i<giaddc;i++)
		{
			gcretval = DinitpdnProc(gcmainproduct_id,gcoldproduce_id[i],gcoldproduce_no[i],"pdn_pdinfo",gitimes,gcdelflag,gcnewflag,gcoldsrv_code[i]);
			if (gcretval == -1)
			{
				strcpy(gcretstr,"初始化pdn_pdinfo出错");
				return -1;
			}
			#ifdef	YYDEBUG
			DebugLog("初始化pdn_pdinfo2");
			#endif
		}
	}

	if (gia0e == -1)
	{
		return 0;
	}

	for(i=0;i<PDINFO_FIELD;i++)
	{
		lcfielda0[i][0]=0;
		lcchna0[i][0]=0;
		lctypea0[i][0]=0;
		lcnewa0[i][0]=0;
		lcolda0[i][0]=0;
	}

	/*预先从dc_sysfields中取出字段和类型,保存在lcfielda0和lctypea0中*/
	EXEC SQL SELECT field_code,field_type INTO :lcfielda0,:lctypea0 FROM dc_sysfields WHERE table_code = 'pdn_pdinfo' ORDER BY fld_id;
	if (sqlca.sqlcode < 0)
	{
		strcpy(gcretstr,"检索dc_sysfields出错");
		return -1;
	}
	#ifdef	YYDEBUG
	DebugLog("get dc_sysfields");
	#endif

	for(i=0;i<PDINFO_FIELD;i++)
	{
		trim(lcfielda0[i]);
		trim(lctypea0[i]);
	}

	for(i=gia0s;i<=gia0e;i++)
	{
		ncpyRec(i,1,lcsub,3);
		lisub=atoi(lcsub);
		ncpyRec(i,3,lcchna0[lisub],40);
		trim(lcchna0[lisub]);
		ncpyRec(i,7,lcnewa0[lisub],PDINFO_LENGTH);
		trim(lcnewa0[lisub]);
		ncpyRec(i,8,lcolda0[lisub],PDINFO_LENGTH);
		trim(lcolda0[lisub]);
	}

	/*保存生产编号、生产类型到数组*/
	strcpy(lcolda0[0],gcmainproduce_id);
	strcpy(lcnewa0[0],gcmainproduce_id);
	strcpy(lcchna0[0],"生产编号");

	strcpy(lcolda0[1],"1");
	strcpy(lcnewa0[1],"1");
	strcpy(lcchna0[1],"生产类型");

	/*拼装SQL语句开始*/
	strcpy(lcupdate,"UPDATE pdn_pdinfo SET ");
	for (i=0;i<PDINFO_FIELD;i++)
	{
		if (lcchna0[i][0] != 0)
		{
			if (strcmp(lctypea0[i],"date") != 0)
			{
				strcat(lcupdate,lcfielda0[i]);
				strcat(lcupdate," = '");
				strcat(lcupdate,lcnewa0[i]);
				strcat(lcupdate,"',");
			}
			else
			{
				strcat(lcupdate,lcfielda0[i]);
				strcat(lcupdate," = to_date('");
				strcat(lcupdate,lcnewa0[i]);
				strcat(lcupdate,"','YYYY-MM-DD HH24:MI:SS'),");
			}
			if (i < 10)
			{
				sprintf(gcfieldstr,"%s%c%d%c","A0",'0',i,'/');
			}
			else
			{
				sprintf(gcfieldstr,"%s%d%c","A0",i,'/');
			}
			if ((i != 0) && (i != 1))								/*非主键字段*/
			{
				#ifdef	YYDEBUG
				DebugLog("pdn_pdinfo 开始judge,i=%d",i);
				#endif
				gcretval=judge_srvcodeProc("pdn_pdinfo","A0",lcfielda0[i],lcchna0[i],lcnewa0[i],lcolda0[i],lctypea0[i],i,gcfieldstr,1,"M");
				#ifdef	YYDEBUG
				DebugLog("pdn_pdinfo 完成judge,i=%d",i);
				#endif
				if (gcretval != 0)
				{
					return -1;
				}
			}
		}
	}
	lcupdate[strlen(lcupdate) - 1] = 0;
	strcat(lcupdate," WHERE produce_id = '");
	strcat(lcupdate,gcmainproduce_id);
	strcat(lcupdate,"' AND produce_type = 1");

	/*拼装SQL语句结束*/
	EXEC SQL EXECUTE IMMEDIATE :lcupdate;
	#ifdef	YYDEBUG
	DebugLog("lcupdate=%s",lcupdate);
	#endif
	if (sqlca.sqlcode < 0)
	{
		#ifdef	YYDEBUG
		DebugLog("lcupdate=%s",lcupdate);
		#endif
		strcpy(gcretstr,"修改pdn_pdinfo出错");
		return -1;
	}
	/*对每一张工单的信息变动表,写主键记录*/
	sprintf(lctempstr,"%s%d","A0",1);
	for(i=0;i<gisrvc;i++)
	{
		#ifdef	YYDEBUG
		DebugLog("start insert primarykey, lctempstr=%s",lctempstr);
		DebugLog("gcnewchantypestr=%s",gcnewchantypestr[i]);
		#endif
		if (strstr(gcnewchantypestr[i],lctempstr) != NULL)
		{
			EXEC SQL INSERT INTO pdn_fieldchang(produce_id,produce_no,table_name,field_name,field_memo,record_id,product_id,field_type,new_value,old_value,srv_code,fld_id)
			VALUES(:gcnewproduce_id[i],:gcnewproduce_no[i],'pdn_pdinfo',:lcfielda0[0],:lcchna0[0],1,:gcmainproduct_id,:lctypea0[0],:lcnewa0[0],:lcolda0[0],:gcnewsrv_code[i],0);
			if (sqlca.sqlcode < 0)
			{
				strcpy(gcretstr,"插入pdn_fieldchang出错");
				return -1;
			}
			EXEC SQL INSERT INTO pdn_fieldchang(produce_id,produce_no,table_name,field_name,field_memo,record_id,product_id,field_type,new_value,old_value,srv_code,fld_id)
			VALUES(:gcnewproduce_id[i],:gcnewproduce_no[i],'pdn_pdinfo',:lcfielda0[1],:lcchna0[1],1,:gcmainproduct_id,:lctypea0[1],:lcnewa0[1],:lcolda0[1],:gcnewsrv_code[i],1);
			if (sqlca.sqlcode < 0)
			{
				strcpy(gcretstr,"插入pdn_fieldchang出错");
				return -1;
			}
		}
	}

	return 0;
}


/*
* 函数说明:生成cn_cust_info信息
* 输入参数:
* 输出参数:
* 返 回 值:
*/

int intoCn_cust_infoProc()

{
	EXEC SQL BEGIN DECLARE SECTION;
	char lcnewe7[44][260] = {0};
	char lcolde7[44][260] = {0};
	char lcfielde7[44][20] = {0};
	char lcchne7[44][40] = {0};
	char lctypee7[44][10] = {0};
	char lcupdate[2000] = {0};
	char lcsrowid[5] = {0};
	char lccrowid[5] = {0};
	char lcstype[5] = {0};
	char lcctype[5] = {0};
	char lcsub[3] = {0};
	int  lisub=0;
	int  i=0;
	int  j=0;
	int  k=0;
	char lctempstr[10] = {0};

	EXEC SQL END DECLARE SECTION;

	/*初始化cn_cust_info*/
	if ((gitimes == 0) || (gitimes == 1) || (gitimes == 4))
	{
		if (girolls == 0)
		{
			gcretval = DinitpdnProc(gcmainproduct_id,gcmainproduce_id,gcrollproduce_no[0],"cn_cust_info",gitimes,gcdelflag,gcnewflag,gcrollsrv_code[0]);
			if (gcretval == -1)
			{
				strcpy(gcretstr,"初始化cn_cust_info出错");
				return -1;
			}
		}
		else
		{
			for(i=0;i<girolls;i++)
			{
				if (gcrollproduce_no[i][0] != 0)
				{
					gcretval = DinitpdnProc(gcmainproduct_id,gcmainproduce_id,gcrollproduce_no[i],"cn_cust_info",gitimes,gcdelflag,gcnewflag,gcrollsrv_code[i]);
					if (gcretval == -1)
					{
						strcpy(gcretstr,"初始化cn_cust_info出错");
						return -1;
					}
				}
			}
		}
	}
	else if (gitimes == 2)
	{
		for(i=0;i<giaddc;i++)
		{
			gcretval = DinitpdnProc(gcmainproduct_id,gcoldproduce_id[i],gcoldproduce_no[i],"cn_cust_info",gitimes,gcdelflag,gcnewflag,gcoldsrv_code[i]);
			if (gcretval == -1)
			{
				strcpy(gcretstr,"初始化cn_cust_info出错");
				return -1;
			}
		}
	}

	if (gie7e == -1)
	{
		return 0;
	}

	for(k=0;k<44;k++)
	{
		lcfielde7[k][0]=0;
		lcchne7[k][0]=0;
		lctypee7[k][0]=0;
		lcnewe7[k][0]=0;
		lcolde7[k][0]=0;
	}

	/*预先从dc_sysfields中取出字段和类型,保存在lcfielde7和lctypee7中*/
	EXEC SQL SELECT field_code,field_type INTO :lcfielde7,:lctypee7 FROM dc_sysfields WHERE table_code = 'cn_cust_info' ORDER BY fld_id;
	if (sqlca.sqlcode < 0)
	{
		strcpy(gcretstr,"检索dc_sysfields出错");
		return -1;
	}
	for(j=0;j<44;j++)
	{
		trim(lcfielde7[j]);
		trim(lctypee7[j]);
	}

	ncpyRec(gie7s,5,lcstype,5);
	trim(lcstype);
	ncpyRec(gie7s,6,lcsrowid,5);
	trim(lcsrowid);
	for(j=gie7s;j<=gie7e;j++)
	{
		ncpyRec(j,1,lcsub,3);
		lisub=atoi(lcsub);
		ncpyRec(j,5,lcctype,5);
		trim(lcctype);
		ncpyRec(j,6,lccrowid,5);
		trim(lccrowid);

		if ((strcmp(lcsrowid,lccrowid) == 0) && (j != gie7e))
		{
			ncpyRec(j,3,lcchne7[lisub],40);
			trim(lcchne7[lisub]);
			ncpyRec(j,7,lcnewe7[lisub],260);
			trim(lcnewe7[lisub]);
			ncpyRec(j,8,lcolde7[lisub],260);
			trim(lcolde7[lisub]);
		}
		else                          /*不同记录序号或者到最后一条记录处理开始*/
		{
			if (j == gie7e)
			{
				ncpyRec(j,3,lcchne7[lisub],40);
				trim(lcchne7[lisub]);
				ncpyRec(j,7,lcnewe7[lisub],260);
				trim(lcnewe7[lisub]);
				ncpyRec(j,8,lcolde7[lisub],260);
				trim(lcolde7[lisub]);
			}
			/*保存生产编号、生产类型到数组*/

			strcpy(lcolde7[0],gcmainproduce_id);
			strcpy(lcnewe7[0],gcmainproduce_id);
			strcpy(lcchne7[0],"生产编号");

			strcpy(lcolde7[1],"1");
			strcpy(lcnewe7[1],"1");
			strcpy(lcchne7[1],"生产类型");

			/*拼装SQL语句开始*/
			strcpy(lcupdate,"UPDATE cn_cust_info SET ");
			for (k=0;k<44;k++)
			{
				if (lcchne7[k][0] != 0)
				{
					if (strcmp(lctypee7[k],"date") != 0)
					{
						strcat(lcupdate,lcfielde7[k]);
						strcat(lcupdate," = '");
						strcat(lcupdate,lcnewe7[k]);
						strcat(lcupdate,"',");
					}
					else
					{
						strcat(lcupdate,lcfielde7[k]);
						strcat(lcupdate," = to_date('");
						strcat(lcupdate,lcnewe7[k]);
						strcat(lcupdate,"','YYYY-MM-DD HH24:MI:SS'),");
					}
					if (k < 10)
					{
						sprintf(gcfieldstr,"%s%c%d%c","E7",'0',k,'/');
					}
					else
					{
						sprintf(gcfieldstr,"%s%d%c","E7",k,'/');
					}
					if ((k != 0) && (k != 1) &&(k != 2))								/*非主键字段*/
					{
						#ifdef	YYDEBUG
						DebugLog("cn_cust_info 开始judge,k=%d",k);
						#endif
						gcretval=judge_srvcodeProc("cn_cust_info","E7",lcfielde7[k],lcchne7[k],lcnewe7[k],lcolde7[k],lctypee7[k],k,gcfieldstr,atoi(lcsrowid),lcstype);
						#ifdef	YYDEBUG
						DebugLog("cn_cust_info 完成judge,k=%d",k);
						#endif
						if (gcretval != 0)
						{
							return -1;
						}
					}
				}
			}
			lcupdate[strlen(lcupdate) - 1] = 0;
			strcat(lcupdate," WHERE produce_id = '");
			strcat(lcupdate,gcmainproduce_id);
			strcat(lcupdate,"' AND produce_type = 1");
			strcat(lcupdate," AND cust_id = '");
			strcat(lcupdate,lcnewe7[2]);
			strcat(lcupdate,"'");

			/*拼装SQL语句结束*/
			EXEC SQL EXECUTE IMMEDIATE :lcupdate;
			#ifdef	YYDEBUG
			DebugLog("cn_cust_info,lcupdate=%s",lcupdate);
			#endif
			if (sqlca.sqlcode < 0)
			{
				#ifdef	YYDEBUG
				DebugLog("gitimes=0,lcupdate=%s",lcupdate);
				#endif
				strcpy(gcretstr,"修改cn_cust_info出错");
				return -1;
			}

			/*对每一张工单的信息变动表,写主键记录*/
			sprintf(lctempstr,"%s%s","E7",lcsrowid);
			for(i=0;i<gisrvc;i++)
			{
				#ifdef	YYDEBUG
				DebugLog("start insert primarykey, lctempstr=%s",lctempstr);
				DebugLog("gcnewchantypestr=%s",gcnewchantypestr[i]);
				#endif
				if (strstr(gcnewchantypestr[i],lctempstr) != NULL)
				{
					EXEC SQL INSERT INTO pdn_fieldchang(produce_id,produce_no,table_name,field_name,field_memo,record_id,product_id,field_type,new_value,old_value,srv_code,fld_id)
					VALUES(:gcnewproduce_id[i],:gcnewproduce_no[i],'cn_cust_info',:lcfielde7[0],:lcchne7[0],:lcsrowid,:gcmainproduct_id,:lctypee7[0],:lcnewe7[0],:lcolde7[0],:gcnewsrv_code[i],0);
					if (sqlca.sqlcode < 0)
					{
						strcpy(gcretstr,"插入pdn_fieldchang出错");
						return -1;
					}
					EXEC SQL INSERT INTO pdn_fieldchang(produce_id,produce_no,table_name,field_name,field_memo,record_id,product_id,field_type,new_value,old_value,srv_code,fld_id)
					VALUES(:gcnewproduce_id[i],:gcnewproduce_no[i],'cn_cust_info',:lcfielde7[1],:lcchne7[1],:lcsrowid,:gcmainproduct_id,:lctypee7[1],:lcnewe7[1],:lcolde7[1],:gcnewsrv_code[i],1);
					if (sqlca.sqlcode < 0)
					{
						strcpy(gcretstr,"插入pdn_fieldchang出错");
						return -1;
					}
					EXEC SQL INSERT INTO pdn_fieldchang(produce_id,produce_no,table_name,field_name,field_memo,record_id,product_id,field_type,new_value,old_value,srv_code,fld_id)
					VALUES(:gcnewproduce_id[i],:gcnewproduce_no[i],'cn_cust_info',:lcfielde7[2],:lcchne7[2],:lcsrowid,:gcmainproduct_id,:lctypee7[2],:lcnewe7[2],:lcolde7[2],:gcnewsrv_code[i],2);
					if (sqlca.sqlcode < 0)
					{
						strcpy(gcretstr,"插入pdn_fieldchang出错");
						return -1;
					}
				}
			}


			strcpy(lcsrowid,lccrowid);
			strcpy(lcstype,lcctype);
			for(k=0;k<44;k++)
			{
				lcchne7[k][0]=0;
				lcnewe7[k][0]=0;
				lcolde7[k][0]=0;
			}

			ncpyRec(j,3,lcchne7[lisub],40);
			trim(lcchne7[lisub]);
			ncpyRec(j,7,lcnewe7[lisub],260);
			trim(lcnewe7[lisub]);
			ncpyRec(j,8,lcolde7[lisub],260);
			trim(lcolde7[lisub]);
		}				/*不同记录序号或者到最后一条记录处理结束*/
	}                          /*for循环结束*/
	return 0;
}

/*
* 函数说明:生成pdn_phone信息
* 输入参数:
* 输出参数:
* 返 回 值:
*/

int intoPdn_phoneProc()

{
	EXEC SQL BEGIN DECLARE SECTION;
	char lcnewa1[PHONE_FIELD][PHONE_LENGTH] = {0};
	char lcolda1[PHONE_FIELD][PHONE_LENGTH] = {0};
	char lcfielda1[PHONE_FIELD][20] = {0};
	char lcchna1[PHONE_FIELD][40] = {0};
	char lctypea1[PHONE_FIELD][10] = {0};
	char lcinsert[2000] = {0};
	char lcvalues[2000] = {0};
	char lcupdate[2000] = {0};
	char lcwhere[2000] = {0};
	char lcdelete[2000] = {0};
	char lcsql[2000] = {0};
	char lcsrowid[5] = {0};
	char lccrowid[5] = {0};
	char lcstype[5] = {0};
	char lcctype[5] = {0};
	char lcsub[3] = {0};
	char lcproduct_no[20] = {0};
	int  liprodno_grade=0;
	int  lisub=0;
	int  i=0;
	int  j=0;
	int  k=0;
	char lctempstr[10] = {0};

	EXEC SQL END DECLARE SECTION;

	/*初始化pdn_phone*/
	if ((gitimes == 0) || (gitimes == 1) || (gitimes == 4))
	{
		if (girolls == 0)
		{
			gcretval = DinitpdnProc(gcmainproduct_id,gcmainproduce_id,gcrollproduce_no[0],"pdn_phone",gitimes,gcdelflag,gcnewflag,gcrollsrv_code[0]);
			if (gcretval == -1)
			{
				strcpy(gcretstr,"初始化pdn_phone出错");
				return -1;
			}
		}
		else
		{
			for(i=0;i<girolls;i++)
			{
				if (gcrollproduce_no[i][0] != 0)
				{
					gcretval = DinitpdnProc(gcmainproduct_id,gcmainproduce_id,gcrollproduce_no[i],"pdn_phone",gitimes,gcdelflag,gcnewflag,gcrollsrv_code[i]);
					if (gcretval == -1)
					{
						strcpy(gcretstr,"初始化pdn_phone出错");
						return -1;
					}
				}
			}
		}
	}
	else if (gitimes == 2)
	{
		for(i=0;i<giaddc;i++)
		{
			gcretval = DinitpdnProc(gcmainproduct_id,gcoldproduce_id[i],gcoldproduce_no[i],"pdn_phone",gitimes,gcdelflag,gcnewflag,gcoldsrv_code[i]);
			if (gcretval == -1)
			{
				strcpy(gcretstr,"初始化pdn_phone出错");
				return -1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -