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

📄 dmobimod.pc

📁 小灵通机卡分离模块的设计.建立在数据库服务器
💻 PC
📖 第 1 页 / 共 5 页
字号:
				strcat(lcwhere," AND prod_class = '");
				strcat(lcwhere,lcoldg0[3]);
				strcat(lcwhere,"'");
				strcat(lcdelete,lcwhere);
				strcpy(lcsql,lcdelete);
			}
			else if (lcstype[0] == 'A')
			{
				lcinsert[strlen(lcinsert) - 1] = 0;
				strcat(lcinsert,")");
				lcvalues[strlen(lcvalues) - 1] = 0;
				strcat(lcvalues,")");
				strcat(lcinsert,lcvalues);
				strcpy(lcsql,lcinsert);
			}
			else if (lcstype[0] == 'M')
			{
				strcpy(lcwhere," WHERE produce_id = '");
				strcat(lcwhere,gcmainproduce_id);
				strcat(lcwhere,"' AND produce_type = 1");
				strcat(lcwhere," AND prod_class = '");
				strcat(lcwhere,lcoldg0[3]);
				strcat(lcwhere,"'");
				lcupdate[strlen(lcupdate) - 1] = 0;
				strcat(lcupdate,lcwhere);
				strcpy(lcsql,lcupdate);
			}

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

			/*对每一张工单的信息变动表,写主键记录*/
			sprintf(lctempstr,"%s%s","G0",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],'pdn_incr_prod',:lcfieldg0[0],:lcchng0[0],:lcsrowid,:gcmainproduct_id,:lctypeg0[0],:lcnewg0[0],:lcoldg0[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_incr_prod',:lcfieldg0[1],:lcchng0[1],:lcsrowid,:gcmainproduct_id,:lctypeg0[1],:lcnewg0[1],:lcoldg0[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],'pdn_incr_prod',:lcfieldg0[3],:lcchng0[3],:lcsrowid,:gcmainproduct_id,:lctypeg0[3],:lcnewg0[3],:lcoldg0[3],:gcnewsrv_code[i],3);
					if (sqlca.sqlcode < 0)
					{
						strcpy(gcretstr,"插入pdn_fieldchang出错");
						return -1;
					}
				}
			}


			strcpy(lcsrowid,lccrowid);
			strcpy(lcstype,lcctype);
			for(k=0;k<6;k++)
			{
				lcchng0[k][0]=0;
				lcnewg0[k][0]=0;
				lcoldg0[k][0]=0;
			}

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


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

int intoPdn_prod_propProc()

{
	EXEC SQL BEGIN DECLARE SECTION;
	char lcnewg1[6][102] = {0};
	char lcoldg1[6][102] = {0};
	char lcfieldg1[6][20] = {0};
	char lcchng1[6][40] = {0};
	char lctypeg1[6][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 lcphone_id[26] = {0};
	int  lisub=0;
	int  i=0;
	int  j=0;
	int  k=0;
	char lctempstr[10] = {0};

	EXEC SQL END DECLARE SECTION;

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


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

	for(k=0;k<6;k++)
	{
		lcfieldg1[k][0]=0;
		lcchng1[k][0]=0;
		lctypeg1[k][0]=0;
		lcnewg1[k][0]=0;
		lcoldg1[k][0]=0;
	}

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

	ncpyRec(gig1s,5,lcstype,5);
	trim(lcstype);
	ncpyRec(gig1s,6,lcsrowid,5);
	trim(lcsrowid);
	for(j=gig1s;j<=gig1e;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 != gig1e))
		{
			ncpyRec(j,3,lcchng1[lisub],40);
			trim(lcchng1[lisub]);
			ncpyRec(j,7,lcnewg1[lisub],102);
			trim(lcnewg1[lisub]);
			ncpyRec(j,8,lcoldg1[lisub],102);
			trim(lcoldg1[lisub]);
		}
		else                          /*不同记录序号或者到最后一条记录处理开始*/
		{
			if (j == gig1e)
			{
				ncpyRec(j,3,lcchng1[lisub],40);
				trim(lcchng1[lisub]);
				ncpyRec(j,7,lcnewg1[lisub],102);
				trim(lcnewg1[lisub]);
				ncpyRec(j,8,lcoldg1[lisub],102);
				trim(lcoldg1[lisub]);
			}

			/*保存生产编号、生产类型到数组*/

			strcpy(lcoldg1[0],gcmainproduce_id);
			strcpy(lcnewg1[0],gcmainproduce_id);
			strcpy(lcchng1[0],"生产编号");

			strcpy(lcoldg1[1],"1");
			strcpy(lcnewg1[1],"1");
			strcpy(lcchng1[1],"生产类型");

			/*拼装SQL语句开始*/
			if (lcstype[0] == 'D')        /*删除*/
			{
				strcpy(lcdelete,"DELETE FROM pdn_prod_prop");
			}
			else if (lcstype[0] == 'A')        /*增加*/
			{
				strcpy(lcinsert,"INSERT INTO pdn_prod_prop(");
				strcpy(lcvalues," VALUES(");
			}
			else if (lcstype[0] == 'M')				/*修改*/
			{
				strcpy(lcupdate,"UPDATE pdn_prod_prop SET ");
			}
			for(i=0;i<6;i++)
			{
				/*拼装SQL语句处理*/
				if (lcchng1[i][0] != 0)
				{
					if (lcstype[0] == 'D')
					{
					}
					else if (lcstype[0] == 'A')
					{
						if ((strcmp(lctypeg1[i],"date") != 0)&&(lcchng1[i][0] != 0))
						{
							strcat(lcinsert,lcfieldg1[i]);
							strcat(lcinsert,",");
							strcat(lcvalues,"'");
							strcat(lcvalues,lcnewg1[i]);
							strcat(lcvalues,"',");
						}
						else if (strcmp(lctypeg1[i],"date") == 0)
						{
							strcat(lcinsert,lcfieldg1[i]);
							strcat(lcinsert,",");
							strcat(lcvalues,"to_date('");
							strcat(lcvalues,lcnewg1[i]);
							strcat(lcvalues,"','YYYY-MM-DD HH24:MI:SS'),");
						}
					}
					else if (lcstype[0] == 'M')
					{
						if ((strcmp(lctypeg1[i],"date") != 0)&&(lcchng1[i][0] != 0))
						{
							strcat(lcupdate,lcfieldg1[i]);
							strcat(lcupdate," = '");
							strcat(lcupdate,lcnewg1[i]);
							strcat(lcupdate,"',");
						}
						else if (strcmp(lctypeg1[i],"date") == 0)
						{
							strcat(lcupdate,lcfieldg1[i]);
							strcat(lcupdate," = to_date('");
							strcat(lcupdate,lcnewg1[i]);
							strcat(lcupdate,"','YYYY-MM-DD HH24:MI:SS'),");
						}
					}
					if (i < 10)
					{
						sprintf(gcfieldstr,"%s%c%d%c","G1",'0',i,'/');
					}
					else
					{
						sprintf(gcfieldstr,"%s%d%c","G1",i,'/');
					}
					if ((i != 0) && (i != 1) && (i != 3) && (i != 4))
					{
						#ifdef	YYDEBUG
						DebugLog("pdn_prod_prop 开始judge,i=%d",i);
						#endif
						gcretval=judge_srvcodeProc("pdn_prod_prop","G1",lcfieldg1[i],lcchng1[i],lcnewg1[i],lcoldg1[i],lctypeg1[i],i,gcfieldstr,atoi(lcsrowid),lcstype);
						#ifdef	YYDEBUG
						DebugLog("pdn_prod_prop 完成judge,i=%d",i);
						#endif
						if (gcretval != 0)
						{
							return -1;
						}
					}
				}
			}							/*fielchang的for循环结束*/

			if (lcstype[0] == 'D')
			{
				strcpy(lcwhere," WHERE produce_id = '");
				strcat(lcwhere,gcmainproduce_id);
				strcat(lcwhere,"' AND produce_type = 1");
				strcat(lcwhere," AND prod_class = '");
				strcat(lcwhere,lcoldg1[3]);
				strcat(lcwhere,"' AND item_code = '");
				strcat(lcwhere,lcoldg1[4]);
				strcat(lcwhere,"'");
				strcat(lcdelete,lcwhere);
				strcpy(lcsql,lcdelete);
			}
			else if (lcstype[0] == 'A')
			{
				lcinsert[strlen(lcinsert) - 1] = 0;
				strcat(lcinsert,")");
				lcvalues[strlen(lcvalues) - 1] = 0;
				strcat(lcvalues,")");
				strcat(lcinsert,lcvalues);
				strcpy(lcsql,lcinsert);
			}
			else if (lcstype[0] == 'M')
			{
				strcpy(lcwhere," WHERE produce_id = '");
				strcat(lcwhere,gcmainproduce_id);
				strcat(lcwhere,"' AND produce_type = 1");
				strcat(lcwhere," AND prod_class = '");
				strcat(lcwhere,lcoldg1[3]);
				strcat(lcwhere,"' AND item_code = '");
				strcat(lcwhere,lcoldg1[4]);
				strcat(lcwhere,"'");
				lcupdate[strlen(lcupdate) - 1] = 0;
				strcat(lcupdate,lcwhere);
				strcpy(lcsql,lcupdate);
			}

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

			/*对每一张工单的信息变动表,写主键记录*/
			sprintf(lctempstr,"%s%s","G1",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],'pdn_prod_prop',:lcfieldg1[0],:lcchng1[0],:lcsrowid,:gcmainproduct_id,:lctypeg1[0],:lcnewg1[0],:lcoldg1[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_prod_prop',:lcfieldg1[1],:lcchng1[1],:lcsrowid,:gcmainproduct_id,:lctypeg1[1],:lcnewg1[1],:lcoldg1[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],'pdn_prod_prop',:lcfieldg1[3],:lcchng1[3],:lcsrowid,:gcmainproduct_id,:lctypeg1[3],:lcnewg1[3],:lcoldg1[3],:gcnewsrv_code[i],3);
					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_prod_prop',:lcfieldg1[4],:lcchng1[4],:lcsrowid,:gcmainproduct_id,:lctypeg1[4],:lcnewg1[4],:lcoldg1[4],:gcnewsrv_code[i],4);
					if (sqlca.sqlcode < 0)
					{
						strcpy(gcretstr,"插入pdn_fieldchang出错");
						return -1;
					}
				}
			}


			strcpy(lcsrowid,lccrowid);
			strcpy(lcstype,lcctype);
			for(k=0;k<6;k++)
			{
				lcchng1[k][0]=0;
				lcnewg1[k][0]=0;
				lcoldg1[k][0]=0;
			}

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


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

int intoPdn_deviceProc()

{
	EXEC SQL BEGIN DECLARE SECTION;
	char lcnewa5[8][60] = {0};
	char lcolda5[8][60] = {0};
	char lcfielda5[8][20] = {0};
	char lcchna5[8][40] = {0};
	char lctypea5[8][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};
	int  lisub=0;
	int  i=0;
	int  j=0;
	int  k=0;
	char lctempstr[10] = {0};

	EXEC SQL END DECLARE SECTION;

	/*初始化pdn_device*/
	if ((gitimes == 0) || (gitimes == 1) || (gitimes == 4))
	{
		if (girolls == 0)
		{
			gcretval = DinitpdnProc(gcmainproduct_id,gcmainproduce_id,gcrollproduce_no[0],"pdn_device",gitimes,gcdelflag,gcnewflag,gcrollsrv_code[0]);
			if (gcretval == -1)
			{
				strcpy(gcretstr,"初始化pdn_device出错");
				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_device",git

⌨️ 快捷键说明

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