|
小弟在做毕业设计,是基于ug的典型工艺库的信息管理系统开发。用visual c++6.0编程,其他部分应该没太大问题,但是数据库死活连不上啊!!急死了,马上就要交了。。。麻烦大家帮帮忙吧。。。跪求。。。我把我的程序贴上来:7 Q0 I4 y! I# M) y! w. S, r1 G
首先是。h文件的代码:
& y; o9 ~0 y7 d L* p* v// MaterialInfo.h : main header file for the MATERIALINFO DLL
$ u, ?2 Q& ^+ v; c//
0 K: K+ G' n3 [# P- n2 N1 F+ t
8 E* F- G. l- o9 T2 v#if !defined(AFX_MATERIALINFO_H__72DE1E8C_6732_4AF8_9DBB_582D57FEAF73__INCLUDED_)
5 O! }8 W) H3 F. u4 {0 k( ?" I: g#define AFX_MATERIALINFO_H__72DE1E8C_6732_4AF8_9DBB_582D57FEAF73__INCLUDED_
5 F, k# E6 R1 y/ u) Z3 c, F0 e
+ [$ k" j* v+ ?. j k1 X& d#if _MSC_VER > 1000
$ z/ K) A, d) q#pragma once
( O3 Y6 G: d5 H5 w8 g! L5 R# Z#endif // _MSC_VER > 1000$ |! Y0 E2 j- h5 b9 y/ e
; S+ R& T( F. |. c E: r
#ifndef __AFXWIN_H__
: }' G; M. a7 b; G( T* z; F! T2 z #error include 'stdafx.h' before including this file for PCH
% M# ~8 A+ e- s- p9 y# ?: l; j% B#endif
" O% |3 D/ n }$ n5 h, l" {$ w
( e8 _! o* H2 @4 K2 j& d#include "resource.h" // main symbols
5 B3 R' X+ ~! i! k6 r1 d* {1 H: A3 r3 i/ D7 m/ U$ e
/*===========================================*/
9 a$ p9 _4 r& J S! w#ifndef MATERIALINFO_H_INCLUDED
# U R- {7 l. R. F. s$ k; U. C4 U#define MATERIALINFO_H_INCLUDED# D' T8 ^$ s# |3 R& S& {
# }. b( s% L% B G, S
#include <windows.h>: x; y/ _6 P; ?2 J% v: {9 A3 y
#include <stdio.h>
+ }, t' E0 V" M" r6 _& r7 Z#include <stdlib.h>
( Q% }2 e/ u4 i, r#include <string.h>
5 H' V" U& F, F9 S6 \$ \#include <conio.h>* `; O$ d6 ^9 U$ J2 ?+ {5 ~/ k K
#include <process.h>
0 }& Y/ ], K- O6 q% T% Q# ?#include <uf.h>
8 z( s; g7 Y6 l s) Y#include <uf_defs.h>
/ Y% D% j4 p+ L4 @4 n) d# @3 t2 k#include <uf_exit.h>
4 b& {) X+ z5 X4 A6 X#include <uf_ui.h>) c! C& Z2 W$ ]& Z
#include <uf_styler.h>, y7 ~( M, y& j" E. h+ z5 `
#include <uf_mb.h>6 G _3 Y5 a. S& n0 H
#include <uf_part.h>
# m" y- j7 n5 q( f5 N; V0 C#include <uf_cfi.h>
" z% D% }4 }/ m) l/ S#include <uf_assem.h>
7 P! t9 z( }+ _+ P#include <uf_layout.h>
+ e1 `. @5 q+ ^# ]#include <uf_curve.h>
4 z. h' E9 i% t d. v: [% R0 Q#include <uf_defs.h>7 Y" Z5 B2 S! ]& U
#include <uf_modl.h>* G }; P5 H3 j2 `0 H
#include <uf_drf.h>0 S! N8 O0 i. `' h7 @6 p) }% k' {
#include <uf_drf_types.h>% p; ]. E% ~1 n7 Q9 m1 V' J
#include <uf_obj.h>
* c5 p* r+ i* z# }) o. R$ k3 U# {8 }# b6 \$ A
#ifdef __cplusplus
0 J7 g* V' k3 ~4 Z2 Textern "C" {
: I1 B$ i% B' n" J#endif
{* S- C# l( w! }7 \0 Q: \) G
/ k1 U* R! m# b& h& c/*------------------ UIStyler Dialog Definitions ------------------- */
; e8 Q; R- H; y9 g/* The following values are definitions into your UIStyler dialog. */' A8 r: a- U# F9 j7 ~' A
/* These values will allow you to modify existing objects within your */, p' J9 t" {6 @5 J0 D
/* dialog. They work directly with the NX Open API, */3 e% H9 _: h; w. K8 f8 Z/ a1 j
/* UF_STYLER_ask_value, UF_STYLER_ask_values, and UF_STYLER_set_value.*/% g- X/ i( G* p
/*------------------------------------------------------------------- */3 j4 V9 \, P) a: s3 U) J
8 ?; S: }$ v- E8 `" _; P4 H
#define MAT_LABEL_0 ("LABEL_0")
7 m0 g# D+ R b* i( j% ^. y$ e# x#define MAO_MATERIALINFO ("MATERIALINFO")
1 F6 p. p) r7 d8 k3 m* P4 P% T#define MAO_MATERIAL ("MATERIAL")1 t& A7 ?+ Z: g# D, k
#define MAO_PARTINFO ("PARTINFO")
" A M/ Q. v# U. m#define MAO_PART ("PART"), p9 t* ]/ I, f* t8 K& s
#define MAO_NAME ("NAME")
2 z% r( Z) q. H$ B& z* T#define MAO_PARTNAME ("PARTNAME")
/ ]0 d& n2 U [; ~3 e6 P4 i) R#define MAO_STD_NO1 ("STD_NO1")( R; l! a W4 l q: n; @7 p
#define MAO_NO ("NO")" J$ e% M) C' v& X
#define MAO_NOTE ("NOTE")3 P. G Y; v8 B- f* L9 |8 @
#define MAO_BTN ("BTN")
6 D. r8 `0 F4 e$ [#define MAO_DIALOG_OBJECT_COUNT ( 10 )
! G. K: j) x* e) y; k" o$ J
" V/ i( A3 o0 N2 ~$ x5 L- X+ w% j
+ H: X" a# O# m/*---------------- UIStyler Callback Prototypes --------------- */( C/ U& D+ |1 n: I; U+ n; o: \
/* The following function prototypes define the callbacks */
! U2 Q1 S1 v Z- ?! e& G/* specified in your UIStyler built dialog. You are REQUIRED to*/: A# T; s1 G3 c! {- w; F# D
/* create the associated function for each prototype. You must */* N$ x7 H5 [- m; ]. }$ V
/* use the same function name and parameter list when creating */
( a( ]1 b* Q0 F7 o7 k/* your callback function. */
& ~; D @; B% e/*------------------------------------------------------------- */2 a, n8 `8 j' @6 \0 n5 f4 e0 P2 t7 R
& W, J3 {7 ^8 q7 w7 f* |$ t
int MAO_constructor_cb ( int dialog_id,: ~- g, D8 u( i3 R
void * client_data,$ R; o% H# J- t L+ F+ L
UF_STYLER_item_value_type_p_t callback_data);; y- q3 S# F( W) s. M* ^3 H
3 ?" s6 [+ ^% R j8 H% w& F
int MAO_destructor_cb ( int dialog_id,
1 W4 C6 b% z$ |; l& ] void * client_data,
) g4 }6 d' o# ?1 I7 a4 k, ^ UF_STYLER_item_value_type_p_t callback_data);$ Y9 {- `: O& @7 F# m- y! z' U- Y4 |
- S% q6 B0 s z9 u8 i2 d ?1 E" K) E
int MAO_ok_cb ( int dialog_id, Z" k: F. x) F8 R3 C! D/ ?
void * client_data,
% U# z; ~5 S( i# T UF_STYLER_item_value_type_p_t callback_data);- X3 y* p3 t" p: m8 [$ L
/ V1 I4 Q: k) B; L8 Y- ]* v7 t- Z
int MAO_apply_cb ( int dialog_id,
9 l* D7 f. \$ m @- [: C1 ^ void * client_data,. q" o+ y1 h5 i
UF_STYLER_item_value_type_p_t callback_data);
6 ]& m1 m; e0 q4 P
$ u7 n# e' x3 v1 Jint MAO_cancel_cb ( int dialog_id,& o- y% M7 y% S. u
void * client_data,; V% S$ G+ M0 w, L
UF_STYLER_item_value_type_p_t callback_data);
7 v0 u, @5 r6 D! m
0 d5 O8 \& c: V! x) ]* tint MAO_mao_type_sel ( int dialog_id,
& H' q) ~6 M @+ c2 y3 _ void * client_data,
7 O& h: q8 U0 K+ N& D UF_STYLER_item_value_type_p_t callback_data);
; K. c: L3 V* E6 j1 o) _9 Z% ~% A' N* J2 b* l% E
int MAO_partname_type_sel ( int dialog_id,+ S" m$ W+ v6 b. V* s$ b; Y5 y
void * client_data,
( s6 I. r" {/ R UF_STYLER_item_value_type_p_t callback_data);
# a$ C8 r) \- J2 o% [ }% J3 ^, ]" h- [( n
int MAO_btn_cb ( int dialog_id,1 f. v/ l2 z# |* K
void * client_data,
: x# |" x" o( a) E0 w UF_STYLER_item_value_type_p_t callback_data);
2 x, i3 C( Q4 E w, E$ V/ Y4 K% D* a* x2 A$ k8 g
* H' H: ^% [; T+ _- k
+ W, F2 B( x. L: l0 F6 Y5 D
4 Y3 K5 B7 S9 R- O- i L7 t#ifdef __cplusplus4 e. b6 Y: u o* k$ `
}( @! C: c3 d; z! ]
#endif
! W: r; w4 ^0 e4 V; p4 ^% c; e1 {' D0 L' }& ~" r
- t0 ~2 |' D, C/ `% a
$ o& ~& z% u. O+ F9 W4 z; t) c& }#endif /* MATERIALINFO_H_INCLUDED */% U! u7 C8 Y6 J
5 w7 U- @4 _; ]0 Q0 Z/ \////////////////////////////////////////////////////////////////////////////
- J6 C" s( g9 X$ @0 _2 O" ]
2 H5 r9 X! L; |7 Q! j7 q6 U//{{AFX_INSERT_LOCATION}}# c. @) P4 h2 d" `9 X, C2 R" I
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
, a" d6 ?5 t: m) Q4 ~- J( t( B
- ?0 L1 R2 P5 h$ \* A: ^& p; R#endif // !defined(AFX_MATERIALINFO_H__72DE1E8C_6732_4AF8_9DBB_582D57FEAF73__INCLUDED_)% s& j; F8 V5 d7 W/ k" a$ a- u# N
$ G* P% ~# x, z8 D/ {) c
! p' A) p. R T- e; }/ C& Y& x然后。cpp:高亮部分是我的连接代码6 b; g. e# n) K" i, S) ~9 n$ ~
// MaterialInfo.cpp : Defines the initialization routines for the DLL.: c" o( D7 _, w
//
) a- {7 ]) @4 c$ U" ^5 t" C6 u9 {& M2 Q g2 i8 c0 M+ y
#include "stdafx.h", b) r" I0 G! U
#include "MaterialInfo.h"
& l9 s1 N' F4 h" l1 T6 ?! l% Z) W. L" P" O$ P7 i' W) s
#ifdef _DEBUG2 z% A1 d# d5 E
#define new DEBUG_NEW, i- O7 Y0 j) T; i
#undef THIS_FILE+ I# r* ~4 n) s
static char THIS_FILE[] = __FILE__;
8 J1 C2 c+ C# r#endif
2 T7 W/ z. T6 A3 q% B
5 x/ V. Y7 l2 u5 N/* The following definition defines the number of callback entries */
- E# R" y/ _- m/* in the callback structure: */% d3 {2 P6 J# {* t- K8 H- L
/* UF_STYLER_callback_info_t MAT_cbs */7 S8 J: W8 F2 _. m( o) K
#define MAO_CB_COUNT ( 6 + 1 ) /* Add 1 for the terminator */% y+ o+ i8 w, Q
7 C9 q& a/ W: U, q6 i5 g
CString strtemp;
6 H4 A) F! }5 ]4 `( Q8 b/ mCString str_tmp1,str_tmp2,str_tmp3,str_tmp4,str_tmp5,str_tmp6;
- Q" _6 e5 d7 H5 J6 `0 J( g2 E
M5 l/ ^' D) {5 v6 b$ q//add_mark:添加标志;7 e* B6 q0 A) o
int add_mark=0;
0 T1 o5 u* W. f5 pchar DbType;
4 O% g8 `1 z9 o( {5 Y7 ]0 A! C6 b4 B( {
//定义数据库指针
; { x* W: s) I/ K* E& FCDatabase *m_pdatabase;! b8 d4 q/ M+ t
CRecordset *m_pset;
& {- ]4 c1 F7 t9 }_ConnectionPtr m_DBCnt;- ]$ M t$ h1 l$ n A' _7 ^9 N9 `
_RecordsetPtr m_pRecordset;
' O# o% s) s O2 e2 |% z$ m
2 W3 X! r" y L1 o* I/*--------------------------------------------------------------------------*/
: ^+ a! w: d8 }4 s' lstatic UF_STYLER_callback_info_t MAO_cbs[MAO_CB_COUNT] = 7 }0 K% L# P8 D( i
{
% @& W/ p" A4 t5 @+ Q& P {UF_STYLER_DIALOG_INDEX, UF_STYLER_CONSTRUCTOR_CB , 0, MAO_constructor_cb},- \' ]0 ?/ n! S3 g) b
{UF_STYLER_DIALOG_INDEX, UF_STYLER_DESTRUCTOR_CB , 0, MAO_destructor_cb},$ u" F( \ E+ K2 d9 d
{UF_STYLER_DIALOG_INDEX, UF_STYLER_APPLY_CB , 0, MAO_apply_cb},
+ J* Z+ K( Y+ G) \. [ {MAO_MATERIAL , UF_STYLER_ACTIVATE_CB , 0, MAO_mao_type_sel},
9 ]6 H6 [. E, q% v( D r {MAO_PART , UF_STYLER_ACTIVATE_CB , 0, MAO_partname_type_sel},
( P2 a8 P/ Z: Z# j {MAO_BTN , UF_STYLER_ACTIVATE_CB , 0, MAO_btn_cb},+ ~, g0 b: _' R8 V# d0 |
{UF_STYLER_NULL_OBJECT, UF_STYLER_NO_CB, 0, 0 }
: r, j- [1 o! w9 M};
* f# Y k+ Y$ x' ~' o6 b; S V3 n& p% y4 t: E- G
/*------------------------------------------------------------*/0 v# d) Q+ m, Z9 q. z; j" z3 y( |
static UF_MB_styler_actions_t actions[] = {3 O3 ?2 e# W6 m
{ "MaterialInfo.dlg", NULL, MAO_cbs, UF_MB_STYLER_IS_NOT_TOP },& S5 N5 [) v& d, p; J. y5 {) X/ z
{ NULL, NULL, NULL, 0 } /* This is a NULL terminated list */
6 l0 K, ] p; R: R- ]# ?+ @};0 H" m9 i2 Y ?2 q8 w$ Y. i& c
) x, W* V( o# F' l3 j3 a
& e0 C' I$ l M. t) y9 M
/*------------------------------------------------------------*/* V) k# w0 ?" f0 E* s) X# Q. k
extern void ufsta (char *param, int *retcode, int rlen). k/ T [1 q9 D9 [- L! g7 j5 Y
{
. i9 v6 W3 E! [& J3 ? int error_code;: E5 b$ x* ]" h
- b U- w1 A8 |& w if ( (UF_initialize()) != 0)
3 ^0 @ x" x) b* J& t& d: P3 G return;
6 g- l* ?% Q) `7 V2 D2 V4 ?- m; K. d1 E4 Y: U( [3 R" i% x1 R0 a
if ( (error_code = UF_MB_add_styler_actions ( actions ) ) != 0 )' i* y2 Z" G. `" e8 }- u
{
- c$ h$ M1 w- z+ U9 U# a, a char fail_message[133];2 F' Y! Z3 l1 W5 S3 W
( V/ l/ x* b4 p9 ^7 {; g
UF_get_fail_message(error_code, fail_message);! T, M0 e# w4 @; f
printf ( "%s\n", fail_message );
8 `8 F! h: s. ~( w }
0 L7 f: e/ q; m( m2 D, ]
/ W6 C9 M( M7 r8 N9 r- n UF_terminate(); - \! j) J9 F/ d
return;% I! l2 K, G% c2 c7 m5 n. m
}
/ V1 v5 x6 | {9 w, G9 R& K% M; J
) w$ _$ k( }- y/ Q9 a6 @/ P/ q6 \# u. A) v! |" ]: c
/*------------------------------------------------------------*/
% e* {! z$ Z) p' H/ kextern void ufusr(char *param, int *retcode, int rlen)
# H+ w; p% v+ g( q6 `+ v{ U: g, ~0 e7 j3 T
int response = 0;
) A" h- c& Q& W) f! ]3 U d int error_code = 0;
/ Z$ q- S: B& t$ {) f8 Q8 k6 @/ N5 p; C; a2 u# H
if ( ( UF_initialize() ) != 0 ) 4 T( i' X7 v2 U+ X% b3 n5 Z( P- H4 O B
return;
0 E, b0 Q l0 X: n t5 \- h" l' ?) n/ O8 q( G0 y
if ( ( error_code = UF_STYLER_create_dialog ( "MaterialInfo.dlg",
0 b4 U( Q" F3 s5 ^# x4 B$ Z MAO_cbs, /* Callbacks from dialog */1 s- \6 }2 n8 K+ ?
MAO_CB_COUNT, /* number of callbacks*/2 O0 r/ V6 q! A8 w U. n& \1 c
NULL, /* This is your client data */
- M. i; }5 F3 `6 R8 N, w &response ) ) != 0 )4 K3 Z' Q. y1 c: R H& j
{
$ v* j6 l+ n; M% Y. j) D char fail_message[133];
' j- D) u$ l, h E8 R a: ? @/ M% q; r1 n* L* t9 C5 Y$ n; G
/* Get the user function fail message based on the fail code.*/' ?7 R+ @& Q! o' |- c' M6 a
UF_get_fail_message(error_code, fail_message);
( a' A1 @ U1 r J! e- p+ M UF_UI_set_status (fail_message);
* m p; V6 X& v4 {, g printf ( "%s\n", fail_message ); 1 {* }# k7 A' ?# M7 H
}! F4 g5 G! W, U5 D7 N/ X$ m
6 g7 ~, o* o& X
8 t8 R6 q R) H+ B( X
UF_terminate(); 4 ` ]/ Z+ u2 _, v
return;
& j% ~1 U& |& V9 S. Q3 d}1 T9 I" l' o) M8 B
5 _" E6 H+ ]" h8 y/ M& i7 g
/*------------------------------------------------------------*/
. I2 r3 R% Q z, Y" \# `3 gextern int ufusr_ask_unload (void)
7 k- T# ?; t9 k* J{
4 j% [6 V" A2 S: D- |- K% P /* unload immediately after application exits*/) n( m7 l& W, Q- j
return ( UF_UNLOAD_IMMEDIATELY );
- ^ q/ g- p- e8 G% P4 p% `
: l8 u# t+ q8 ~* m4 \ /*via the unload selection dialog... */
- [0 S# r2 L8 z! l# Q4 d /*return ( UF_UNLOAD_SEL_DIALOG ); */ w$ I9 Z8 U# a) z' z$ S; I
/*when UG terminates... */, p* H* A! f& I# D" l
/*return ( UF_UNLOAD_UG_TERMINATE ); */
# K2 k0 l% s0 ^4 X: i" J1 [0 ^6 i6 S1 _+ D}* w: ^! \8 p) q) G# r7 S( g
. C5 A$ }2 Q5 x4 s( y
! Q: q! I; r; Q3 E4 Z/*------------------------------------------------------------*/3 S- R) Z) F' M7 ~6 h
extern void ufusr_cleanup (void)
3 b/ a+ E4 E$ n$ A{
; w+ s9 x2 Q! x return;" i4 j1 e! E p7 g, ~
}0 c, b+ b$ D. Y5 x- Y- L+ w! M" X
$ z1 C0 ~5 ]. d2 H4 [
' |$ B; A: S0 D/*-------------------------------------------------------------------------*/* P! D0 S3 J& B$ g6 ^
/*---------------------- UIStyler Callback Functions ----------------------*/. L. c, `9 F' P# K; }7 {3 Z' v
/*-------------------------------------------------------------------------*/
; Q9 | X6 V& ?% w8 W//在构造函数中初始化,将数据库中的产品列表信息调入显示窗口中
- B( k k3 Q6 ]0 a# ?- s# \$ J a8 d, K/ x$ I. n3 m# r
int MAO_constructor_cb ( int dialog_id,' w0 E3 a: }) L5 Q
void * client_data,, t# a d/ f9 l3 [4 v
UF_STYLER_item_value_type_p_t callback_data)
3 A, ?2 G3 L; p{, z. ?( T3 O( e- K- a+ m
UF_STYLER_item_value_type_t item_data;: h; G6 w. V" @9 W! d0 {
) J7 N+ }- _, {0 ?7 G, y
/* Make sure User Function is available. */
9 J( S+ O' t7 J4 x9 e if ( UF_initialize() != 0)
9 t0 i O, ` k+ }* Y {: _: t return ( UF_UI_CB_CONTINUE_DIALOG );
- t: T* z, H- _ D2 B: J2 K- K; v8 |! o4 d- F
/* ---- Enter your callback code here ----- */+ P3 y% R) R* c& G! V! Y
/*-------------数据库初始化-------------*/* D+ ?; M( f% j6 {- R7 `/ [) s0 X9 X
//----在构造函数中初始化数据库,并将材料信息显示在界面中----
! _/ {, }4 |4 @* j
+ L+ \, T1 q8 F A3 y( E6 [
0 f$ K$ ^! [% E x, l& L
2 j# ~! l# U {2 c+ @! e) L$ W! O: M2 d) P# z+ N1 b* z$ H7 Y0 j
char JigPath[120];
3 L3 d' y" k) z( E; R7 Z% B strcpy(JigPath,getenv("UGII_USER_DIR"));
( O: X0 Z w7 Y+ i, V8 z5 l, Z4 p/ c! a& X) [
7 v6 `( t6 C# e4 w8 y
//CString strtemp;
& O% j/ m$ [4 ~& J. Q; E }strtemp = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=";# O: U; T; f* Y& \; h- j
strtemp = strtemp + JigPath;1 D0 R7 z. y% C/ y9 g; T
strtemp = strtemp + "\\application\\Mao_Manage.mdb";& K& m- G5 A1 D2 e2 J7 `7 y
) A E! j: w s1 b
. i( B: v4 S+ z L- t6 z# l try
' B5 r& t! h8 d8 f# C# z8 k# H A2 ^; \ {
: {8 S" S+ p" b+ \- ^+ w L. I, M CoInitialize(NULL);
% E- F( J# T; g _ m_DBCnt.CreateInstance(__uuidof(Connection));
& W& n' n* i( S% a {% i. U9 o* i3 Z- c# _% |1 L
m_DBCnt->Open(strtemp.GetBuffer(strtemp.GetLength()),"","",adModeUnknown);
% r- h2 ]- [8 H; O$ W }1 J: C" ]0 L9 E+ R" N
}
9 @# c8 D+ C2 M) X+ k4 ] catch(_com_error e)
& Z& `2 X7 x" Y- X$ m* } {( t' Q2 J6 B5 W+ S- L
AfxMessageBox("数据库连接失败,确认数据库设置是否正确!");& c" e2 F0 g6 P8 f* }! X5 b
return TRUE;
; |9 }" ], V% Q2 u2 ?1 T3 j; |! _ }
8 N6 K' `9 w) P8 B+ [2 ^$ w# E# G. U/ T" k7 m( a- E
//设置按钮属性
$ A! z9 t' u8 B) t item_data.item_id=MAO_BTN;
6 v( q6 X$ V, _; B* F$ Z item_data.item_attr=UF_STYLER_SENSITIVITY;& z/ \2 i. x5 P" G/ n
item_data.subitem_index=1;2 w# L: \6 x( M9 w4 m3 g* a
item_data.value.integer=FALSE;
0 l: Y2 I9 N, Z+ B3 C( m3 R: g UF_STYLER_set_value(dialog_id, &item_data);
+ [% {4 A, p8 U2 v' c1 q4 D B
% l/ F& v. Z) O# w( I item_data.item_id=MAO_BTN; b: q; k6 e* z2 E/ q- E( |
item_data.item_attr=UF_STYLER_SENSITIVITY;% G) O- e T& |7 |
item_data.subitem_index=2;
1 }5 s$ P- H! A7 w( H: `6 H item_data.value.integer=FALSE;
5 [. L- f1 _, j UF_STYLER_set_value(dialog_id, &item_data);# L4 s- e6 K$ B T) h/ G2 t2 }/ P
/ D( w6 q: C. P0 ?% G( o
//初始化SingleList 2 h- _ O* _8 H* |9 E
//从数据库中选择类型,并列出
/ A/ C0 r6 d8 z& M
' S3 R7 ]: F) w) |1 G _variant_t var1;
% @( o/ W8 |$ f5 t `4 A CString str1;" {$ }1 }+ {& i1 _5 n' O# b
1 s9 Z: M/ e$ W8 Y: \. q
item_data.item_id=MAO_MATERIAL;$ p0 T1 B$ w' m5 G) h7 Y
item_data.item_attr=UF_STYLER_LIST_DELETE;
- u+ E) `+ u2 j) j0 v9 { item_data.subitem_index=UF_STYLER_NO_SUB_INDEX;
* e1 F- s$ C, @0 e, \/ E( k2 r item_data.count=0; 0 f: D% G }- M% j
UF_STYLER_set_value(dialog_id, &item_data);& p$ {/ y7 x6 y9 |) s1 h
9 g0 k z. N# M+ ^$ u3 K item_data.item_id=MAO_MATERIAL;1 O& |5 F6 s2 }# u( {. L
item_data.item_attr=UF_STYLER_LIST_INSERT;
' O/ r; t# [- Q2 j7 ^, B: l item_data.subitem_index=UF_STYLER_NO_SUB_INDEX;
! Z4 e" H' d; N, j1 x& D+ ]2 t5 e, v( K0 g
if(m_DBCnt->State)* a. N! e& I8 b. X* i1 V2 M( \+ e
{/ C* [+ u" q/ h8 ~4 v
m_pRecordset.CreateInstance(__uuidof(Recordset));
% e, [5 N0 y, ^ B try
: F! M C( V( N+ `0 }' \: k" { {
0 Y) B& X- N) d ?* Q+ b. f m_pRecordset->Open("SELECT Distinct MATERIAL FROM MATERIAL_INFO",
9 ~: F0 }( \! U/ d6 \ m_DBCnt.GetInterfacePtr(),3 Z3 k5 M/ q8 \$ ]
adOpenDynamic,3 U! ]* M2 a {, e/ V- i
adLockOptimistic,9 d3 U) M& o- f& e( u u) V
adCmdText);. c! [3 B% n! v; G7 J) Q
try
: O) {) q4 i4 o* Z6 u6 q4 `- c { 9 u& C' e! [; r; X( d
while(!m_pRecordset->adoEOF)
( w1 L1 J* p" }3 l0 c) G2 x {6 _/ l' Y" a* ]! j
if(!m_pRecordset->adoEOF)
# A8 }6 {) ~2 ?! `5 I var1=m_pRecordset->GetCollect("MATERIAL");* e# k+ b0 q F( c" S( ~
if(var1.vt != VT_NULL)
: A, G7 `+ O. [ {
8 l+ Q5 m# ?( }7 K str1=(LPCSTR)_bstr_t(var1);$ U7 I; |5 C" |- |9 e7 N3 b, E T; c
4 K+ D4 n7 @' R+ D
item_data.value.string=str1.GetBuffer(str1.GetLength());1 h+ I2 b% K' E
item_data.indicator=UF_STYLER_STRING_VALUE;
; Z+ w! R; K. V( q0 _ UF_STYLER_set_value(dialog_id, &item_data);6 \, t: Z$ c* r W0 T2 U! b
}
; N" j9 n& ^+ e6 s7 Y if(!m_pRecordset->adoEOF)
9 w) a# W7 J2 |& } {
( m8 i; G2 p1 @" ]$ Z. G5 S m_pRecordset->MoveNext();- {+ t M( F2 T) U& w7 v8 V
}' [; M; l6 Q: {" I% D$ @9 X
}! R/ \/ p- q$ f
m_pRecordset->Close();
! a( H0 a4 \* O) T# b) @! Q }
2 p* {" f0 Q2 }2 c, u catch(_com_error *e)
2 L' n& y- x! b4 l+ } {* X) A5 Q( O- ^. Y. e& [
AfxMessageBox(e->ErrorMessage());
$ B* ]& a; e5 {3 Q+ K- `' w }% E7 A; Y0 J; p$ T2 n
}
( v! O2 M4 q: J* M catch(_com_error *e)
0 u, C9 x. Q, w2 K% ? { - G1 E: U8 d& P. G# X! s
AfxMessageBox(e->ErrorMessage());' P7 q. g2 i$ r/ _+ E# J) Y) r
}3 N# Q7 l; _: l3 z5 f1 e* a
}
+ @1 N2 Y7 E1 u, K: N* ~+ s$ g, `6 V( c" o+ e# Q, y% Q- e3 T+ ?. R
UF_terminate ();
2 m) C$ U. q1 }$ W. ]; v4 x" F# ]# n' m' T* {/ [% j7 z' P+ _9 }
/* Callback acknowledged, do not terminate dialog */" d( t3 _ J) q) d! G7 B
return (UF_UI_CB_CONTINUE_DIALOG);
$ T: `. j& X* B9 U, D$ [5 f /* A return value of UF_UI_CB_EXIT_DIALOG will not be accepted */3 \3 R3 g+ m. j1 d
/* for this callback type. You must continue dialog construction.*/, i/ z) A. c X' {4 \# ~4 a
0 t8 `: x; v+ [- c7 ~8 P}
. N+ [6 e( `3 Z* g. c A% V% Q- _* ~. v: d' I% z
/*------------------------------------------------------------*/
4 G4 T( \: |9 [/ Oint MAO_destructor_cb ( int dialog_id,% ^* t3 J- i; s8 |& C! q; G4 ]
void * client_data,
+ D9 e% ]- S8 p UF_STYLER_item_value_type_p_t callback_data)
3 V" o2 `/ Z5 z0 D) d: {" D. E{
2 a6 G( E9 \& w /* Make sure User Function is available. */
) }" l/ u( N- V7 l+ N if ( UF_initialize() != 0)
$ F7 ]9 w7 V% ?" p return ( UF_UI_CB_CONTINUE_DIALOG );4 H( D5 G* A, E7 k- `
) |; N- c4 M8 A# v5 }, r& B
/* ---- Enter your callback code here ----- */
2 j) D) Y* ~; B, I) ]$ D2 g1 ?7 L/ x8 C& k# i7 Q) z- L
m_DBCnt->Close(); //关闭ADO连接3 K9 b8 V5 K; \
m_DBCnt= NULL;
! C k5 ?; [' v5 G! N% b4 m CoUninitialize();
, X7 o8 o$ i, P( X6 K
& o L/ t; x) W) k UF_terminate ();) D* o! p, ^0 `
4 G! F5 T0 _* t2 M3 \' k, p+ Q1 g
/* Callback acknowledged, do not terminate dialog. */
0 T- b1 u- _- E /* A return value of UF_UI_CB_EXIT_DIALOG will not be accepted */
% j8 }' U1 j5 J3 E# b4 i! p( t /* for this callback type. You must continue dialog destruction*/( `$ ^1 D4 V4 v! e' C! |
return (UF_UI_CB_CONTINUE_DIALOG); 3 |* l, j% i- X
2 e, H6 G2 w( A" J
}( l: L7 i. [! k. m3 d1 G# O3 N; z
3 `: r* r4 K( w* N
2 f; I( ]% A$ l: Q5 y; S6 ]# Q/*------------------------------------------------------------*/# O- n& r3 @, l3 b& \; D$ u3 f
int MAO_apply_cb ( int dialog_id,
! M0 b3 O: C( x6 {& t. J, R void * client_data,
# t& p) f5 d8 }7 W3 Q UF_STYLER_item_value_type_p_t callback_data)
1 [. X! |6 d; V# m% f6 e5 d7 n( k{; `* _8 [" m1 g6 P% K" ^& O
/* Make sure User Function is available. */
0 Y% {& y9 q; w _, ? if ( UF_initialize() != 0)
% I: W" y# I* V0 v- m return ( UF_UI_CB_CONTINUE_DIALOG );2 g, L' k: u! l4 @! v+ u
+ f0 Y- M$ Z1 T! h& K' w1 l b
/* ---- Enter your callback code here ----- */; c6 ^( r3 _1 A$ P+ @! b
8 Z: } X$ X7 Q& j* @ UF_terminate ();
% p& J. q+ _! h1 n8 I. t, N, w3 @5 K: F& J4 {% V6 ^& e
/* Callback acknowledged, do not terminate dialog */
. i) @0 B/ f7 l6 F: [ /* A return value of UF_UI_CB_EXIT_DIALOG will not be accepted */
' ]' B3 X d7 ~ /* for this callback type. You must respond to your apply button.*/
% M3 b" J, n. `8 t" b return (UF_UI_CB_CONTINUE_DIALOG);
2 B6 h# j1 G1 N
; Q u4 J4 @" `9 l. D}5 k$ u F1 k \0 `8 w, v$ i+ c
6 C% b. M( {6 H
. I, [) _% q9 y
/*------------------------------------------------------------*/4 u' B7 q% ^8 ~! I( u+ r
int MAO_mao_type_sel ( int dialog_id,& R0 G2 j5 Y; y3 R/ a4 j# a. p G
void * client_data,6 T6 g9 Q' b5 ` A
UF_STYLER_item_value_type_p_t callback_data)# ? E, ?' f) U1 @
{
# \: Q! j4 {9 G1 ~$ y( W1 E UF_STYLER_item_value_type_t item_data;
9 @; m% W5 R7 S" X0 _$ @6 t- S, {! W* y' k6 g4 |: a: H
/* Make sure User Function is available. */
3 ~" Z& C1 A, U if ( UF_initialize() != 0)
$ j0 o) _* y* f2 t/ k9 F return ( UF_UI_CB_CONTINUE_DIALOG );
5 \' u0 l( \8 Z" H, s5 W' C
- K8 S/ y; h" Q/ b# f0 W /* ---- Enter your callback code here ----- */' B9 |' f6 H) t6 w" [. B
+ `% r1 m5 h. | _variant_t var;3 k0 u* n) ]- c
CString str,str1,str001,str002;. C0 Y& g3 r0 Z$ ?* } B1 t
char name[100]="";
1 |5 L+ P% u8 `9 {( R4 t. Z// int i=0,j,k,m=0; F g+ _5 l a- |
//锁定按钮
6 m7 U6 `( O$ F item_data.item_id=MAO_BTN;
; k) U$ V' D3 B item_data.item_attr=UF_STYLER_SENSITIVITY;
2 ~0 o. W) B! z7 O+ C8 f1 n4 q9 }4 k item_data.subitem_index=1;4 k" I4 x, _6 S$ }# {1 Y
item_data.value.integer=FALSE;! C) x. }. H6 A) x* Y, A+ A
UF_STYLER_set_value(dialog_id, &item_data);
M0 V+ K7 a, P; {# g- H# V
/ ^% x/ F: |# Q1 Z- t/ { item_data.item_id=MAO_BTN;
, r8 [4 S2 q4 H. T& i+ F% U m! T item_data.item_attr=UF_STYLER_SENSITIVITY;
- ]+ `! w) e) Q2 l; q4 x. m3 e item_data.subitem_index=2;
& a+ E* }; F/ d: ] q item_data.value.integer=FALSE;0 L' x- ? ^% p) h% Z
UF_STYLER_set_value(dialog_id, &item_data);
8 }: K% O& P( j% X0 Q$ t/ C( t& R( z _0 D1 j* S
item_data.item_id=MAO_MATERIAL;
& e& u6 @. z! h# m- U: L item_data.item_attr=UF_STYLER_VALUE; ' y. ]" f( W2 k7 d
item_data.indicator=UF_STYLER_STRING_VALUE;
/ \5 t+ {1 k r' U, D, N% \ UF_STYLER_ask_value(dialog_id, &item_data);
- c7 P: i+ L/ N+ [9 P9 A strcpy(name,item_data.value.string);: M) ^# U% {0 }2 \9 g
T" L" q/ K- Y2 M- h6 z
//在材料类框中选中一项后,获取其中的字符串,以此作为关键字从数据库中搜索匹配的材料;* H4 J$ V0 |# ^# ~1 s! L
//将匹配的记录显示在零件名称框中。显示方式:名称+牌号,以确保唯一性。
+ R5 I' r/ w2 A8 c& o% T/ Q# X
$ n' m1 c: [: l" @4 m' { item_data.item_id=MAO_PART;/ O2 r* [& U6 }" R+ o/ B5 h
item_data.item_attr=UF_STYLER_LIST_DELETE; , J: | g* Q% G) v4 o
item_data.subitem_index=UF_STYLER_NO_SUB_INDEX;
; ~4 c( ^3 i1 L9 N8 F3 | J ^ item_data.count=0; 1 B2 t0 L; @. Q# |; q+ w
UF_STYLER_set_value(dialog_id, &item_data);. q3 o/ I2 ?5 e0 l
' z; {4 N @" P' \ item_data.item_id=MAO_PART;
; p+ G* l6 \+ B8 _9 q: d item_data.item_attr=UF_STYLER_LIST_INSERT;
. }: {7 g+ N4 p! l7 s item_data.subitem_index=UF_STYLER_NO_SUB_INDEX;0 [* r2 E' o/ E y" q$ ], g
* V( Q* g/ X! e" f" Q. w6 s3 O \
str="SELECT NAME,BRAND FROM MATERIAL_INFO WHERE MATERIAL=\'";
3 j' Z* {9 c7 V4 o4 U% ^ str=str+name;6 r! l, e' {5 P( |% U
str=str+"\'";6 {- `+ S' g p8 P) J+ ^) l
% {" H+ F; c2 S6 a. G
if(m_DBCnt->State)
2 [0 H! X! B* y5 `2 |# x8 A3 t {
' J9 {/ Y& d: l m_pRecordset.CreateInstance(__uuidof(Recordset));2 L- ]* u4 P* }7 Z! {* M
try& ?- T: S6 m0 Y4 T
{8 B+ } [% j$ h9 y0 G0 n
m_pRecordset->Open((LPCSTR)str, 3 r- A6 u8 L# o
m_DBCnt.GetInterfacePtr(),
4 M* z% `8 _$ l adOpenDynamic,$ I* D7 k" K1 y V# I
adLockOptimistic,
3 X# N* e, Q8 U$ H7 p( H adCmdText);. F u" Y5 P; h$ i
try V ]! [4 m& _! S4 M5 f
{% }5 c+ Q8 K' W, J) F5 w3 [
while(!m_pRecordset->adoEOF)6 \. j# G1 H, j# T+ B$ E0 z
{. @8 Z7 x6 p- e7 e
var=m_pRecordset->GetCollect("NAME");+ s1 s l, o( Z: b- ^! g& K3 N
if(var.vt != VT_NULL)4 J6 e& V* Q) M$ w
{
" G* X. u0 z& J3 D0 P- }5 I str001=(LPCSTR)_bstr_t(var);
- a+ l4 i j( w+ g* h }
0 x! n q, s% d; H8 _. { else9 I: X; ]' d& m9 X
str001="";
" l8 t; x; ?) n3 M var=m_pRecordset->GetCollect("BRAND");1 @8 y! ~; f: `8 c; ?+ a9 X8 _2 F3 u/ b
if(var.vt != VT_NULL)4 F" Q* W: O" [9 W
{; w5 ~3 P1 f. ?) x% U: F& C: X
str002=(LPCSTR)_bstr_t(var);8 a& P" J2 B8 e3 X$ F1 ~# r
}
: C1 \8 G8 S' e, A else& v1 r4 @+ t; a3 |$ Q6 R# w
str002="";
0 ~7 }: D2 c3 L5 g) ?
% i8 C z9 v' y1 h+ R. G str1=str001+"*****";- I. D e6 x5 T( c& x
str1=str1+str002;+ h4 M% a% M/ T$ h8 y' V# W; D; b
+ k- @* U9 f# V item_data.value.string=str1.GetBuffer(str1.GetLength());
. F/ G5 c) U: Z s% P* n* u' D) ? item_data.indicator=UF_STYLER_STRING_VALUE;) }. S0 D& T; Q* c, p+ u
UF_STYLER_set_value(dialog_id, &item_data);7 b! u) w7 c- W! s6 n# t) L
& f- g4 O K9 g( c: I
m_pRecordset->MoveNext();
% z& V: }/ @% E6 k2 Q } D5 n0 d$ t" s* Y9 E( s7 h
m_pRecordset->Close();
! C: y/ q+ h$ t4 ^( {! T- r m_pRecordset=NULL;
" X9 E9 G# Q$ y& H) F) B }
2 o: n2 {0 q9 h! {! G catch(_com_error *e)
9 q9 R: |: [/ D% S# ` {
0 h: i) ?8 X2 Y( a- g6 y1 j AfxMessageBox(e->ErrorMessage());3 e# N. X2 S7 N3 K! W% h# h, v
}
, G% O# }2 h# b P& N }
+ Z2 N8 x! H8 y) l/ @6 w catch(_com_error *e)
0 a" i6 b) b4 h& t9 W% N {
$ m- M a+ c+ Y$ V+ A/ v4 ? d/ E6 H$ y3 T AfxMessageBox(e->ErrorMessage());
. m2 \5 o- B+ d; k- _/ s: i7 c2 [ }& e, r T* h8 a7 d
}+ j2 l U' L4 {% @6 d4 r
4 H( t+ h* z( ]6 o7 t _' g. P UF_terminate ();& c$ E- \6 ?3 U4 U
" }$ ?2 o+ @0 ? /* Callback acknowledged, do not terminate dialog */
, k2 G& X) {& _2 {5 j return (UF_UI_CB_CONTINUE_DIALOG); ; ]# \; o v1 y ~" z6 @( Q
0 H6 u( w3 H$ l" d /* or Callback acknowledged, terminate dialog. */
5 ^/ d2 J X. k9 Y. Q' W! S /* return ( UF_UI_CB_EXIT_DIALOG ); */
& k6 [: V e& I* K$ e3 R7 I8 a4 w) ~5 m) w* Q. J
}
; x' s! e: Z0 S0 r, E3 v, l
7 y7 g- [0 m" d% e# X9 O w; o/ m7 p ^2 W: z& _- V* f/ j
/*------------------------------------------------------------*/. i5 ^! \$ ?4 n& V. u! T
int MAO_partname_type_sel ( int dialog_id,/ u0 C0 x' A% Y! [# B. n! |$ b
void * client_data,; K5 R! V6 j# [% a/ B( G+ s
UF_STYLER_item_value_type_p_t callback_data)
8 w4 T# X$ \) |{
% W7 u. {8 @% b: v4 C UF_STYLER_item_value_type_t item_data;& G4 i; k* F- M5 C- w5 \! S
/* Make sure User Function is available. */
8 e& J- q& E" D3 X& Q if ( UF_initialize() != 0) / r7 @" m: J( v& F" u) B
return ( UF_UI_CB_CONTINUE_DIALOG );
6 T( a1 A% V: C: p
* {( D5 l5 h- P, Z9 n1 B8 y* a /* ---- Enter your callback code here ----- */
- t0 [8 }( B! s+ Q- O. J- o//选中一种材料后,改变按钮属性:保存/删除变得可用: l ]1 s5 f- ]1 l# K
//设置按钮属性# c! L8 y3 ~2 w! k
item_data.item_id=MAO_BTN;+ I" J9 _* E5 X6 s5 M% B+ e
item_data.item_attr=UF_STYLER_SENSITIVITY;- @* ^# D+ `$ V% ^& W% U
item_data.subitem_index=1;
' `$ j! P# B3 `- j+ Z. u G4 @: ?3 L item_data.value.integer=TRUE;
; K- h) R+ Z/ w) t4 y UF_STYLER_set_value(dialog_id, &item_data);% K( f) N! U; C" a
! U7 M3 d% B l. i( h) q' ~
item_data.item_id=MAO_BTN;
L- V; y, ~$ T item_data.item_attr=UF_STYLER_SENSITIVITY;
+ v: w2 l6 w* @0 C9 \# l item_data.subitem_index=2;7 O& f, z7 R0 K- B- o
item_data.value.integer=TRUE;, {- `6 J+ o8 x% ]' z0 M" W
UF_STYLER_set_value(dialog_id, &item_data);9 p3 c, W- L" b
* {( t" @" g, Z: r* L8 ~//选中一种材料后,一条记录被唯一确定,下一步从数据库中定位该记录,; q* u' A! s0 O5 Q B( u" F5 K
//并将有关字段显示在相应输入框中。) w4 I; V; T! k/ O2 x
* Q# n, R4 s( ^% _, M6 ]
char name[120]="",name1[60]="",name2[60];
6 o# O( B8 [: z1 H8 I int i=0,j,k,m=0;
8 x6 N$ W4 ~$ o& J- z0 u, w4 m, O# q: \: \ W: [% Z$ h# Q5 U0 g! Q2 x
item_data.item_id=MAO_MATERIAL;
: u& E9 U5 g* U" k7 k9 g5 K0 K item_data.item_attr=UF_STYLER_VALUE;
' P' v. h1 w( E9 X item_data.indicator=UF_STYLER_STRING_VALUE;
$ V0 }2 K0 }7 [, Q UF_STYLER_ask_value(dialog_id, &item_data);
/ y0 ^. S6 M0 \$ q/ G; m: B* ` strcpy(name,item_data.value.string);' B( Q3 t* w! c$ D5 G- v! [
9 [0 S) Y5 x6 i& ~( s, J
//显示材料类型名称
8 r1 a' g. h$ P- \4 F* p6 Z item_data.item_id=MAO_NAME;
5 c! X- Q5 e; g* ~- X6 c4 } item_data.item_attr=UF_STYLER_VALUE;1 h/ Y5 v$ Y* t
item_data.value.integer=TRUE;9 p/ H2 E) r& p- R- j
item_data.count=1;
/ \( R# Y) b- K' y4 O item_data.value.string=name;/ a( T" m& b8 ]+ e y
UF_STYLER_set_value(dialog_id, &item_data);
. Z3 u# \, a: y7 V- I str_tmp2=name;5 q& ]* N* o- P% L% }7 c% e
% b: k, G$ U! K7 O. \' _9 k item_data.item_id=MAO_PART;
2 _0 u& ^( [7 @/ e; m! j- m item_data.item_attr=UF_STYLER_VALUE; , l$ @# P" K6 [3 [3 S
item_data.indicator=UF_STYLER_STRING_VALUE; 0 n9 p; V6 y/ C8 I/ A6 S2 b
UF_STYLER_ask_value(dialog_id, &item_data); 3 c# A* O! {6 F, |0 c
strcpy(name,item_data.value.string);
; Y( |, m1 D' Q
7 C: |! u% g5 T( U% Q2 J j=strlen(name);- Y+ a# `, G3 Y% c' x6 D8 k
while(name!='*')1 A ]2 y3 Y5 c) ~
{6 b6 L# }. |' f* |
name1=name;6 ^* e/ \( l8 i
i++;
2 ~2 q( S+ q/ P$ e8 p }6 g+ E9 q+ U" ]# B
name1='\0';
) A4 ~# k) p j* o$ A* R" p! Y( J, ~1 `8 z' E' w, x
for(k=i+5;k<j;k++) M4 Y% S w- n. Z; L
{
. j1 v. j' L# _; U) @/ F name2[m]=name[k];
" q5 k0 {+ y3 k0 K9 c m++; F7 X& p" g$ b2 I# i
}
% y" y5 ], i9 u name2[m]='\0';3 v2 b+ q0 [% Q6 B) q
//name1: 材料类型名称;name2: 零件名称
0 |/ v2 ^, h# ]; p1 ~$ T3 u7 j: a( s( J+ ?5 u" w9 V. Y- u
. o }8 f5 I1 c+ _//显示零件名称7 ~% p! P0 a8 Z. N- w
item_data.item_id=MAO_PARTNAME;- h, f- V( E' L$ k- H% Z
item_data.item_attr=UF_STYLER_VALUE;0 V4 V+ o+ }/ J$ V! K; w
item_data.value.integer=TRUE;
4 R7 A; {0 k0 \+ o/ | item_data.count=1;
0 V6 e" r2 j; J' T9 j# l; ^ item_data.value.string=name1;
/ s2 _# b7 ^) P+ s3 D$ F" n: G UF_STYLER_set_value(dialog_id, &item_data);
* q, y. h9 J' m9 t0 I% q G0 j; e8 w
//显示零件材料牌号3 L, ?- C4 k4 Y" N& u1 C9 i# [
item_data.item_id=MAO_NO;
" v* F; w# \& Y5 D item_data.item_attr=UF_STYLER_VALUE;7 H5 z" G5 _8 R, L
item_data.value.integer=TRUE;
% C* p% I6 v- V, G$ ~ H item_data.count=1;- o! N8 ?% {8 ]) \' V
item_data.value.string=name2;
0 I- [* w' d5 v' I9 }) R UF_STYLER_set_value(dialog_id, &item_data);6 W1 C6 `/ N2 u+ ^5 ]) ?% P( O
4 T+ x5 c1 s5 w7 n# k str_tmp3=name1;. @2 b2 C7 P6 f- h0 @5 M6 D( J
str_tmp4=name2;2 b5 f9 O( t: m# |- `8 \! r
2 M# Z- t7 _3 }. q1 Q _variant_t var1;
7 L; v# n3 w; ~0 D CString str,str1,str2;
& l0 a: w; K6 O. I0 e7 T/ T; m3 c
; ^) A; F: w; f: n str="SELECT * FROM MATERIAL_INFO WHERE NAME=\'";: C1 H4 X2 C4 l5 U
str=str+name1;
" a4 T. ]4 C% s/ n str=str+"\' and BRAND=\'";
* D$ E0 F+ b* u' J& `# g str=str+name2;
* i! T: V% {1 A, d0 c- t; d6 |( q str=str+"\'";
/ [" J" G7 j: ~ M) g9 u& D. y
$ ~0 U3 N) J* \+ \4 K2 U if(m_DBCnt->State)& X0 \) V+ w9 m
{
( g* e$ j/ |" s+ n! X! f! y! k m_pRecordset.CreateInstance(__uuidof(Recordset));
, b. U* f2 x) d# p try
" W! r9 A* z3 c) P {: ]: g8 P5 D4 _
m_pRecordset->Open(str.GetBuffer(str.GetLength()), 0 r9 Q, P+ D# Q+ C: v
m_DBCnt.GetInterfacePtr(),
1 l' n! v. x" B/ d) B$ }# Q adOpenDynamic,) U9 V0 D4 x7 _" P8 L6 ]$ U
adLockOptimistic,1 J3 N, \* a n8 H
adCmdText);# s# `" g3 ?- L- ]6 r, a I
* |' X/ H7 ^0 _ if(!m_pRecordset->adoEOF)
& f7 ^9 D( k4 h3 L( F. ~ var1=m_pRecordset->GetCollect("IID");4 {/ ?9 `% a$ L% G/ Z
if(var1.vt != VT_NULL)# y5 t: N- s- n: T2 C" [
str1=(LPCSTR)_bstr_t(var1);/ e2 T0 N+ w" m* z% C4 [
else0 I6 B! Q( S) _. v( F; |4 q5 e
str1="";
) S' h* x0 h; r. b+ \1 W a- l str_tmp1=str1;
8 t: }% y3 R* C9 j7 |; u8 p6 f/ z& ~/ i- Y, `- c5 {5 X2 i; e* R4 I
if(!m_pRecordset->adoEOF) * }! h/ O9 F, n- W6 b4 {
var1=m_pRecordset->GetCollect("GB_CODE");
3 }5 d, |' g" V' r6 M; g F+ [ if(var1.vt != VT_NULL)- D5 @1 L) r+ [' r5 q
str1=(LPCSTR)_bstr_t(var1);
" ]! U2 V e q7 T- @/ K/ ? else
. @2 R+ y0 S4 g# R str1="";2 c4 ?0 t8 j, t
if(!m_pRecordset->adoEOF)% {2 B0 o- F) W# Y0 z
var1=m_pRecordset->GetCollect("NOTE");
& k% k. c* g% A7 `' F if(var1.vt != VT_NULL)
_3 M0 }) M+ I8 j# [ str2=(LPCSTR)_bstr_t(var1);
3 t" R; g9 R1 Y else
# X: V0 g& }, ?% Z6 q4 ?- x @5 ?, r str2="";
/ \5 d, u6 @$ H" H% @ }8 V- v) |0 |" [. P
catch(_com_error *e)
' O2 }: X" R8 R" t8 @! }5 n {
, I) d9 M4 r8 {. x" z AfxMessageBox(e->ErrorMessage());
; R: z) K/ A' s* G }6 \+ a" p% x- b! U0 O) W
m_pRecordset->Close();" I3 E$ n( s3 Z1 c/ h
}: y, C4 d5 F, u4 s7 x3 Z* F
' r, p- U% F7 @0 J4 s% n( r2 K n
//显示国标代号+ ?! ]8 |+ `# N, o: R: Q
//显示备注
. a- J& c$ U1 H8 ^8 F item_data.item_id=MAO_STD_NO1;5 `! ~. f+ Z9 Y' s g
item_data.item_attr=UF_STYLER_VALUE;# Q1 { {: x$ ^. _$ t) ^
item_data.value.integer=TRUE;9 e( {9 a0 j& u
item_data.count=1;. z8 ^/ @" b; H& _" ~( c5 M2 g# F
item_data.value.string=str1.GetBuffer(str1.GetLength());; `9 t- B9 ~" O2 q& X$ \, x+ P( H6 H
UF_STYLER_set_value(dialog_id, &item_data);# y6 q1 M5 c; o2 q
+ v% `) \; `3 w$ T4 }
item_data.item_id=MAO_NOTE;+ T1 V0 Q$ P! c$ v$ s& j/ q0 p% h
item_data.item_attr=UF_STYLER_VALUE;& X) q6 |; n% J) V0 B! A; g
item_data.value.integer=TRUE;
" i+ ^* b: c" T: C; U" l/ G" n item_data.count=1;# ^0 {5 M2 S: v2 m3 F
item_data.value.string=str2.GetBuffer(str2.GetLength());2 R& W0 l- q) N( C
UF_STYLER_set_value(dialog_id, &item_data);
, y: M# D0 @8 P- P( N) h# D
" n E7 I/ H2 R str_tmp5=str1;6 W6 F8 a; q: k7 E! S2 t
str_tmp6=str2;
% M$ Z$ M M- @* p+ o4 V7 X5 y0 b" i, V
UF_terminate ();! S- ?' E1 _7 r1 b- c8 Y( Q0 Y8 x
) _9 D$ \' P2 z! n( C0 N7 R /* Callback acknowledged, do not terminate dialog *// J" i6 o, j& f
return (UF_UI_CB_CONTINUE_DIALOG); 2 y" A4 ~6 n4 T& s
# A* u: [. ?4 B# l+ R: k8 B/ X
/* or Callback acknowledged, terminate dialog. */
. W: Q) e2 g9 c1 n$ u0 g$ F /* return ( UF_UI_CB_EXIT_DIALOG ); */5 `% G( Y) d, F0 {; k5 K
8 d0 h8 q1 x% b! e y6 w}
1 ]% U2 _" Q# o
( {0 ~4 x: d" Y, R! d' b. N. e0 W3 p' N
/*------------------------------------------------------------*/+ T$ m+ @! k: n- w+ \) i+ q g* ~; V1 t
int MAO_btn_cb ( int dialog_id,
5 P5 u) w8 i: V# J W void * client_data,$ ~7 f3 M; z$ n' ] _0 ]
UF_STYLER_item_value_type_p_t callback_data)3 I7 o( I0 |4 `2 F# u V2 b
{" {- s( C H! k6 g4 b
UF_STYLER_item_value_type_t item_data,item_data1;" X" P: `6 e5 I* O0 e. v
/* Make sure User Function is available. */ / [ W" o# Q- q% D, }2 y- t
if ( UF_initialize() != 0) 7 z3 C! N) k/ s2 |' r0 ?
return ( UF_UI_CB_CONTINUE_DIALOG );
8 p; X4 R3 F9 R; }5 x* t
& c" Q/ H1 W+ H5 \5 A3 g/ H /* ---- Enter your callback code here ----- */
3 ?1 J, a! x; v; K1 Y5 @ i, c1 G, F( G# @7 R0 Q
_variant_t var;
* g, b2 j9 L/ d2 { CString str,str0;! F3 i/ U& e4 B$ s8 \
% P5 \) v3 Y$ n5 j//获取按钮的索引值6 _) C; t' d2 r' u, G; p
int BtnNdx;
% v' w4 X+ M, `% W+ F8 Q item_data.item_attr=UF_STYLER_VALUE; % r( x1 F" D- l0 b5 A B, J/ ^
item_data.item_id=MAO_BTN;
& b- I/ `0 \# J% \$ l3 I item_data.indicator=UF_STYLER_INTEGER_VALUE;
/ p1 e' A& U# O6 b/ o1 K" V UF_STYLER_ask_value(dialog_id, &item_data);
1 U/ {8 m4 a$ p7 U BtnNdx=item_data.value.integer;
6 u2 r7 ^( Q) _5 G2 A5 ^0 C2 G
2 }! t! |8 `) g2 k' z//添加新材料
) w( u' ]) F% @4 P( [3 _* T if(BtnNdx==0)% x, w! w# h( O# x/ d/ x0 S
{
9 @. G m& f* D/ ?. j. J$ } add_mark=1;- c8 P# ]3 r. K" s, z" T4 `" _0 Z
( L1 z2 `: {* p8 v! y
//点击添加后,清空输入框中的内容' U) d# e2 M9 r; W* I
item_data.item_id=MAO_PARTNAME; //零件类名称
! B3 C2 ^7 Y# `6 M% j item_data.item_attr=UF_STYLER_VALUE;
6 X' ^! g9 t" ]' g item_data.value.integer=FALSE;
3 e1 J: h. U' f) b; F6 Z8 Q UF_STYLER_set_value(dialog_id, &item_data);
" z8 x+ \6 N( w$ R item_data.value.integer=TRUE;
$ Q# @0 S& H9 B" q UF_STYLER_set_value(dialog_id, &item_data);2 Z' t! D# W v( p/ e
" }4 q, I6 F/ y$ f/ x
item_data.item_id=MAO_NO; //零件牌号
m# @7 ?. E. I' f- @ item_data.item_attr=UF_STYLER_VALUE;
- V. v2 T+ t% U; R `& D. Y item_data.value.integer=FALSE;! @5 x4 Y, ?6 `3 z) `2 k
UF_STYLER_set_value(dialog_id, &item_data);
; V. p9 g# n# {# s) o. ^1 z }7 Q item_data.value.integer=TRUE;
' y4 f$ ~+ t2 Y, D/ J5 p# D0 Z+ ^7 `. ?
item_data.item_id=MAO_STD_NO1; //标准代号
4 N2 a/ a$ X7 k3 W* R& _ item_data.item_attr=UF_STYLER_VALUE;
9 K8 Y; X5 }, v3 A5 G0 e; N0 d, c item_data.value.integer=FALSE;
2 k1 e) j$ G2 M2 K& _ UF_STYLER_set_value(dialog_id, &item_data);, p; X; M1 K9 a! [& O( |" ]3 g, u
item_data.value.integer=TRUE;! \6 r% X$ l. Z m- G
% D+ Z$ K8 h" q# t. l, L2 w
item_data.item_id=MAO_NOTE; //备注
4 |6 e2 y* b7 f8 S item_data.item_attr=UF_STYLER_VALUE;- j0 i1 v* G* }( S2 g
item_data.value.integer=FALSE;7 L- `6 Q) _+ r5 V [: Y8 c
UF_STYLER_set_value(dialog_id, &item_data);) a: P, {0 I7 w1 Y/ u/ M: U) q
item_data.value.integer=TRUE;
5 F6 P) ^8 X. v: n$ U5 ~4 Q9 p3 ^ }' j- C( g3 L2 }# S7 ~3 l
% @+ C/ n0 s5 j4 c/ z
//保存修改后的信息
2 D& P' }1 V' ~+ g8 k1 q! E! ^5 Z if(BtnNdx==1)% h$ S6 |8 {7 V& H
{
4 Z/ |( M, O0 |9 I$ ^5 N char temp1[80]="",temp2[80]="",temp3[80]="";+ O) ?& D, Y/ Z3 |" W4 a5 b; A
char temp4[40]="",temp5[200]="";
& C1 ^# r0 h# W( x( u- n6 W* _8 U! J) ?, c/ v5 z% c
//获取当前输入框中的信息5 ]: T: T f& ^
item_data.item_id=MAO_NAME;
$ `, A6 ^9 \# Q# A. s item_data.item_attr=UF_STYLER_VALUE; / x4 S9 ]3 k, k# e& C" ?. {
item_data.indicator=UF_STYLER_STRING_VALUE;
: Z H- n X9 o- d" z UF_STYLER_ask_value(dialog_id, &item_data); 9 t9 ]( k0 j; }3 o+ I0 V% t
strcpy(temp1,item_data.value.string);% ]" w! O: l8 j# X$ y1 f9 d8 \
3 H- F$ C6 e5 d item_data.item_id=MAO_PARTNAME;
1 @4 u& b4 A# v$ d item_data.item_attr=UF_STYLER_VALUE;
, S4 p* H" `$ W1 G( l! z$ V% ` item_data.indicator=UF_STYLER_STRING_VALUE; ' D8 @! a1 A! u% c1 v# s5 a+ G
UF_STYLER_ask_value(dialog_id, &item_data); 9 @6 \* ^" p- ^0 H- l* z
strcpy(temp2,item_data.value.string);
6 n; s! d2 m4 m/ |' m7 Q
g# h3 K1 ^: E: U& V7 j item_data.item_id=MAO_NO;8 Q/ V, l$ V6 E8 v8 n9 \1 M" H
item_data.item_attr=UF_STYLER_VALUE; 8 B9 W1 ]; c) |' x# M
item_data.indicator=UF_STYLER_STRING_VALUE;
) I0 `: U6 l. {2 T* C UF_STYLER_ask_value(dialog_id, &item_data);
4 a; r4 m H6 G) ~ strcpy(temp3,item_data.value.string);: z; _! `' Y. b
6 C3 v' _- l, g item_data.item_id=MAO_STD_NO1;# x2 y4 ~$ W- E Y8 U7 n. u H) `. K
item_data.item_attr=UF_STYLER_VALUE;
% W% s4 X3 E( f" z- @ item_data.indicator=UF_STYLER_STRING_VALUE;
: |3 n$ Z* }9 {9 A7 _( n$ ~- B UF_STYLER_ask_value(dialog_id, &item_data);
' r l8 S0 g4 q' f" q5 I% d strcpy(temp4,item_data.value.string);% {3 c( c) n% A. G8 b9 `
* N* u8 d1 p2 {. i+ ? item_data.item_id=MAO_NOTE;$ Z& i7 k% t$ P3 }2 l, Q
item_data.item_attr=UF_STYLER_VALUE;
: ~# Y# L/ F3 U: | item_data.indicator=UF_STYLER_STRING_VALUE; + q+ Z) L: T3 B. y1 _ Q3 P! R
UF_STYLER_ask_value(dialog_id, &item_data); 5 S% g' T+ U# ^" o( R2 W2 s( I- w9 p5 {
strcpy(temp5,item_data.value.string);! n; d+ F6 _) E# B
/ H. n5 I* w f if (add_mark!=1)( G( [! Q& }/ D" k: |0 D4 c I. h- U
{
% ?1 U/ j2 z+ ]2 q if((strcmp(str_tmp2,temp1)==0)&&(strcmp(str_tmp3,temp2)==0)&&
4 `9 W7 B( m l. e5 @- d (strcmp(str_tmp4,temp3)==0)&&(strcmp(str_tmp5,temp4)==0)&&
' E; G6 ^' ~- {8 L+ n% x (strcmp(str_tmp6,temp5)==0))
( P! e7 s( [. _0 \1 G @ {
3 i. s6 b. c8 x8 Z- j return (UF_UI_CB_CONTINUE_DIALOG);0 l; |# Q5 U4 A3 i$ X- m( }
}
/ Z3 A. I& u3 p) }6 ~( G else
9 z$ @ q; ]0 a& G6 L {. }; l3 u7 _( W; M; ]; d
int info;
# X2 s H( ?" X1 t/ q info=MessageBox(NULL,"纪录已经改变,是否保存?","信息提示",MB_YESNO);) x; ]: L. [. q. ^$ a) ?! K
if(info==7). b7 |: p B/ ^9 _4 B# r
return ( UF_UI_CB_CONTINUE_DIALOG );6 m8 W- V) o' f" _
//如果选择"是",则保存修改后的信息
: }1 u9 E: x1 g 5 o' M: e) W7 R
if(temp1[0]==NULL)/ j& k3 v' W! C l
{
0 |' u) `9 D% ` uc1601("材料类别不能为空!",1);
; j; L; l0 K5 { k return (UF_UI_CB_CONTINUE_DIALOG);# r( u' Y' [6 E9 \
}; L8 c$ L/ q) a& j6 m8 X3 V
; Z) }; h; p. }1 r% U7 n str="SELECT NAME,BRAND FROM MATERIAL_INFO WHERE NAME=\'";! E% P' o+ u& u
str=str+str_tmp3;& B! D" K5 K# I8 }2 A
str=str+"\' and BRAND=\'";6 B5 ]2 w' b7 J q" t
str=str+str_tmp3;+ c! `8 v' Z8 f( `# Q- ~1 t; E; \$ ~
str=str+"\'";
, C6 d5 n7 s) \5 a3 t5 l( z5 w
7 O' T! o; U$ j e8 l if(m_DBCnt->State)
- Z7 W6 ?5 `1 a2 K$ n3 I {
: t9 Y7 O- s. b/ k0 o m_pRecordset.CreateInstance(__uuidof(Recordset));' n! \. l6 {! U0 U5 v% k( q# g
try" j. e& n3 `- B6 P* g% Z! N; C3 g ?
{
$ O# Z5 J( O$ ~3 Q ^9 q0 ? m_pRecordset->Open(str.GetBuffer(str.GetLength()), 6 j& C+ w8 }1 Q- O8 r
m_DBCnt.GetInterfacePtr(),9 M2 T" q4 D4 ^
adOpenDynamic,
! G& _4 t& n3 J+ ^, b& I/ V: B adLockOptimistic,5 I6 w* u, D) g W7 _6 Y
adCmdText);0 a& p2 x6 Y* {* e; q3 X9 x
}
6 @1 T' C+ ^6 p* g5 e4 Z/ ] catch(_com_error *e). p8 G# G3 l- R1 ^9 i$ o
{& S* W7 e2 V2 }* c7 [
AfxMessageBox(e->ErrorMessage());
& m/ r% @0 o/ W3 f8 v }
+ V1 {* y5 H F1 M9 ]8 R// if(DbType=='2')
2 A" z0 X& O2 K% M% Q3 V* G {
/ p. s3 N$ z# \! j% N: U/ | str="DELETE FROM MATERIAL_INFO WHERE IID=";
4 Q0 E6 A7 }8 f str=str+str_tmp1;% T4 u8 ~" \8 o$ l+ i$ M$ o
try. M* z E9 K% S0 R# E& p
{: k5 F& x6 E1 p5 {
m_DBCnt->Execute(str.GetBuffer(str.GetLength()),NULL,adCmdText);! o) ?; j( x0 `% Z1 D/ r- c
m_DBCnt->Execute(L"COMMIT",NULL,adCmdText);4 X+ m' J: I) e
}. C2 I' I4 s3 j# {8 ]5 }
catch(_com_error& e)
+ R$ V8 C9 Y7 R* k2 Y* R3 q! e {0 M n, g" B$ R: T, o
}5 U9 v$ }" M' H* w$ x4 d0 I
str="INSERT INTO MATERIAL_INFO VALUES(";
1 r# ]4 {9 H9 e7 J, G( n str=str+str_tmp1;
/ S q% v5 Y" v p: v# S( N str=str+",\'";$ F$ G8 P# l: z. S
str=str+temp1+"\',\'"+temp2+"\',\'"+temp3+"\',\'"+temp4+"\',\'"+temp5+"\')";
2 w4 }; @6 j& [7 ~: {8 _4 Z }# M; h9 A+ s: m( Z9 d' a7 u8 W( X4 R
try' g# b' L1 d9 O7 d, _# [* f6 H8 ~
{
+ G8 {: B9 z9 `! R' F m_DBCnt->Execute(str.GetBuffer(str.GetLength()),NULL,adCmdText);+ _% F' q1 W' |% c
m_DBCnt->Execute(L"COMMIT",NULL,adCmdText);# K) T3 A: Z0 S% ^/ p
} ' ^# l; g/ w5 k
catch(_com_error &e)1 X1 i& E% E: R4 ~$ r
{
7 x+ b2 l) X1 A5 g9 i6 W! s8 C // AfxMessageBox(e.ErrorMessage());1 x# o8 ]( B/ ? [) u. ?
}
0 K- f% p1 S) W: f* J* R. u) e3 N' L3 x/ b7 ~) [; @
AfxMessageBox("修改成功!");
4 J; e) R; u4 C; p! j }
$ x: P4 d' z3 O1 A6 K' A# A4 s( X3 K
if(m_DBCnt->State)
; d7 g1 a$ c6 t5 m {
; y5 K/ l* {! Y6 p m_pRecordset.CreateInstance(__uuidof(Recordset));( o- J6 c8 q+ B0 G
try9 V; w. `9 h# v9 \
{
5 R: h5 W2 d) d3 D+ ?7 G/ ]% p m_pRecordset->Open("SELECT * FROM MATERIAL_INFO ORDER BY IID ASC",! Z4 J7 ^$ w8 c- r1 @
m_DBCnt.GetInterfacePtr(),; D5 W1 h) v& v4 ?4 o9 @
adOpenDynamic,) Z( J5 }9 i6 g1 E% c& v- i ^
adLockOptimistic,
7 y9 l6 X2 z$ y# X8 n adCmdText);; h- G9 g) A6 q0 K. X
}
j0 o4 K' W4 K6 Q" M/ d9 _+ ?! A catch(_com_error *e)% B- s& c3 P9 |5 W ]
{
9 S. U* x* i$ \- H# r; n AfxMessageBox(e->ErrorMessage());
1 k% s0 L, h5 q }
% P: q3 @ ?2 ` F( ?' ] }% l. e% `, D8 b2 k0 F7 H. M6 k
}}! |8 f$ z8 t( F+ Q6 c
//点击过添加按钮,现在保存的是新添加的记录,保存完成后将添加标记add_mark=02 E/ g# H+ z1 M) i8 S/ g5 R! k
if (add_mark==1)
8 w& i3 @& y1 A/ o" [ { i8 x: {. ]. R$ `/ \2 h) t
if(temp1[0]==NULL): {5 o6 c+ X# i
{
/ W+ J4 G$ O7 ~# W: W7 ^ uc1601("材料类别不能为空!",1);
$ v$ ^+ n; p% j1 K* I6 t return (UF_UI_CB_CONTINUE_DIALOG);
{. H& F5 e2 B! ?& y) k }
* s* i4 R) \( L, X. d //确定当前表中的最大ID号: c% U- D+ A! z
//select MAX(IID) from MATERIAL_INFO
2 D% n% z2 I% ~ if(m_DBCnt->State)
' u: n2 G9 ~( X/ j8 H8 W' a, z {
5 z) A+ |6 E/ l9 ?4 r& ~ a5 D; R m_pRecordset.CreateInstance(__uuidof(Recordset));
5 @) Q7 t: z# b( ?9 F try# b4 Y) Q& R" U- Z( H2 A
{, M! w+ }1 P! k5 J/ U1 J/ f% c
m_pRecordset->Open("SELECT * FROM MATERIAL_INFO ORDER BY IID DESC",4 O* K# O9 y; J9 r" E- O
m_DBCnt.GetInterfacePtr(),, h) n$ ]( o; b( R( ]+ Y) M; Q
adOpenDynamic,# S: \ E3 G3 A3 G
adLockOptimistic,$ ?% n5 b; X; c' s F+ T& m
adCmdText);3 I9 C+ }& P3 m5 |5 q! N0 B
}7 `% l) Z$ [2 `( w
catch(_com_error *e)6 `3 c+ l2 E6 _5 S; q
{
/ Y) w$ n# t6 N, j AfxMessageBox(e->ErrorMessage());5 |, [& H8 S3 ~6 ~ I! j
}# ?2 `8 k; J( M
}
4 _7 E" b1 d$ ] try
- k2 E- A# F. l1 Z) ?" V6 x4 Z {
' x" t% v5 h! D1 {# \: c* | | if(!m_pRecordset->adoEOF)
% d9 { A3 K; ] {9 K6 c0 t; k! x' ~) s4 V0 j) v8 ^
var = m_pRecordset->GetCollect("IID");
* b4 c; {( {1 P/ J if(var.vt != VT_NULL)- g$ N: H, u) c
str=(LPCSTR)_bstr_t(var);4 J3 [8 S4 [; l+ L
else: B. D# S3 B( Z' F* u
str="";
4 Q' s' f' C/ ~5 O& W }" A) \' a) x+ l$ f$ u1 d
}
6 h- h5 h& C& G- X catch(_com_error& e)9 R- V/ O2 Q E" O' T6 ?6 W: H* ]
{0 ^( X( j% {2 Y9 K: n8 S4 [
AfxMessageBox(e.ErrorMessage());" ^8 S, p: x6 e# R9 g+ d; H& d; q6 }
} `: A, Y. H- g. u1 u
6 N. T v* g: |0 ~
str0="INSERT INTO MATERIAL_INFO VALUES(";
2 @: a4 ~9 H K0 m P, c str0=str0+str; Q3 R$ ]7 L5 p
str0=str0+"+1,"; //在原有最大号上加1
. P3 P4 V* T9 L str0=str0+"\'";: @# m4 p$ i1 Y7 h: z
str0=str0+temp1;
) G! n+ S' C1 B" r str0=str0+"\',\'";( E7 G4 Q' r; t q7 ^
str0=str0+temp2;
: X5 [' g5 L7 Y, Z* }* H6 P+ w str0=str0+"\',\'";
/ ^5 f( A+ p, d8 N3 N str0=str0+temp3;
3 l. t! e- q& g) o9 K* L- b2 q str0=str0+"\',\'";
f& y& ~0 l# H+ M) Q str0=str0+temp4;
- e% j! ?% Y0 F1 r, m2 j# C str0=str0+"\',\'";
; }* ^, W9 b3 y3 p8 g2 ?1 c str0=str0+temp5;- p" |2 K+ x4 B+ j/ U
str0=str0+"\')";( I: C' @" c' C' d& i2 P) @& s6 E
' p H9 I/ @4 [: H try5 I" A- p/ L6 o* Y
{# c8 q' f. }0 G! G
m_DBCnt->Execute(str0.GetBuffer(str0.GetLength()),NULL,adCmdText);8 q# f J5 L" B/ H/ T/ o7 v. r
m_DBCnt->Execute(L"COMMIT",NULL,adCmdText);
; H; j# t3 W" t6 U/ s9 x }
5 P% [& f' n( E) e0 b6 D! W7 d catch(_com_error& e)! [0 B4 ?4 u" P; q1 V' @; I; r
{" i1 b8 x( H4 y: r" U
// AfxMessageBox(e.ErrorMessage());1 ^1 h3 P8 |0 x" M% j6 O( m. q
} 6 A/ t7 X) ^, d, ~3 _
AfxMessageBox("新记录添加成功!");
) L( l: L6 z0 G3 K( ^5 H m_pRecordset->Close();
: [7 M4 W4 R! K( N
6 `5 U/ J( X0 F$ a3 | add_mark=0;7 A8 p0 M0 v1 O$ b
//添加或修改后的保存完成,并设置add_mark为"0",即未添加状态
; G* W5 Y' \. u, B& E' r; {6 `. ^5 K% p4 c
}
8 A- u! q0 y+ l L, @$ ^/ U//下一步是刷新屏幕,将添加完后的信息重新显示在屏幕上
& d+ I" x7 ^! n1 m8 `//材料类型单选列表框4 t- Z( D$ D+ s0 q' U
item_data.item_id=MAO_MATERIAL;' s, R2 P/ ]6 i3 y& Z* B; v
item_data.item_attr=UF_STYLER_LIST_DELETE;
, H. x4 F. d$ ]/ @- J item_data.subitem_index=UF_STYLER_NO_SUB_INDEX;3 h y* e. B# H9 y6 I
item_data.count=0;
- N6 r3 K% O3 \. j) ]7 I. ^% J UF_STYLER_set_value(dialog_id, &item_data); k$ t) e1 [& k$ D9 {( q# ^
! `5 |7 T4 ?9 s1 l% ~
item_data.item_id=MAO_MATERIAL;& u) j1 C" k8 E/ t4 v! r
item_data.item_attr=UF_STYLER_LIST_INSERT;
' b! ?4 C0 C t; y; w item_data.subitem_index=UF_STYLER_NO_SUB_INDEX;
+ B7 t' t# j) Z7 ^8 W- Z0 @
" ^0 C' k( i8 y4 b8 d: X8 e" `//零件类列表框
0 A6 ]( q3 e8 g- N: c* T+ R4 _# B b item_data1.item_id=MAO_PART;
, g1 Q: X/ d( R) ^+ i item_data1.item_attr=UF_STYLER_LIST_DELETE;
8 |; V2 d. f6 D! q8 _6 f item_data1.subitem_index=UF_STYLER_NO_SUB_INDEX;
; R2 h0 X% E; _7 }5 L item_data1.count=0;
, e( f o. W7 ^. O+ c UF_STYLER_set_value(dialog_id, &item_data1);
" d0 I6 Z; p1 q8 {) a) o: |
; A. ]$ W6 r. l% f" H if(m_DBCnt->State)
' J$ `8 F( ~' P& g" O, T/ h {
' p$ C7 L9 M; D2 H) x m_pRecordset.CreateInstance(__uuidof(Recordset));
1 S" `+ g f* e8 u E$ ~ try
$ G+ c! c* W2 M5 {4 t, f; R( l {
# Z! M: V" T6 o! _; {, Q2 J5 _0 M m_pRecordset->Open("SELECT Distinct MATERIAL FROM MATERIAL_INFO",
2 ]+ r" ^5 R3 s b5 Z# r2 X9 _ m_DBCnt.GetInterfacePtr(),
: p) X4 t- Z5 g% N; P4 @- ^ adOpenDynamic,
7 k2 N9 U5 i( v1 d s8 I6 t3 F adLockOptimistic,
B" N3 d- ^& H- V: ^ adCmdText);
5 w# N2 x" a! A! n8 ^4 k try4 G! G( Z% }9 m+ H" ^& H& b& r1 r
{
- @+ g: n+ v! z8 V; c C' B while(!m_pRecordset->adoEOF)1 z9 ?7 u" u; u/ `7 L* H1 ]
{
) U4 E% M- G4 x% z: U) [) V3 \7 O9 K if(!m_pRecordset->adoEOF)
% \. b6 f7 s0 ]0 h2 Q: t var=m_pRecordset->GetCollect("MATTYPE");
: g# A& Z$ p$ `1 } if(var.vt != VT_NULL)$ f }( G+ H a1 |, H) [
{
5 N L) [3 L3 t& Y2 V3 q str=(LPCSTR)_bstr_t(var);$ h: E/ b- s6 g4 q2 M1 M
item_data.value.string=str.GetBuffer(str.GetLength());
9 J! x. U- Y* N/ ~5 s( { item_data.indicator=UF_STYLER_STRING_VALUE;
6 D* W$ E5 [) c1 |4 e UF_STYLER_set_value(dialog_id, &item_data);
" i+ Z! _* L3 K" R' u) K7 y }
/ }' G0 _) L2 O8 I( H2 B' T if(!m_pRecordset->adoEOF)! v( d$ D5 `- A. q; m, U
m_pRecordset->MoveNext();
! c# M/ x; X* s) } }
G) ^) {/ I+ \9 S9 A( g m_pRecordset->Close();
# O9 @! P" s% Z" V }5 J9 I' A) o9 z. b p1 f
catch(_com_error *e)
! q9 |4 Q u, i {
, Y4 f9 w9 b1 G7 y& b& X" n AfxMessageBox(e->ErrorMessage());
* {2 r( V- |# ? }' }( }* X7 c* l o9 W
}
3 y- A+ f' f1 z$ }1 e2 u# I- S* C catch(_com_error *e)
: d0 g9 H6 H* g E {
6 a8 z9 a7 K8 s% |) J* v AfxMessageBox(e->ErrorMessage());
4 g) t# [& n- L6 B# }5 m' ?, n: ^ }* l) o" G* _4 U$ a- d
}
9 k: J1 y& }% _2 y& {//锁定按钮6 G. h0 Q; K( b+ P! ^# C% t% z% m
item_data.item_id=MAO_BTN;
% l+ c- }8 B8 \. d! y( Z item_data.item_attr=UF_STYLER_SENSITIVITY;
' u1 E7 q; r% J item_data.subitem_index=1;
$ n( U. b: W7 R9 O4 k# B3 W item_data.value.integer=FALSE;7 t: b" y/ V; Y# Z0 \
UF_STYLER_set_value(dialog_id, &item_data);6 B1 K3 m2 ]: n& C" X
) U! H) a( x D/ s
item_data.item_id=MAO_BTN;
# T" x- R2 Q( o. m- O- D% n" v item_data.item_attr=UF_STYLER_SENSITIVITY;
9 c6 ]% j3 }9 I item_data.subitem_index=2;' F/ V9 x8 ]0 b' |0 v0 X7 V6 L
item_data.value.integer=FALSE;
g/ }% W; L3 S2 x: w: U% h; r% ] UF_STYLER_set_value(dialog_id, &item_data);
, K5 I* @6 t h: ] y5 z1 V" j6 v
}- D/ p; t, F$ Y- n
& g" f5 }; Q x
//删除材料信息$ m( q: D" H! b! T! f
if(BtnNdx==2)
$ t6 m' H3 i* _" M7 Q$ I, ] {
. U" h9 z3 n5 F+ Y% T str="DELETE FROM MATERIAL_INFO WHERE IID=";
( D1 ` ~# A5 c2 Y! O% m% _ str0="SELECT * FROM MATERIAL_INFO WHERE IID=";! ?+ R" i) n" a- ~$ ~6 F+ ~
str=str+str_tmp1;# d, ~ H; v" V% W0 a4 n/ O
str0=str0+str_tmp1;$ `5 ^; v% f; g8 ^% f$ A
7 g, g; |- Y8 u
int info=-1;
5 |) H2 O9 W K0 I/ k$ C% P info=MessageBox(NULL,"您确实要删除选中的纪录吗?","信息提示",MB_YESNO);
0 l2 B. r0 l e% ~7 \ C7 S if(info==7) //选择"否"
2 P, B* p4 w3 y$ P+ I7 r {$ c* A, p- R( ~8 P9 v5 d; o$ w7 e
return ( UF_UI_CB_CONTINUE_DIALOG );
; c' D9 q. f8 l }( `8 w; J l' D3 H
else- _5 {, O9 q( a( S
{5 N( c' W2 y0 ]' x
if(m_DBCnt->State)
# t9 _) [' K* d( ~/ l* K. U {2 a4 C6 W: C7 c1 l( R
m_pRecordset.CreateInstance(__uuidof(Recordset));$ F" n( t' w' R9 Z/ b# U1 P8 B: D
try# P; r8 s1 L* M; g E
{
4 G9 G% _: a" h: N1 X$ G m_pRecordset->Open(str0.GetBuffer(str0.GetLength()),
3 M% X) Q& V9 z& Q$ q) _# E! o4 q m_DBCnt.GetInterfacePtr(),
! F/ |4 e$ T. d! C adOpenDynamic,3 V g/ O( j4 c% x V- a6 ~# b
adLockOptimistic,2 D- J, X$ }9 a% u
adCmdText);
: h. L) O F c+ T8 {' o( k }
8 z! E' j+ V# ~$ ~# f; f( r/ s catch(_com_error *e)
( T& y" K- r7 I9 B3 t9 O+ G G6 b {5 O% s1 S" L0 l4 D7 m+ C
// AfxMessageBox(e->ErrorMessage());" w; _$ ?% h: S, u3 O) c
}1 Q, c ~% P+ e: j+ j" P5 ~8 e
try
: |3 E% |" X4 d( p) k" u) w {
. U/ J/ ~8 x+ E4 G2 _7 r. a; I/ T m_DBCnt->Execute(str.GetBuffer(str.GetLength()),NULL,adCmdText);4 p1 Q; O3 R5 l4 Y
m_DBCnt->Execute(L"COMMIT",NULL,adCmdText);1 \3 i, T) O' {* w/ b
} 2 g) B! T0 t3 @
catch(_com_error& e)" F* r6 B( E5 D- d" g
{) L, p! }7 l, I: B `2 O" I( e2 i
// AfxMessageBox(e.ErrorMessage());
, A& X, u( a0 b3 O, u } " s0 b$ O' K1 r
AfxMessageBox("删除成功!");' l& O" Y( ~0 b& n8 M
! N- I! H. R, ]7 x' l m_pRecordset->Close();
$ j8 F, h, o+ s) m! h; {" ` }2 W. N% i8 e |8 a- C
//删除成功后刷新记录显示
. W1 ~/ e ?! b9 f//材料类型单选列表框+ W) x0 b W, W# M w; u: G
item_data.item_id=MAO_MATERIAL;
" T3 {* u3 |$ H! T2 c8 C) C+ m+ J item_data.item_attr=UF_STYLER_LIST_DELETE; . o( m |. n; N4 F% e
item_data.subitem_index=UF_STYLER_NO_SUB_INDEX;
+ }. I! A1 V5 g item_data.count=0;
: [2 R8 V8 }2 d1 [+ o9 Y UF_STYLER_set_value(dialog_id, &item_data);
8 p6 w! b' r. W
& C! @8 I9 a+ v+ d( c7 B+ R( f! k item_data.item_id=MAO_MATERIAL;! E4 d+ O- f( n8 b6 `' _
item_data.item_attr=UF_STYLER_LIST_INSERT;! m5 R( z! J- {9 g- l; i6 e
item_data.subitem_index=UF_STYLER_NO_SUB_INDEX;
. s" O6 Q# x0 ^3 i% x* Y: m& w# c* k* l( c
//零件类列表框+ S0 @8 z/ p: c+ g3 A* `2 W* V( |3 n
item_data1.item_id=MAO_PART;3 h) U8 L( l& }) Q" M% H+ x
item_data1.item_attr=UF_STYLER_LIST_DELETE;
) s% X3 _$ n9 [, t# D$ d" u item_data1.subitem_index=UF_STYLER_NO_SUB_INDEX;2 M8 `0 O! N- i+ V
item_data1.count=0;
}: Y) j: n: j2 N8 U* s( R UF_STYLER_set_value(dialog_id, &item_data1);2 D3 ~! x' V8 z" }3 Q+ Y
1 c m( c% R; A
if(m_DBCnt->State)* n% j, O6 e5 P3 h3 r- f
{2 T6 h7 n' N1 I
m_pRecordset.CreateInstance(__uuidof(Recordset));: V0 w ^! i' ?7 n/ Y R
try
. { A7 E( E w& u {
* m7 t# Q! ~: g. t: ?. S$ l m_pRecordset->Open("SELECT Distinct MATERIAL FROM MATERIAL_INFO", ) ?4 s e) P5 A+ Y! b& u! K0 ?
m_DBCnt.GetInterfacePtr(),2 N8 @0 r P0 u! `# D' w* E
adOpenDynamic,9 S8 E5 L/ C- F- \& n/ }& T5 s" o& E
adLockOptimistic,' f# V; H4 W/ d# z/ W4 g
adCmdText);* T" j3 U6 o9 f+ ?% T, ~ V3 [4 ?
try
5 M6 c8 N! a" ?8 | { , _- E# C9 L3 P) w, H/ Z3 P) V
while(!m_pRecordset->adoEOF)
9 J, L+ v8 ?8 q9 |' d m2 c% x3 ` {$ M# e: [" V3 T3 P8 B
if(!m_pRecordset->adoEOF)) i6 n1 F/ |- U0 y
var=m_pRecordset->GetCollect("MATERIAL");
4 l" h; h: X1 t l' ^4 u if(var.vt != VT_NULL)
+ \/ [* ?9 ?3 R {
% d) t9 ~1 {8 H2 l( f, O5 O& z9 R str=(LPCSTR)_bstr_t(var);/ l& M4 b. V) n' |: a) \2 T+ D% k" b
item_data.value.string=str.GetBuffer(str.GetLength());
9 ]7 @$ h0 e7 j" l) l8 V2 z item_data.indicator=UF_STYLER_STRING_VALUE;+ @* m1 e! R6 y" ]* L& F
UF_STYLER_set_value(dialog_id, &item_data);- w; E5 E8 L5 e# E- ^. W
}8 q3 {% O# @) L$ o$ r: L
if(!m_pRecordset->adoEOF)
% F$ k/ B6 [. L. i6 l m_pRecordset->MoveNext();
$ t; P: P7 h, b. i8 P, U1 { }8 `3 n" [* b9 R$ ^ T4 _/ ?
m_pRecordset->Close();; j# {5 |2 K" m/ z* }
}
# P( E# D* S2 A1 v catch(_com_error *e)
0 @% }4 E- {- @+ X {
" }) Z2 [, F* S, }/ w$ W A* Q AfxMessageBox(e->ErrorMessage());' y0 r. ~7 e a: `& v# y
}) z0 A7 A* a% c4 Y. I! s
}
& H/ `% T8 E' E# M catch(_com_error *e)! D$ [, r) q! Y- q$ }
{ ! Q; J. [& ?! E+ ^
AfxMessageBox(e->ErrorMessage());
9 ]6 N( }$ I1 l. A }( ~5 t( U( |4 c5 a) X
}3 y& N. r9 |$ H% i5 e! E
//锁定按钮) H3 P: s3 R9 R# b. J% i
item_data.item_id=MAO_BTN;
" c; C; l, U Q/ A6 w9 b item_data.item_attr=UF_STYLER_SENSITIVITY;
" t. i* f1 M5 B; p# j; I C item_data.subitem_index=1;' T3 V$ R! ]/ ^9 \/ p' [
item_data.value.integer=FALSE;% V* C# D- `7 ~( ?0 W' O
UF_STYLER_set_value(dialog_id, &item_data);/ `& d9 B( D, v; K {
% Z' A( h, x) X* t7 p2 ~. i3 N item_data.item_id=MAO_BTN;
2 ^9 E$ V& E$ u% t item_data.item_attr=UF_STYLER_SENSITIVITY;
# i7 S9 H. @" g7 \ item_data.subitem_index=2;
3 P) y" l k+ g* j item_data.value.integer=FALSE;9 M, |" M* I! d( |6 L. z& T
UF_STYLER_set_value(dialog_id, &item_data);
! @% t; |4 J8 \0 Q8 M( Y, r1 O3 o* g# e% e
}
; ?- W# l& w, o4 T }
7 l, t9 E# |+ ]! ]) T" w: V2 b6 n r$ r) z( h; W
//帮助信息$ I9 ^ D% f( a1 m ^' d
if(BtnNdx==3)
( B3 M7 G- V' v {! n: A9 g4 T/ x
char nc_env[100]="",hlp_path[100]="";
0 H* t- w* f6 { strcpy(nc_env,getenv("UGII_USER_DIR"));
: N; f% ?8 Q2 y" d; l& t W0 I strcpy(hlp_path,nc_env);
$ n" i! W3 W9 F: \ strcat(nc_env,"\\Help\\iexplore.exe");3 M2 _( Q" f0 j( s
strcat(hlp_path,"\\Help\\MaterialInfo.htm");, }& _4 M/ v$ U w
Z2 W3 s1 n! S' \! L/ H6 S
spawnl(1,nc_env,nc_env,hlp_path,NULL);
0 I, [. }( k! q }
# f0 G7 P7 d, \4 G. o" {, ~' c# w6 @" y
//退出
) g) ~( \5 b$ J1 m/ ^ if(BtnNdx==4)
: K4 P) _/ R0 C' F9 R {& p$ [0 b; N2 {
return ( UF_UI_CB_EXIT_DIALOG );
' m$ E# L' Z" F+ w. v }5 M0 I q, y4 Z5 b
6 ~+ ^* j" z v
//IID,MATERIAL,NAME,BRAND,GB_CODE,NOTE;
% @( e, F% m$ M* G Q1 {' M//MAT_NAME,MAT_PARTNAME,MAT_NO,MAT_STD_NO1,MAT_NOTE5 L- }3 G4 C/ ^
//按钮:添加,保存,删除,帮助,退出
1 S- [% M7 n' O; l- R6 _ UF_terminate ();3 \( R: @( c/ P; _' K0 S
3 W$ \9 N$ T/ n
/* Callback acknowledged, do not terminate dialog */! j( g% o* Z( t; \
return (UF_UI_CB_CONTINUE_DIALOG); 1 F/ b% b* N0 ]$ q$ b
+ v" C; ?8 V# d' \ /* or Callback acknowledged, terminate dialog. */- T! A7 F+ L, M; O# g
/* return ( UF_UI_CB_EXIT_DIALOG ); */
9 M2 a8 p1 ?( N3 r+ h5 w' c6 J4 J% n! R. @& @) k" X2 e1 v7 a
}, L6 d- f7 E$ ^
7 h1 J9 g8 W, X; T
) E) F% Q6 s' O
|
|