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