自己写了一个脚本,以生产计算单为例,先按正常操作输入主产品信息及数量,明细区域会自动生成需要的下级物资数量,脚本在保存前执行。脚本相对生疏,朋友们可以帮忙修正一下。脚本如下: int func_before_save() { string id,sql,a; int i,n,i1,n1; num b,c; grid_seek("MG_Item","res_id",''); n=grid_cur_row("MG_Item"); for(i=1;i<n;i++){ id=grid_get_v("MG_Item","res_id",i); b=grid_get_v("MG_Item","inp_num",i); sql="select sub_res_id, num from res_composing where res_id='"+id+"'"; db_run(sql); n1=db_row_count(); if(n1>0){ for(i1=0;i1<n1;i1++){ a=db_cell(0,i1); c=db_cell(1,i1); vr_add_res(a,b*c) }; grid_del_row("MG_Item",i); i=i-1; n=n+n1-1; }; }; //can_save=1; return 1; }; |