更详细的来了。 如果支持attr扩展,则不需要二次保存,二次加载 1、建立一个产品编号,按颜色。 2、建立码段及码数字典 3、使用扩展字段,动态显示码数 4、保存后再次脚本保存码数 5、显示时,再次加载脚本保存的码数 好处: 1、可以少建产品 2、在BOM里可以少建BOM 3、在采购里可以更简洁的,原先要一码一颜色,如果20个码,则要20行,现在则需要1行。 extern change_obj; int csm() { string sql, md; md = gui_get_val("ext_Ext1"); int a, b; for (a = 0; a < 35; a++) { grid_set_v("MG_Composing", "a" + a, 0, ""); grid_set_col_width("MG_Composing", "a" + a, 0); } if (md != "") { db_free_cur_area(); db_copy_from_dt(md); b = db_row_count(); for (a = 0; a <= b; a++) { grid_add_col_num("MG_Composing", db_res(0), db_res(1)); grid_set_v("MG_Composing", db_res(0), 0, db_res(1)); grid_set_col_width("MG_Composing", db_res(0), 35); db_next(); } } return 1; } int func_edit_rec() { //msg('edit rec'); csm(); //二次加载 return 1; }; int func_after_save() { //二次保存 string sql, vql, bom_id, mdc; int a, b, c, d; bom_id = gui_get_val("Edit_Bom_Id"); sql = "delete from u_res_bom_item_attr where bom_id='" + bom_id + "'"; b = grid_find("MG_Composing", "res_id", ""); for (a = 1; a < b; a++) { sql = "insert into u_res_bom_item_attr(bom_id,pcode,a1,a2,a3,a4,a5,a6,a7,a8,a9)values('" + bom_id + "'," + grid_get_v("MG_Composing", "pcode", a); for (c = 1; c < 10; c++) { vql = vql + ",'" + grid_get_v("MG_Composing", "a" + c, a) + "'"; } db_run(sql + vql + ")"); vql = ""; } } int obj_change() { csm(); return 1; }; |