關於MEMO資料新增至DB |
答題得分者是:st33chen
|
hsiuchih
一般會員 發表:6 回覆:10 積分:3 註冊:2004-04-20 發送簡訊給我 |
就是我在程式上放了一個ComboBox和一個Memo,
當USERS挑了ComboBox中的某個選項時, 我會把ComboBox裡的選項塞到Memo裡面去, 然後USERS接著在他們挑的選項下繼續打裡面的內容, 這樣的動作他們可一直重複做,不管幾次都行, 等到USERS按了確定的Button之後,就得把這些內容存到資料庫去。 市場資訊 1、10月採購需求200mt,ideal price 300系跌7元/kg ,400系跌4元/kg 2、觀察報價動作再行回覆 3、跌幅比照辦理 競爭者資訊 1、304J3/304HC/304M/304M4/302HQ: 110/108/105/101/126 2、比照辦理 現在問題來了,就是針對Memo裡面的這些資料, 我該如何分類的存進資料庫去呢? 我的資料庫欄位設計分別是, Summary_type(分類大綱) visit_Summary(內容) 競爭者資訊 1、燁興304J3/304HC/304M/304M4/302HQ: 110/108/105/101/126 2、力常跌幅比照辦理 市場資訊 1、10月採購需求200mt,ideal price 300系跌7元/kg ,400系跌4元/kg2、觀察YH報價動作再行回覆3、力常跌幅比照辦理 就是這個問題,想請問大家了! 編輯記錄
hsiuchih 重新編輯於 2008-10-23 11:23:04, 註解 無‧
|
st33chen
尊榮會員 發表:15 回覆:591 積分:1201 註冊:2005-09-30 發送簡訊給我 |
|
hsiuchih
一般會員 發表:6 回覆:10 積分:3 註冊:2004-04-20 發送簡訊給我 |
|
st33chen
尊榮會員 發表:15 回覆:591 積分:1201 註冊:2005-09-30 發送簡訊給我 |
您好,
如果 memo 中出現的 combobox 標題獨佔一列, 且第一列就一定是標題. i i : = 0; // 傳上去後會亂掉, 所以每個字母加一空格 w h i l e i i < m e m o 1 . l i n e s . c o u n t d o b e g i n i f p o s ( m e m o 1 . l i n e s [ i i ] , c o m b o b o x 1 . i t e m s . t e x t ) > 0 t h e n b e g i n a s t r : = m e m o 1 . l i n e s [ i i ] ; // for 分類大綱 b s t r : = ' ' ; // for 內容 i i : = i i 1 ; w h i l e ( i i < m e m o 1 . l i n e s . c o u n t ) a n d ( p o s ( m e m o 1 . l i n e s [ i i ] , c o m b o b o x 1 . i t e m s . t e x t ) < = 0 ) d o b e g i n b s t r : = b s t r m e m o 1 . l i n e s [ i i ] ; i i : = i i 1 ; e n d; write _ r e c o r d _ t o _ d a t a b a s e ; e n d e l s e b e g i n i i : = i i 1; e n d; e n d; 請試一下 =================引 用 hsiuchih 文 章=================== 市場資訊 1、10月採購需求200mt,ideal price 300系跌7元/kg ,400系跌4元/kg 2、觀察報價動作再行回覆 3、跌幅比照辦理 競爭者資訊 1、304J3/304HC/304M/304M4/302HQ: 110/108/105/101/126 2、比照辦理 Summary_type(分類大綱) visit_Summary(內容) 競爭者資訊 1、燁興304J3/304HC/304M/304M4/302HQ: 110/108/105/101/126 2、力常跌幅比照辦理 市場資訊 1、10月採購需求200mt,ideal price 300系跌7元/kg ,400系跌4元/kg2、觀察YH報價動作再行回覆3、力常跌幅比照辦理 就是這個問題,想請問大家了!
------
IS IT WHAT IT IS 我是 李慕白 請倒著唸. 又想把老話拿出來說, 請用台語發音 : 專家專家全是ROBOT CAR (滷肉腳啦); 都已接手這麼久了, 績效還是那麼爛, 講話還那麼大聲. |
hsiuchih
一般會員 發表:6 回覆:10 積分:3 註冊:2004-04-20 發送簡訊給我 |
Hello...st33chen大大,您好:
我按照您教的方法去做,似乎有點問題, 程式掉進去無窮迴圈了! 我貼上程式碼,麻煩您幫小妹我看一下, 到底那邊出了問題了,不好意思, 麻煩您囉!Thanks...... 另,您的程式碼是不是少了一個end啊? [code delphi] unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, DBTables, DB; type TForm1 = class(TForm) ComboBox1: TComboBox; Memo1: TMemo; Button1: TButton; DB_YSP1: TDatabase; Query1: TQuery; UpdateSQL1: TUpdateSQL; procedure ComboBox1Change(Sender: TObject); procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.ComboBox1Change(Sender: TObject); begin Memo1.Lines.Add(ComboBox1.Text); end; procedure TForm1.Button1Click(Sender: TObject); var ii:Integer; aStr,bStr:String; begin ii:=0; while ii < Memo1.Lines.Count do begin If Pos(Memo1.Lines[ii],ComboBox1.Text) > 0 Then begin aStr:=Memo1.Lines[ii]; bStr:=''; ii:=ii 1; while (ii < Memo1.Lines.Count) and (Pos(Memo1.Lines[ii],ComboBox1.Items.Text) <= 0 ) do begin bStr:=bStr Memo1.Lines[ii]; ii:=ii 1; end; Query1.Append; Query1.FieldByName('cust_no').AsString:='9990000000'; Query1.FieldByName('visit_date').AsString:='2008/10/22'; Query1.FieldByName('serial_no').AsString:='1'; Query1.FieldByName('summary_type').AsString:=aStr; Query1.FieldByName('visit_summary').AsString:=bStr; DB_YSP1.StartTransaction; Try Query1.ApplyUpdates; DB_YSP1.Commit; Except DB_YSP1.Rollback; Raise; End; Query1.CommitUpdates; end; end; end; procedure TForm1.FormCreate(Sender: TObject); begin Query1.Close; Query1.ParamByName('cust_no').AsString:='X'; Query1.ParamByName('visit_date').AsString:='X'; Query1.ParamByName('serial_no').AsString:='X'; Query1.Prepare; Query1.Open; end; end. 市場資訊 1、10月採購需求200mt,ideal price 300系跌7元/kg ,400系跌4元/kg 2、觀察報價動作再行回覆 3、跌幅比照辦理 競爭者資訊 1、304J3/304HC/304M/304M4/302HQ: 110/108/105/101/126 2、比照辦理 Summary_type(分類大綱) visit_Summary(內容) 競爭者資訊 1、燁興304J3/304HC/304M/304M4/302HQ: 110/108/105/101/126 2、力常跌幅比照辦理 市場資訊 1、10月採購需求200mt,ideal price 300系跌7元/kg ,400系跌4元/kg2、觀察YH報價動作再行回覆3、力常跌幅比照辦理 就是這個問題,想請問大家了! [/code] ===================引 用 st33chen 文 章=================== 您好, 如果 memo 中出現的 combobox 標題獨佔一列, 且第一列就一定是標題. i i : = 0; // 傳上去後會亂掉, 所以每個字母加一空格 w h i l e i i < m e m o 1 . l i n e s . c o u n t d o b e g i n i f p o s ( m e m o 1 . l i n e s [ i i ] , c o m b o b o x 1 . i t e m s . t e x t ) > 0 t h e n b e g i n a s t r : = m e m o 1 . l i n e s [ i i ] ; // for 分類大綱 b s t r : = ' ' ; // for 內容 i i : = i i 1 ; w h i l e ( i i < m e m o 1 . l i n e s . c o u n t ) a n d ( p o s ( m e m o 1 . l i n e s [ i i ] , c o m b o b o x 1 . i t e m s . t e x t ) < = 0 ) d o b e g i n b s t r : = b s t r m e m o 1 . l i n e s [ i i ] ; i i : = i i 1 ; e n d; write _ r e c o r d _ t o _ d a t a b a s e ; e n d; 請試一下 =================引 用 hsiuchih 文 章=================== |
st33chen
尊榮會員 發表:15 回覆:591 積分:1201 註冊:2005-09-30 發送簡訊給我 |
------
IS IT WHAT IT IS 我是 李慕白 請倒著唸. 又想把老話拿出來說, 請用台語發音 : 專家專家全是ROBOT CAR (滷肉腳啦); 都已接手這麼久了, 績效還是那麼爛, 講話還那麼大聲. |
hsiuchih
一般會員 發表:6 回覆:10 積分:3 註冊:2004-04-20 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |