#cs ____________________________________
Au3 版本:
脚本作者:
Email:
QQ/TM:
脚本版本:
脚本功能:
#ce _______________脚本开始_________________
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <DateTimeConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#Include <GuiListView.au3>
#include <GUIListBox.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>
#include <GUIScrollBars.au3>
#include <ScrollBarConstants.au3>
Opt("GUICloseOnESC", 0)
Global $item_id,$aRow,$hQuery,$cny,$krw,$money,$get_data
Global $sql_path = @ScriptDir & "\",$sql_name = $sql_path & "代购.db"
_SQLite_Startup()
If Not FileExists($sql_name) Then
_sql_create()
EndIf
_main_gui()
Func _main_gui()
$gui = GUICreate("代购江湖一览",@DesktopWidth,@DesktopHeight-100)
GUISetBkColor(0xf58f98,$gui)
$cny_value = GUICtrlCreateInput(" 1",20,16,50,25)
GUICtrlSetFont(-1,14)
GUICtrlSetLimit(-1,1)
$cny = StringStripWS(GUICtrlRead($cny_value),8)
GUICtrlSetState(-1,$GUI_DISABLE)
GUICtrlCreateLabel("人民币",80,20,60)
GUICtrlSetFont(-1,12)
GUICtrlCreateLabel("(CNY<=>KRW)",140,20,85)
GUICtrlSetFont(-1,12)
$krw_input = GUICtrlCreateInput("181.6000",230,16,100,25)
GUICtrlSetFont(-1,14)
GUICtrlSetLimit(-1,8)
$krw = StringStripWS(GUICtrlRead($krw_input),8)
GUICtrlCreateLabel("韩币",340,20,60)
GUICtrlSetFont(-1,12)
$buy_btn = GUICtrlCreateButton("预定信息",410,16,100,30)
GUICtrlSetFont(-1,12)
$user_btn = GUICtrlCreateButton("用户信息",530,16,100,30)
GUICtrlSetFont(-1,12)
$brand_btn = GUICtrlCreateButton("品牌信息",650,16,100,30)
GUICtrlSetFont(-1,12)
GUICtrlCreateLabel("赚了:",800,12,83,50)
GUICtrlSetFont(-1,25)
$money = GUICtrlCreateLabel("",883,16,300,40)
GUICtrlSetFont(-1,12)
$date_check = GUICtrlCreateCheckbox("",20,66,20,25)
GUICtrlCreateLabel("日期:",40,70,50)
GUICtrlSetFont(-1,14)
$date = GUICtrlCreateDate("", 100, 68, 120, 25, $DTS_SHORTDATEFORMAT)
GUICtrlSetFont(-1,14)
$user_check = GUICtrlCreateCheckbox("",240,66,20,25)
GUICtrlCreateLabel("购买人:",260,70,70)
GUICtrlSetFont(-1,14)
$user_name = GUICtrlCreateInput("",330,67,120,25)
GUICtrlSetFont(-1,14)
$pay_check = GUICtrlCreateCheckbox("",465,66,20,25)
GUICtrlCreateGroup("是否结账",490,55,140,45)
GUICtrlSetBkColor(-1,0xffce7b)
$yes_pay = GUICtrlCreateRadio("是",510,70,40)
GUICtrlSetFont(-1,12)
$no_pay = GUICtrlCreateRadio("否",570,70,40)
GUICtrlSetFont(-1,12)
GUICtrlSetState($no_pay, $GUI_CHECKED)
$deliver_check = GUICtrlCreateCheckbox("",640,66,20,25)
GUICtrlCreateGroup("是否发货",660,55,140,45)
GUICtrlSetBkColor(-1,0xffce7b)
$yes_deliver = GUICtrlCreateRadio("是",680,70,40)
GUICtrlSetFont(-1,12)
$no_deliver = GUICtrlCreateRadio("否",740,70,40)
GUICtrlSetFont(-1,12)
GUICtrlSetState($no_deliver, $GUI_CHECKED)
$success_check = GUICtrlCreateCheckbox("",810,66,20,25)
GUICtrlCreateGroup("是否交易成功",830,55,140,45)
GUICtrlSetBkColor(-1,0xffce7b)
$yes_success = GUICtrlCreateRadio("是",850,70,40)
GUICtrlSetFont(-1,12)
$no_success = GUICtrlCreateRadio("否",910,70,40)
GUICtrlSetFont(-1,12)
GUICtrlSetState($no_success, $GUI_CHECKED)
$user_item_btn = GUICtrlCreateButton(" 搜索 ",980,68,60,30)
GUICtrlSetFont(-1,12)
$show_state_btn = GUICtrlCreateButton("状态显示",1060,68,100,30)
GUICtrlSetFont(-1,12)
GUICtrlSetState($show_state_btn,$GUI_DISABLE)
$main_listbox = GUICtrlCreateListView("", 10, 110, @DesktopWidth-20, @DesktopHeight-220, 0x0010)
GUICtrlSetFont(-1,14)
_GUICtrlListView_AddColumn($main_listbox, " ID", 45, 0)
_GUICtrlListView_AddColumn($main_listbox, "购买人 ", 115, 1)
_GUICtrlListView_AddColumn($main_listbox, "手机 ", 110, 1)
_GUICtrlListView_AddColumn($main_listbox, "品牌 ", 100, 1)
_GUICtrlListView_AddColumn($main_listbox, "商品 ", 100, 1)
_GUICtrlListView_AddColumn($main_listbox, "购买价格 ", 115, 1)
_GUICtrlListView_AddColumn($main_listbox, "购买数量 ", 115, 1)
_GUICtrlListView_AddColumn($main_listbox, "订购时间 ", 115, 1)
_GUICtrlListView_AddColumn($main_listbox, "是否结账 ", 115, 1)
_GUICtrlListView_AddColumn($main_listbox, "是否发货 ", 115, 1)
_GUICtrlListView_AddColumn($main_listbox, "发货时间 ", 115, 1)
_GUICtrlListView_AddColumn($main_listbox, "是否成功交易", 120, 1)
_find_all_user_buy_item_info($main_listbox)
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $msg
Case $user_btn
_user_info()
Case $brand_btn
_brand_info()
Case $buy_btn
_buy_item_info()
Case $user_item_btn
Local $time_from,$time_to,$user,$pay_choose,$deliver_choose,$success_choose
If BitAND(GUICtrlRead($date_check),$GUI_CHECKED) == $GUI_CHECKED Then
$today = GUICtrlRead($date)
Local $month,$day
If @OSVersion = "WIN_XP" Then
$arr = StringSplit($today,"-")
If StringLen($arr[2]) == 1 Then
$month = "0" & $arr[2]
Else
$month = $arr[2]
EndIf
If StringLen($arr[3]) == 1 Then
$day = "0" & $arr[3]
Else
$day = $arr[3]
EndIf
$today = $arr[1] & "-" & $month & "-" & $day
EndIf
If @OSVersion = "WIN_7" Then
$arr = StringSplit($today,"/")
If StringLen($arr[2]) == 1 Then
$month = "0" & $arr[2]
Else
$month = $arr[2]
EndIf
If StringLen($arr[3]) == 1 Then
$day = "0" & $arr[3]
Else
$day = $arr[3]
EndIf
$today = $arr[1] & "-" & $month & "-" & $day
EndIf
$time_from = $today & " 00:00:00"
$time_to = $today & " 23:59:59"
EndIf
If BitAND(GUICtrlRead($user_check),$GUI_CHECKED) == $GUI_CHECKED Then
$user = StringStripWS(GUICtrlRead($user_name),8)
If StringLen($user) == 0 Then
MsgBox(0,"INFO","如果勾选了,按照购买人来搜索,为啥不整个人名来试试呢?")
ContinueLoop
EndIf
EndIf
If BitAND(GUICtrlRead($pay_check),$GUI_CHECKED) == $GUI_CHECKED Then
If BitAND(GUICtrlRead($yes_pay),$GUI_CHECKED) == $GUI_CHECKED Then
$pay_choose = "1"
EndIf
If BitAND(GUICtrlRead($no_pay),$GUI_CHECKED) == $GUI_CHECKED Then
$pay_choose = "0"
EndIf
EndIf
If BitAND(GUICtrlRead($deliver_check),$GUI_CHECKED) == $GUI_CHECKED Then
If BitAND(GUICtrlRead($yes_deliver),$GUI_CHECKED) == $GUI_CHECKED Then
$deliver_choose = "1"
EndIf
If BitAND(GUICtrlRead($no_deliver),$GUI_CHECKED) == $GUI_CHECKED Then
$deliver_choose = "0"
EndIf
EndIf
If BitAND(GUICtrlRead($success_check),$GUI_CHECKED) == $GUI_CHECKED Then
If BitAND(GUICtrlRead($yes_success),$GUI_CHECKED) == $GUI_CHECKED Then
$success_choose = "1"
EndIf
If BitAND(GUICtrlRead($no_success),$GUI_CHECKED) == $GUI_CHECKED Then
$success_choose = "0"
EndIf
EndIf
$get_data = _find_user_item_by_time_name_pay_deliver_success($main_listbox,$time_from,$time_to,$user,$pay_choose,$deliver_choose,$success_choose)
If StringLen($pay_choose) == 1 Or StringLen($deliver_choose) == 1 Or StringLen($success_choose) == 1 Then
If StringLen($get_data) <> 0 Then
GUICtrlSetState($show_state_btn,$GUI_ENABLE)
Else
GUICtrlSetState($show_state_btn,$GUI_DISABLE)
EndIf
EndIf
Case $show_state_btn
_show_state_info($get_data)
$get_data = ""
GUICtrlSetState($show_state_btn,$GUI_DISABLE)
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
EndFunc
;显示查询后的状态信息
Func _show_state_info($get_data)
Local $pay_btn,$deliver_btn,$success_btn,$id
Local $arr = StringSplit($get_data,"|")
$state_gui = GUICreate("状态信息一览",500,500)
GUISetBkColor(0xf58f98,$state_gui)
For $i = 1 To $arr[0]
$info = StringSplit($arr[$i],"~")
$id[$i] = $info[1]
GUICtrlCreateLabel($info[2],30,20,100)
GUICtrlSetFont(-1,12)
GUICtrlCreateLabel($info[3],150,20,100)
GUICtrlSetFont(-1,12)
GUICtrlCreateLabel($info[4],30,20,100)
GUICtrlSetFont(-1,12)
GUICtrlCreateLabel($info[5],30,20,100)
GUICtrlSetFont(-1,12)
GUICtrlCreateLabel($info[6],30,20,100)
GUICtrlSetFont(-1,12)
GUICtrlCreateLabel($info[7],30,20,100)
GUICtrlSetFont(-1,12)
If $info[8] = "1" Then
GUICtrlCreateButton("完美付款",30,20,100)
GUICtrlSetFont(-1,12)
Else
$pay_btn[$i] = GUICtrlCreateButton("未付款",30,20,100)
GUICtrlSetFont(-1,12)
EndIf
If $info[9] = "1" Then
GUICtrlCreateButton("完美发货",30,20,100)
GUICtrlSetFont(-1,12)
Else
GUICtrlCreateButton("未发货",30,20,100)
GUICtrlSetFont(-1,12)
EndIf
If $info[10] = "1" Then
GUICtrlCreateButton("完美成交",30,20,100)
GUICtrlSetFont(-1,12)
Else
$deliver_btn[$i] = GUICtrlCreateButton("未成交",30,20,100)
GUICtrlSetFont(-1,12)
EndIf
If $info[11] = "" Then
$success_btn[$i] = GUICtrlCreateButton("选择订单",30,20,100)
GUICtrlSetFont(-1,12)
Else
$success_btn[$i] = GUICtrlCreateButton("打开订单",30,20,100)
GUICtrlSetFont(-1,12)
EndIf
Next
GUISetState()
While 1
$msg = GUIGetMsg()
For $i = 1 To $arr[0]
If $msg = $pay_btn[$i] Then
ElseIf $msg = $deliver_btn[$i] Then
ElseIf $msg = $success_btn[$i] Then
ElseIf $msg = $GUI_EVENT_CLOSE Then
ExitLoop
GUIDelete($state_gui)
EndIf
Next
WEnd
EndFunc
;品牌
Func _brand_info()
$brand_gui = GUICreate("品牌一览",550,300)
GUISetBkColor(0xf58f98,$brand_gui)
$brand_sub = GUICtrlCreateCombo("",20,13,250,45,$CBS_DROPDOWNLIST + $WS_VSCROLL)
GUICtrlSetFont(-1,12)
$brand_ok_btn = GUICtrlCreateButton(" 确定 ",330,10,60,30)
GUICtrlSetFont(-1,12)
$brand_product_btn = GUICtrlCreateButton("商品维护",430,10,80,30)
GUICtrlSetFont(-1,12)
GUICtrlCreateLabel("品牌名称:",20,60,90,20)
GUICtrlSetFont(-1,14)
$brand_name = GUICtrlCreateInput("",120,57,250,25)
GUICtrlSetFont(-1,14)
GUICtrlCreateGroup("是否启用品牌",390,50,120,40)
$y_radio = GUICtrlCreateRadio("是",410,62,35,20)
GUICtrlSetFont(-1,12)
GUICtrlSetState($y_radio, $GUI_CHECKED)
$n_radio = GUICtrlCreateRadio("否",470,62,35,20)
GUICtrlSetFont(-1,12)
GUICtrlCreateLabel("描述:",20,160,60)
GUICtrlSetFont(-1,14)
;填写描述信息
$brand_view = GUICtrlCreateEdit("",90,100,430,150,$ES_AUTOVSCROLL+$ES_WANTRETURN+$WS_VSCROLL+$ES_MULTILINE)
GUICtrlSetFont(-1,15)
$brand_update = GUICtrlCreateButton(" 修改 ",240,255,80,30)
GUICtrlSetFont(-1,12)
$brand_add = GUICtrlCreateButton(" 添加 ",340,255,80,30)
GUICtrlSetFont(-1,12)
$brand_close = GUICtrlCreateButton(" 关闭 ",440,255,80,30)
GUICtrlSetFont(-1,12)
Local $brand_id=0
;确定当前所有品牌下拉列表
If _find_brand() <> "" Then
GUICtrlSetData($brand_sub,_find_brand(),"")
EndIf
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $msg
Case $brand_ok_btn
$b_name = StringStripWS(GUICtrlRead($brand_sub),8)
If StringLen($b_name) == 0 Then
MsgBox(0,"INFO","你傻呀,倒是选择一个品牌呀!!!")
ContinueLoop
Else
_find_brand_by_name($b_name,$brand_name,$y_radio,$n_radio,$brand_view)
$brand_id = _find_brand_id_by_name($b_name)
EndIf
Case $brand_product_btn
$b_name = StringStripWS(GUICtrlRead($brand_sub),8)
If StringLen($b_name) == 0 Then
MsgBox(0,"INFO","你傻呀,没有品牌咋添加商品啊!!!")
ContinueLoop
EndIf
_product_info($b_name)
Case $brand_update
$b_name = StringStripWS(GUICtrlRead($brand_name),8)
If StringLen($b_name) == 0 Then
MsgBox(0,"INFO","一个没有名字的品牌是不会被认可的。")
ContinueLoop
EndIf
If $brand_id == 0 Then
MsgBox(0,"INFO","请在下拉框选择一个品牌,之后点击确定按钮。")
ContinueLoop
EndIf
If BitAND(GUICtrlRead($y_radio),$GUI_CHECKED) = $GUI_CHECKED Then
$choose = "1"
ElseIf BitAND(GUICtrlRead($n_radio),$GUI_CHECKED) = $GUI_CHECKED Then
$choose = "0"
Else
MsgBox(0,"INFO","系统可能中病毒了,请检查系统。")
Exit
EndIf
$description = GUICtrlRead($brand_view)
$time = @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC
$get_string = _update_brand_by_id($brand_id,$b_name,$choose,$description,$time)
MsgBox(0,"INFO",$get_string)
$brand_id = 0
GUICtrlSetData($brand_name,"")
GUICtrlSetState($y_radio,$GUI_CHECKED)
GUICtrlSetData($brand_view,"")
If _find_brand() <> "" Then
GUICtrlSetData($brand_sub,_find_brand(),"")
EndIf
Case $brand_add
$b_name = StringStripWS(GUICtrlRead($brand_name),8)
If StringLen($b_name) == 0 Then
MsgBox(0,"INFO","一个没有名字的品牌是不会被认可的。")
ContinueLoop
EndIf
If BitAND(GUICtrlRead($y_radio),$GUI_CHECKED) = $GUI_CHECKED Then
$choose = "1"
ElseIf BitAND(GUICtrlRead($n_radio),$GUI_CHECKED) = $GUI_CHECKED Then
$choose = "0"
Else
MsgBox(0,"INFO","系统可能中病毒了,请检查系统。")
Exit
EndIf
$description = GUICtrlRead($brand_view)
$time = @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC
$get_string = _brand_add($b_name,$choose,$description,$time)
MsgBox(0,"INFO",$get_string)
GUICtrlSetData($brand_name,"")
GUICtrlSetState($y_radio,$GUI_CHECKED)
GUICtrlSetData($brand_view,"")
If _find_brand() <> "" Then
GUICtrlSetData($brand_sub,_find_brand(),"")
EndIf
Case $brand_close
GUIDelete($brand_gui)
ExitLoop
Case $GUI_EVENT_CLOSE
GUIDelete($brand_gui)
ExitLoop
EndSwitch
WEnd
EndFunc
;商品
Func _product_info($b_name)
$product_gui = GUICreate("商品详情一览",650,650)
GUISetBkColor(0xf58f98,$product_gui)
GUICtrlCreateLabel("名称:",30,30,50)
GUICtrlSetFont(-1,14)
$p_name = GUICtrlCreateInput("",90,27,350,25)
GUICtrlSetFont(-1,14)
GUICtrlCreateLabel("韩国报价:",30,70,90)
GUICtrlSetFont(-1,14)
$p_kprice = GUICtrlCreateInput("",110,67,100,25)
GUICtrlSetFont(-1,14)
GUICtrlSetLimit(-1,10)
GUICtrlCreateLabel("韩元",210,70,40)
GUICtrlSetFont(-1,14)
GUICtrlCreateLabel("中国报价:",260,70,100)
GUICtrlSetFont(-1,14)
$p_cprice = GUICtrlCreateInput("",360,67,60,25)
GUICtrlSetFont(-1,14)
GUICtrlSetLimit(-1,5)
GUICtrlCreateLabel("RMB",420,70,40)
GUICtrlSetFont(-1,14)
GUICtrlCreateLabel("进货价:",30,110,70)
GUICtrlSetFont(-1,14)
$p_net_price = GUICtrlCreateInput("",110,107,100,25)
GUICtrlSetFont(-1,14)
GUICtrlSetLimit(-1,10)
GUICtrlCreateLabel("韩元",210,110,40)
GUICtrlSetFont(-1,14)
GUICtrlCreateLabel("扣价:",300,110,50)
GUICtrlSetFont(-1,14)
$p_discount = GUICtrlCreateInput("",360,107,50,25)
GUICtrlSetFont(-1,14)
GUICtrlSetLimit(-1,2)
GUICtrlCreateLabel("折",420,110,50)
GUICtrlSetFont(-1,14)
GUICtrlCreateLabel("进货数量:",30,150,100)
GUICtrlSetFont(-1,14)
$p_num = GUICtrlCreateInput("",110,147,50,25)
GUICtrlSetFont(-1,14)
GUICtrlSetLimit(-1,4)
GUICtrlCreateLabel("个",180,150,50)
GUICtrlSetFont(-1,14)
GUICtrlCreateLabel("国际运费:",265,150,90)
GUICtrlSetFont(-1,14)
$p_international_freight = GUICtrlCreateInput("",360,147,50,25)
GUICtrlSetFont(-1,14)
GUICtrlSetLimit(-1,3)
GUICtrlCreateLabel("RMB",410,150,50)
GUICtrlSetFont(-1,14)
GUICtrlCreateLabel("国内运费:",30,190,100)
GUICtrlSetFont(-1,14)
$p_internal_freight = GUICtrlCreateInput("",110,187,50,25)
GUICtrlSetFont(-1,14)
GUICtrlSetLimit(-1,4)
GUICtrlCreateLabel("RMB",180,190,50)
GUICtrlSetFont(-1,14)
GUICtrlCreateLabel("建议售价:",265,190,90)
GUICtrlSetFont(-1,14)
GUICtrlSetColor(-1,0xed1941)
$p_retail_price = GUICtrlCreateInput("",360,187,50,25)
GUICtrlSetFont(-1,14)
GUICtrlSetLimit(-1,4)
GUICtrlCreateLabel("RMB",410,190,50)
GUICtrlSetFont(-1,14)
GUICtrlCreateLabel("商品描述:",30,245,100)
GUICtrlSetFont(-1,14)
$p_view = GUICtrlCreateEdit("",120,215,320,75,$ES_AUTOVSCROLL+$ES_WANTRETURN+$WS_VSCROLL+$ES_MULTILINE)
GUICtrlSetFont(-1,15)
GUICtrlCreateLabel("ID:",30,300,30)
GUICtrlSetFont(-1,14)
$p_id = GUICtrlCreateInput("",60,297,50,25)
GUICtrlSetFont(-1,14)
GUICtrlSetLimit(-1,4)
$p_find = GUICtrlCreateButton(" 查找 ",130,297,60,25)
GUICtrlSetFont(-1,12)
$p_modify = GUICtrlCreateButton(" 修改 ",220,297,60,25)
GUICtrlSetFont(-1,12)
$p_delete = GUICtrlCreateButton(" 删除 ",310,297,60,25)
GUICtrlSetFont(-1,12)
$p_add = GUICtrlCreateButton(" 添加 ",400,297,60,25)
GUICtrlSetFont(-1,12)
$item_listbox = GUICtrlCreateListView("", 30, 330, 590, 310, 0x0010)
GUICtrlSetFont(-1,14)
_GUICtrlListView_AddColumn($item_listbox, " ID", 45, 0)
_GUICtrlListView_AddColumn($item_listbox, "名称 ", 115, 1)
_GUICtrlListView_AddColumn($item_listbox, "韩价(RMB) ", 110, 1)
_GUICtrlListView_AddColumn($item_listbox, "中价 ", 100, 1)
_GUICtrlListView_AddColumn($item_listbox, "成本 ", 100, 1)
_GUICtrlListView_AddColumn($item_listbox, "建议售价 ", 115, 1)
_GUICtrlListView_AddColumn($item_listbox, "状态", 60, 1)
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $msg
Case $p_find
$item_id = StringStripWS(GUICtrlRead($p_id),8)
If StringRegExp(GUICtrlRead($p_id),"^[1-9][0-9]{0,}",0) Then
$get_string = _find_item_by_id($item_listbox,$item_id,$p_name,$p_kprice,$p_cprice,$p_net_price,$p_discount,$p_num,$p_international_freight,$p_internal_freight,$p_retail_price,$p_view)
If StringLen($get_string) <> 1 Then
MsgBox(0,"INFO",$get_string)
EndIf
Else
_find_all_item($item_listbox)
GUICtrlSetData($p_name,"")
GUICtrlSetData($p_kprice,"")
GUICtrlSetData($p_cprice,"")
GUICtrlSetData($p_net_price,"")
GUICtrlSetData($p_discount,"")
GUICtrlSetData($p_num,"")
GUICtrlSetData($p_international_freight,"")
GUICtrlSetData($p_internal_freight,"")
GUICtrlSetData($p_retail_price,"")
GUICtrlSetData($p_view,"")
GUICtrlSetData($p_id,"")
EndIf
Case $p_modify
$item_id = StringStripWS(GUICtrlRead($p_id),8)
If StringLen($item_id) == 0 Then
MsgBox(0,"INFO","想修改一个商品,必须给出 ID 才行。")
ContinueLoop
EndIf
$item_name = StringStripWS(GUICtrlRead($p_name),8)
If StringLen($item_name) == 0 Then
MsgBox(0,"INFO","一个没有名称的商品,不科学!")
ContinueLoop
EndIf
$item_kprice = StringStripWS(GUICtrlRead($p_kprice),8)
If StringLen($item_kprice) <> 0 Then
If Not StringRegExp($item_kprice,"^[1-9][0-9]{0,}.?[0-9]{0,2}",0) Then
MsgBox(0,"INFO","亲爱的同学,你好:这里的数字应该是首字母不为0且小数点儿后两位的小数。" & _
@CRLF & @CRLF & "你看你这写的是啥呀?" & GUICtrlRead($p_kprice) & _
@CRLF & @CRLF & "你小学到底毕业没有啊?Σ( ° △ °|||)︴)")
ContinueLoop
EndIf
EndIf
$item_cprice = StringStripWS(GUICtrlRead($p_cprice),8)
If StringLen($item_cprice) <> 0 Then
If Not StringRegExp($item_cprice,"^[1-9][0-9]{0,}.?[0-9]{0,2}",0) Then
MsgBox(0,"INFO","亲爱的同学,你好:这里的数字应该是首字母不为0且小数点儿后两位的小数。" & _
@CRLF & @CRLF & "你看你这写的是啥呀? " & GUICtrlRead($p_cprice) & _
@CRLF & @CRLF & "你小学到底毕业没有啊?Σ( ° △ °|||)︴)")
ContinueLoop
EndIf
EndIf
$item_net_price = StringStripWS(GUICtrlRead($p_net_price),8)
If StringLen($item_net_price) == 0 Then
MsgBox(0,"INFO","货物进价不能为空。")
ContinueLoop
Else
If Not StringRegExp($item_net_price,"^[1-9][0-9]{0,}.?[0-9]{0,2}",0) Then
MsgBox(0,"INFO","亲爱的同学,你好:这里的数字应该是首字母不为0且小数点儿后两位的小数。" & _
@CRLF & @CRLF & "你看你这写的是啥呀? " & GUICtrlRead($p_net_price) & _
@CRLF & @CRLF & "你小学到底毕业没有啊?Σ( ° △ °|||)︴)")
ContinueLoop
EndIf
EndIf
$item_discount = StringStripWS(GUICtrlRead($p_discount),8)
If StringLen($item_discount) == 0 Then
MsgBox(0,"INFO","货物进价折扣不能为空。")
ContinueLoop
Else
If Not StringRegExp($item_discount,"^[1-9][0-9]{0,1}",0) Then
MsgBox(0,"INFO","亲爱的同学,你好:这里的数字应该是首字母不为0的数字。" & _
@CRLF & @CRLF & "你看你这写的是啥呀? " & GUICtrlRead($p_discount) & _
@CRLF & @CRLF & "你小学到底毕业没有啊?Σ( ° △ °|||)︴)")
ContinueLoop
EndIf
EndIf
$item_num = StringStripWS(GUICtrlRead($p_num),8)
If StringLen($item_num) == 0 Then
MsgBox(0,"INFO","货物数量不能为空。")
ContinueLoop
Else
If Not StringRegExp($item_num,"^[1-9][0-9]{0,}",0) Then
MsgBox(0,"INFO","亲爱的同学,你好:这里的数字应该是首字母不为0的数字。" & _
@CRLF & @CRLF & "你看你这写的是啥呀? " & GUICtrlRead($p_discount) & _
@CRLF & @CRLF & "你小学到底毕业没有啊?Σ( ° △ °|||)︴)")
ContinueLoop
EndIf
EndIf
$item_international_freight = StringStripWS(GUICtrlRead($p_international_freight),8)
If StringLen($item_international_freight) == 0 Then
MsgBox(0,"INFO","货物国际运费不能为空。")
ContinueLoop
Else
If Not StringRegExp($item_international_freight,"^[1-9][0-9]{0,}",0) Then
MsgBox(0,"INFO","亲爱的同学,你好:这里的数字应该是首字母不为0的数字。" & _
@CRLF & @CRLF & "你看你这写的是啥呀? " & GUICtrlRead($p_international_freight) & _
@CRLF & @CRLF & "你小学到底毕业没有啊?Σ( ° △ °|||)︴)")
ContinueLoop
EndIf
EndIf
$item_internal_freight = StringStripWS(GUICtrlRead($p_internal_freight),8)
If StringLen($item_internal_freight) == 0 Then
MsgBox(0,"INFO","货物国内运费不能为空,可以预估一个价格。")
ContinueLoop
Else
If Not StringRegExp($item_internal_freight,"^[1-9][0-9]{0,}",0) Then
MsgBox(0,"INFO","亲爱的同学,你好:这里的数字应该是首字母不为0的数字。" & _
@CRLF & @CRLF & "你看你这写的是啥呀? " & GUICtrlRead($p_internal_freight) & _
@CRLF & @CRLF & "你小学到底毕业没有啊?Σ( ° △ °|||)︴)")
ContinueLoop
EndIf
EndIf
$item_retail_price = StringStripWS(GUICtrlRead($p_retail_price),8)
$item_description = StringStripWS(GUICtrlRead($p_view),8)
$get_string = _update_item_by_id($item_id,$item_name,$item_kprice,$item_cprice,$item_net_price,$item_discount,$item_num,$item_international_freight,$item_internal_freight,$item_retail_price,$item_description)
MsgBox(0,"INFO",$get_string)
GUICtrlSetData($p_name,"")
GUICtrlSetData($p_kprice,"")
GUICtrlSetData($p_cprice,"")
GUICtrlSetData($p_net_price,"")
GUICtrlSetData($p_discount,"")
GUICtrlSetData($p_num,"")
GUICtrlSetData($p_international_freight,"")
GUICtrlSetData($p_internal_freight,"")
GUICtrlSetData($p_retail_price,"")
GUICtrlSetData($p_view,"")
GUICtrlSetData($p_id,"")
_find_all_item($item_listbox)
Case $p_delete
$item_id = StringStripWS(GUICtrlRead($p_id),8)
If StringLen($item_id) == 0 Then
MsgBox(0,"INFO","想删除一个商品,必须给出 ID 才行。")
ContinueLoop
Else
$get_string = _delete_item_by_id($item_id)
If StringLen($get_string) <> 1 Then
MsgBox(0,"INFO",$get_string)
EndIf
GUICtrlSetData($p_name,"")
GUICtrlSetData($p_kprice,"")
GUICtrlSetData($p_cprice,"")
GUICtrlSetData($p_net_price,"")
GUICtrlSetData($p_discount,"")
GUICtrlSetData($p_num,"")
GUICtrlSetData($p_international_freight,"")
GUICtrlSetData($p_internal_freight,"")
GUICtrlSetData($p_retail_price,"")
GUICtrlSetData($p_view,"")
GUICtrlSetData($p_id,"")
EndIf
Case $p_add
$item_name = StringStripWS(GUICtrlRead($p_name),8)
If StringLen($item_name) == 0 Then
MsgBox(0,"INFO","一个没有名称的商品,不科学!")
ContinueLoop
EndIf
$item_kprice = StringStripWS(GUICtrlRead($p_kprice),8)
If StringLen($item_kprice) <> 0 Then
If Not StringRegExp($item_kprice,"^[1-9][0-9]{0,}.?[0-9]{0,2}",0) Then
MsgBox(0,"INFO","亲爱的同学,你好:这里的数字应该是首字母不为0且小数点儿后两位的小数。" & _
@CRLF & @CRLF & "你看你这写的是啥呀?" & GUICtrlRead($p_kprice) & _
@CRLF & @CRLF & "你小学到底毕业没有啊?Σ( ° △ °|||)︴)")
ContinueLoop
EndIf
EndIf
$item_cprice = StringStripWS(GUICtrlRead($p_cprice),8)
If StringLen($item_cprice) <> 0 Then
If Not StringRegExp($item_cprice,"^[1-9][0-9]{0,}.?[0-9]{0,2}",0) Then
MsgBox(0,"INFO","亲爱的同学,你好:这里的数字应该是首字母不为0且小数点儿后两位的小数。" & _
@CRLF & @CRLF & "你看你这写的是啥呀? " & GUICtrlRead($p_cprice) & _
@CRLF & @CRLF & "你小学到底毕业没有啊?Σ( ° △ °|||)︴)")
ContinueLoop
EndIf
EndIf
$item_net_price = StringStripWS(GUICtrlRead($p_net_price),8)
If StringLen($item_net_price) == 0 Then
MsgBox(0,"INFO","货物进价不能为空。")
ContinueLoop
Else
If Not StringRegExp($item_net_price,"^[1-9][0-9]{0,}.?[0-9]{0,2}",0) Then
MsgBox(0,"INFO","亲爱的同学,你好:这里的数字应该是首字母不为0且小数点儿后两位的小数。" & _
@CRLF & @CRLF & "你看你这写的是啥呀? " & GUICtrlRead($p_net_price) & _
@CRLF & @CRLF & "你小学到底毕业没有啊?Σ( ° △ °|||)︴)")
ContinueLoop
EndIf
EndIf
$item_discount = StringStripWS(GUICtrlRead($p_discount),8)
If StringLen($item_discount) == 0 Then
MsgBox(0,"INFO","货物进价折扣不能为空。")
ContinueLoop
Else
If Not StringRegExp($item_discount,"^[1-9][0-9]{0,1}",0) Then
MsgBox(0,"INFO","亲爱的同学,你好:这里的数字应该是首字母不为0的数字。" & _
@CRLF & @CRLF & "你看你这写的是啥呀? " & GUICtrlRead($p_discount) & _
@CRLF & @CRLF & "你小学到底毕业没有啊?Σ( ° △ °|||)︴)")
ContinueLoop
EndIf
EndIf
$item_num = StringStripWS(GUICtrlRead($p_num),8)
If StringLen($item_num) == 0 Then
MsgBox(0,"INFO","货物数量不能为空。")
ContinueLoop
Else
If Not StringRegExp($item_num,"^[1-9][0-9]{0,}",0) Then
MsgBox(0,"INFO","亲爱的同学,你好:这里的数字应该是首字母不为0的数字。" & _
@CRLF & @CRLF & "你看你这写的是啥呀? " & GUICtrlRead($p_discount) & _
@CRLF & @CRLF & "你小学到底毕业没有啊?Σ( ° △ °|||)︴)")
ContinueLoop
EndIf
EndIf
$item_international_freight = StringStripWS(GUICtrlRead($p_international_freight),8)
If StringLen($item_international_freight) == 0 Then
MsgBox(0,"INFO","货物国际运费不能为空。")
ContinueLoop
Else
If Not StringRegExp($item_international_freight,"^[1-9][0-9]{0,}",0) Then
MsgBox(0,"INFO","亲爱的同学,你好:这里的数字应该是首字母不为0的数字。" & _
@CRLF & @CRLF & "你看你这写的是啥呀? " & GUICtrlRead($p_international_freight) & _
@CRLF & @CRLF & "你小学到底毕业没有啊?Σ( ° △ °|||)︴)")
ContinueLoop
EndIf
EndIf
$item_internal_freight = StringStripWS(GUICtrlRead($p_internal_freight),8)
If StringLen($item_internal_freight) == 0 Then
MsgBox(0,"INFO","货物国内运费不能为空,可以预估一个价格。")
ContinueLoop
Else
If Not StringRegExp($item_internal_freight,"^[1-9][0-9]{0,}",0) Then
MsgBox(0,"INFO","亲爱的同学,你好:这里的数字应该是首字母不为0的数字。" & _
@CRLF & @CRLF & "你看你这写的是啥呀? " & GUICtrlRead($p_internal_freight) & _
@CRLF & @CRLF & "你小学到底毕业没有啊?Σ( ° △ °|||)︴)")
ContinueLoop
EndIf
EndIf
$item_retail_price = StringStripWS(GUICtrlRead($p_retail_price),8)
$item_description = StringStripWS(GUICtrlRead($p_view),8)
$brand_id = _find_brand_id_by_name($b_name)
$get_string = _item_add($brand_id,$item_name,$item_kprice,$item_cprice,$item_net_price,$item_discount,$item_num,$item_international_freight,$item_internal_freight,$item_retail_price,$item_description)
MsgBox(0,"INFO",$get_string)
_find_all_item($item_listbox)
GUICtrlSetData($p_name,"")
GUICtrlSetData($p_kprice,"")
GUICtrlSetData($p_cprice,"")
GUICtrlSetData($p_net_price,"")
GUICtrlSetData($p_discount,"")
GUICtrlSetData($p_num,"")
GUICtrlSetData($p_international_freight,"")
GUICtrlSetData($p_internal_freight,"")
GUICtrlSetData($p_retail_price,"")
GUICtrlSetData($p_view,"")
Case $GUI_EVENT_CLOSE
GUIDelete($product_gui)
ExitLoop
EndSwitch
WEnd
EndFunc
;用户
Func _user_info()
$user_gui = GUICreate("用户详情一览",600,650)
GUISetBkColor(0xf58f98,$user_gui)
GUICtrlCreateLabel("姓名:",30,20,50)
GUICtrlSetFont(-1,14)
$u_name = GUICtrlCreateInput("",100,17,100,25)
GUICtrlSetFont(-1,14)
GUICtrlCreateLabel("手机:",240,20,50)
GUICtrlSetFont(-1,14)
$u_phone = GUICtrlCreateInput("",310,17,120,25)
GUICtrlSetFont(-1,14)
GUICtrlSetLimit(-1,11)
GUICtrlCreateLabel(" Q Q:",30,60,50)
GUICtrlSetFont(-1,14)
$u_qq = GUICtrlCreateInput("",100,57,100,25)
GUICtrlSetFont(-1,14)
GUICtrlCreateLabel("微信:",240,60,50)
GUICtrlSetFont(-1,14)
$u_weixin = GUICtrlCreateInput("",310,57,120,25)
GUICtrlSetFont(-1,14)
;GUICtrlCreateLabel("地址:",30,100,50)
;GUICtrlSetFont(-1,14)
;$u_province = GUICtrlCreateCombo("",100,97,100,45,$CBS_DROPDOWNLIST)
;GUICtrlSetFont(-1,13)
;GUICtrlCreateLabel("市/县:",240,100,70)
;GUICtrlSetFont(-1,14)
;$u_city = GUICtrlCreateCombo("",310,97,120,25,$CBS_DROPDOWNLIST)
;GUICtrlSetFont(-1,14)
GUICtrlCreateLabel("详细地址:",30,130,90)
GUICtrlSetFont(-1,14)
$u_address = GUICtrlCreateEdit("",120,100,330,75,$ES_AUTOVSCROLL+$ES_WANTRETURN+$WS_VSCROLL+$ES_MULTILINE)
GUICtrlSetFont(-1,15)
GUICtrlCreateLabel("ID:",30,190,30)
GUICtrlSetFont(-1,14)
$u_id = GUICtrlCreateInput("",60,187,50,25)
GUICtrlSetFont(-1,14)
GUICtrlCreateLabel("姓名:",120,190,50)
GUICtrlSetFont(-1,14)
$find_name = GUICtrlCreateInput("",170,187,100,25)
guiCtrlSetFont(-1,14)
$find_btn = GUICtrlCreateButton("搜索",280,187,60)
GUICtrlSetFont(-1,14)
$update_btn = GUICtrlCreateButton("修改",360,187,60)
GUICtrlSetFont(-1,14)
$add_btn = GUICtrlCreateButton("添加",440,187,60)
GUICtrlSetFont(-1,14)
$user_listbox = GUICtrlCreateListView("", 30, 220, 530, 410, 0x0010)
GUICtrlSetFont(-1,14)
_GUICtrlListView_AddColumn($user_listbox, " ID", 45, 0)
_GUICtrlListView_AddColumn($user_listbox, "姓名 ", 100, 1)
_GUICtrlListView_AddColumn($user_listbox, "手机号 ", 130, 1)
_GUICtrlListView_AddColumn($user_listbox, " QQ ", 120, 1)
_GUICtrlListView_AddColumn($user_listbox, "微信 ", 130, 1)
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $msg
Case $find_btn
$user_id = StringStripWS(GUICtrlRead($u_id),8)
$user_name = StringStripWS(GUICtrlRead($find_name),8)
If StringLen(GUICtrlRead($u_id)) == 0 And StringLen(GUICtrlRead($find_name)) == 0 Then
_find_all_user($user_listbox)
GUICtrlSetData($u_name,"")
GUICtrlSetData($u_phone,"")
GUICtrlSetData($u_qq,"")
GUICtrlSetData($u_weixin,"")
GUICtrlSetData($u_address,"")
GUICtrlSetData($u_id,"")
GUICtrlSetData($find_name,"")
Else
GUICtrlSetData($u_name,"")
GUICtrlSetData($u_phone,"")
GUICtrlSetData($u_qq,"")
GUICtrlSetData($u_weixin,"")
GUICtrlSetData($u_address,"")
$get_string = _find_user_by_id_name($user_listbox,$user_id,$user_name,$u_name,$u_phone,$u_qq,$u_weixin,$u_address)
If StringLen($get_string) <> 1 Then
MsgBox(0,"INFO",$get_string)
EndIf
EndIf
Case $update_btn
$user_id = StringStripWS(GUICtrlRead($u_id),8)
If StringLen(GUICtrlRead($u_id)) == 0 Then
MsgBox(0,"INFO","ID为空,请根据ID搜索出需要修改的用户。")
ContinueLoop
EndIf
$user_name = StringStripWS(GUICtrlRead($u_name),8)
$user_phone = StringStripWS(GUICtrlRead($u_phone),8)
If StringLen($user_name) == 0 Then
MsgBox(0,"INFO","用户名不能为空。")
ContinueLoop
EndIf
If Not StringRegExp($user_phone,"^1[3-9][0-9]{9}",0) Then
MsgBox(0,"INFO","手机号码填写不正确。")
ContinueLoop
EndIf
$user_qq = StringStripWS(GUICtrlRead($u_qq),8)
$user_weixin = StringStripWS(GUICtrlRead($u_weixin),8)
$user_address = StringStripWS(GUICtrlRead($u_address),8)
$modify_time = @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC
$get_string = _update_user_by_id($user_id,$user_name,$user_phone,$user_qq,$user_weixin,$user_address,$modify_time)
MsgBox(0,"INFO",$get_string)
GUICtrlSetData($u_name,"")
GUICtrlSetData($u_phone,"")
GUICtrlSetData($u_qq,"")
GUICtrlSetData($u_weixin,"")
GUICtrlSetData($u_address,"")
GUICtrlSetData($u_id,"")
GUICtrlSetData($find_name,"")
_find_user_by_id($user_listbox,$user_id)
Case $add_btn
$user_name = StringStripWS(GUICtrlRead($u_name),8)
If StringLen($user_name) == 0 Then
MsgBox(0,"INFO","用户名不能为空。")
ContinueLoop
EndIf
$user_phone = StringStripWS(GUICtrlRead($u_phone),8)
If Not StringRegExp($user_phone,"^1[3-9][0-9]{9}",0) Then
MsgBox(0,"INFO","手机号码填写不正确。")
ContinueLoop
EndIf
$user_qq = StringStripWS(GUICtrlRead($u_qq),8)
$user_weixin = StringStripWS(GUICtrlRead($u_weixin),8)
$user_address = StringStripWS(GUICtrlRead($u_address),8)
$create_time = @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC
$get_string = _user_add($user_name,$user_phone,$user_qq,$user_weixin,$user_address,$create_time)
MsgBox(0,"INFO",$get_string)
_find_all_user($user_listbox)
GUICtrlSetData($u_name,"")
GUICtrlSetData($u_phone,"")
GUICtrlSetData($u_qq,"")
GUICtrlSetData($u_weixin,"")
GUICtrlSetData($u_address,"")
GUICtrlSetData($u_id,"")
GUICtrlSetData($find_name,"")
Case $GUI_EVENT_CLOSE
GUIDelete($user_gui)
ExitLoop
EndSwitch
WEnd
EndFunc
;预约购买
Func _buy_item_info()
$buy_gui = GUICreate("预购信息一览",750,600)
GUISetBkColor(0xf58f98,$buy_gui)
GUICtrlCreateLabel("姓名(购买人):",30,20,120)
GUICtrlSetFont(-1,14)
$buy_user = GUICtrlCreateInput("",150,17,100,25)
GUICtrlSetFont(-1,14)
GUICtrlCreateLabel("手机:",260,20,50)
GUICtrlSetFont(-1,14)
$buy_phone=GUICtrlCreateInput("",310,17,120,25)
GUICtrlSetFont(-1,14)
GUICtrlSetLimit(-1,11)
GUICtrlCreateLabel("品牌:",440,20,50)
GUICtrlSetFont(-1,14)
$buy_brand = GUICtrlCreateCombo("",490,17,130,25,$CBS_DROPDOWNLIST + $WS_VSCROLL)
GUICtrlSetFont(-1,14)
If _find_brand_is_use() <> "" Then
GUICtrlSetData($buy_brand,_find_brand_is_use(),"")
EndIf
$buy_brand_btn = GUICtrlCreateButton("确定",630,17,60,25)
GUICtrlSetFont(-1,12)
$brand_label = GUICtrlCreateLabel("==========",130,60,100)
GUICtrlSetColor(-1,0xed1941)
GUICtrlSetFont(-1,14)
GUICtrlCreateLabel("商品:",230,60,50)
GUICtrlSetFont(-1,14)
$buy_brand_item = GUICtrlCreateCombo("",280,57,200,25,$CBS_DROPDOWNLIST + $WS_VSCROLL)
GUICtrlSetFont(-1,14)
GUICtrlSetState($buy_brand_item,$GUI_DISABLE)
$buy_item_btn = GUICtrlCreateButton("确定",500,57,60,25)
GUICtrlSetFont(-1,14)
GUICtrlSetState($buy_item_btn,$GUI_DISABLE)
$item_label = GUICtrlCreateLabel("",560,60)
GUICtrlSetState($item_label,$GUI_HIDE)
GUICtrlCreateLabel("韩国报价:",30,100,90)
GUICtrlSetFont(-1,14)
$korea_price = GUICtrlCreateLabel("=",120,100,100)
GUICtrlSetColor(-1,0x2a5caa)
GUICtrlSetFont(-1,14)
GUICtrlCreateLabel("(RMB)",220,100,50)
GUICtrlSetColor(-1,0xed1941)
GUICtrlSetFont(-1,14)
GUICtrlCreateLabel("中国报价:",280,100,90)
GUICtrlSetFont(-1,14)
$china_price = GUICtrlCreateLabel("=",370,100,100)
GUICtrlSetColor(-1,0x2a5caa)
GUICtrlSetFont(-1,14)
GUICtrlCreateLabel("(RMB)",470,100,50)
GUICtrlSetColor(-1,0xed1941)
GUICtrlSetFont(-1,14)
GUICtrlCreateLabel("成本:",530,100,50)
GUICtrlSetFont(-1,14)
$cost_price = GUICtrlCreateLabel("=",580,100,100)
GUICtrlSetColor(-1,0x2a5caa)
GUICtrlSetFont(-1,14)
GUICtrlCreateLabel("(RMB)",680,100,50)
GUICtrlSetColor(-1,0xed1941)
GUICtrlSetFont(-1,14)
GUICtrlCreateLabel("建议售价:",30,140,90)
GUICtrlSetFont(-1,14)
$retail_price = GUICtrlCreateLabel("=",120,140,60)
GUICtrlSetColor(-1,0x2a5caa)
GUICtrlSetFont(-1,14)
GUICtrlCreateLabel("(RMB)",220,140,60)
GUICtrlSetColor(-1,0xed1941)
GUICtrlSetFont(-1,14)
GUICtrlCreateLabel("剩余数量:",280,140,90)
GUICtrlSetFont(-1,14)
$remainder = GUICtrlCreateLabel("=",370,140,100)
GUICtrlSetColor(-1,0x2a5caa)
GUICtrlSetFont(-1,14)
GUICtrlCreateLabel("(个/支)",460,140,80)
GUICtrlSetColor(-1,0xed1941)
GUICtrlSetFont(-1,14)
GUICtrlCreateLabel("预定数量:",530,140,90)
GUICtrlSetFont(-1,14)
$fix_num = GUICtrlCreateInput("=",620,137,50,25)
GUICtrlSetColor(-1,0x2a5caa)
GUICtrlSetFont(-1,14)
GUICtrlSetLimit(-1,4)
GUICtrlSetState($fix_num,$GUI_DISABLE)
GUICtrlCreateLabel("(个/支)",670,140,80)
GUICtrlSetColor(-1,0xed1941)
GUICtrlSetFont(-1,14)
GUICtrlCreateLabel("卖出价格:",30,180,90)
GUICtrlSetFont(-1,14)
$real_price = GUICtrlCreateInput("=",120,177,90,25)
GUICtrlSetColor(-1,0x2a5caa)
GUICtrlSetFont(-1,14)
GUICtrlSetState($real_price,$GUI_DISABLE)
GUICtrlCreateLabel("(RMB)",220,180,60)
GUICtrlSetColor(-1,0xed1941)
GUICtrlSetFont(-1,14)
GUICtrlCreateLabel("商品描述信息:",30,290,120)
GUICtrlSetFont(-1,14)
$description = GUICtrlCreateEdit("",150,220,430,150,$ES_READONLY + $ES_AUTOVSCROLL + $ES_WANTRETURN + $WS_VSCROLL + $ES_MULTILINE)
GUICtrlSetFont(-1,15)
GUICtrlCreateLabel("备 注 信 息 :",30,430,120)
GUICtrlSetFont(-1,14)
$ps_info = GUICtrlCreateEdit("",150,410,430,75,$ES_AUTOVSCROLL+$ES_WANTRETURN+$WS_VSCROLL+$ES_MULTILINE)
GUICtrlSetFont(-1,15)
$fix_buy_btn = GUICtrlCreateButton("确认预订",600,510,120,60)
GUICtrlSetBkColor(-1,0xed1941)
GUICtrlSetFont(-1,18)
GUICtrlSetColor(-1,0xffc20e)
GUICtrlSetState($fix_buy_btn,$GUI_DISABLE)
Local $brand_id = 0,$remain_num
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $msg
Case $buy_brand_btn
$brand_name = StringStripWS(GUICtrlRead($buy_brand),8)
If StringLen($brand_name) == 0 Then
MsgBox(0,"INFO","必须要选择一个品牌才能进行预订。")
ContinueLoop
EndIf
$brand_id = _find_brand_id_by_name($brand_name)
$item_list = _find_item_by_brand_id($brand_id)
If $item_list == "" Then
MsgBox(0,"INFO",$brand_name & "品牌下没有可用的商品。")
ContinueLoop
Else
GUICtrlSetState($buy_item_btn,$GUI_ENABLE)
GUICtrlSetState($buy_brand_item,$GUI_ENABLE)
GUICtrlSetData($buy_brand_item,$item_list)
GUICtrlSetData($brand_label,"")
GUICtrlSetData($brand_label,$brand_name)
GUICtrlSetTip($brand_label, $brand_name)
EndIf
Case $buy_item_btn
$brand_name = StringStripWS(GUICtrlRead($buy_brand),8)
$item_name = StringStripWS(GUICtrlRead($buy_brand_item),8)
If StringLen($item_name) == 0 Then
MsgBox(0,"INFO","需要选择一个商品才能继续预购。")
ContinueLoop
Else
GUICtrlSetState($fix_buy_btn,$GUI_ENABLE)
GUICtrlSetState($real_price,$GUI_ENABLE)
GUICtrlSetState($fix_num,$GUI_ENABLE)
GUICtrlSetData($fix_num,"")
GUICtrlSetData($real_price,"")
GUICtrlSetData($item_label,$item_name)
$all_num = _find_num_by_brand_id_and_item_name($brand_id,$item_name)
$sell_num = _find_num_by_brand_name_and_item_name($brand_name,$item_name)
$remain_num = Int($all_num) - Int($sell_num)
_find_item_info_by_brand_id_and_item_name($brand_id,$item_name,$korea_price,$china_price,$cost_price,$retail_price,$description)
GUICtrlSetData($remainder,$remain_num)
EndIf
Case $fix_buy_btn
$user_name = StringStripWS(GUICtrlRead($buy_user),8)
If StringLen($user_name) == 0 Then
MsgBox(0,"INFO","必须填写一个购买人姓名,才能进行预购。")
ContinueLoop
EndIf
$user_phone = StringStripWS(GUICtrlRead($buy_phone),8)
If StringLen($user_phone) == 0 Then
MsgBox(0,"INFO","必须填写一个购买人手机,才能进行预购。")
ContinueLoop
Else
If Not StringRegExp($user_phone,"^1[3-9][0-9]{9}",0) Then
MsgBox(0,"INFO","预购人手机号码填写不正确。")
ContinueLoop
EndIf
EndIf
$num = StringStripWS(GUICtrlRead($fix_num),8)
If StringLen($num) == 0 Then
MsgBox(0,"INFO","她/他 到底预定了几个呢?")
ContinueLoop
Else
If Not StringRegExp($num,"^[1-9][0-9]{0,}",0) Then
MsgBox(0,"INFO","亲爱的,你输入的预定数量,不正常。"& $num)
ContinueLoop
Else
If Int($num) > Int($remain_num) Then
MsgBox(0,"INFO","TA 预定的数量已经大于库存了,我们给不起这么多东西啊!")
ContinueLoop
EndIf
EndIf
EndIf
$price = StringStripWS(GUICtrlRead($real_price),8)
If StringLen($price) == 0 Then
MsgBox(0,"INFO","不能把商品白给人家啊!!!填一个真实的卖价吧。")
ContinueLoop
Else
If Not StringRegExp($price,'^[1-9][0-9]{0,}.?[0-9]{0,2}',0) Then
MsgBox(0,"INFO","亲爱的,你看你输入的是啥呀?"&$price&" 我们需要的是数字。")
ContinueLoop
EndIf
EndIf
$cost = StringStripWS(GUICtrlRead($cost_price),8)
If $price < $cost Then
MsgBox(0,"INFO","亲爱的,卖价比成本价都低,亏本的买卖不能干啊!")
ContinueLoop
EndIf
$dispart = $price - $cost
$ps = StringReplace(GUICtrlRead($ps_info),"'","’")
$brand_name = StringStripWS(GUICtrlRead($brand_label),8)
$item_name = StringStripWS(GUICtrlRead($item_label),8)
$return_code = MsgBox(1,"核对信息","预订人:"&$user_name&"--预定手机号:"&$user_phone&@CRLF&@CRLF& _
"预定品牌:" & $brand_name & "--预定商品:" & $item_name&@CRLF&@CRLF& _
"预定数量:" & $num &" --卖出价格:" & $price)
If $return_code = 1 Then
$get_string = _find_user_by_phone($user_phone)
$time = @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC
If StringCompare($get_string,"yes") == 0 Then
$get_string = _add_user_and_item_info($user_name,$user_phone,$brand_name,$item_name,$num,$price,$ps,$dispart,$time)
If $get_string = 0 Then
MsgBox(0,"INFO","预定失败!请找工程师解决。")
ContinueLoop
ElseIf $get_string = 1 Then
MsgBox(0,"INFO","预定成功。")
Else
MsgBox(0,"INFO","预定失败!系统问题,请找工程师解决。")
ContinueLoop
EndIf
ElseIf StringCompare($get_string,"no") == 0 Then
$get_string = _add_user_and_item_info($user_name,$user_phone,$brand_name,$item_name,$num,$price,$ps,$dispart,$time)
If $get_string = 0 Then
MsgBox(0,"INFO","预定失败!请找工程师解决。")
ContinueLoop
ElseIf $get_string = 1 Then
_user_add($user_name,$user_phone,"","","",$time)
MsgBox(0,"INFO","预定成功。")
Else
MsgBox(0,"INFO","预定失败!系统问题,请找工程师解决。")
ContinueLoop
EndIf
EndIf
ElseIf $return_code = 2 Then
MsgBox(0,"INFO","亲爱的,你取消了--"&$user_name&" --的预定。")
ContinueLoop
Else
MsgBox(0,"INFO","亲爱的,你取消了--"&$user_name&" --的预定。")
ContinueLoop
EndIf
GUICtrlSetData($korea_price,"=")
GUICtrlSetData($china_price,"=")
GUICtrlSetData($cost_price,"=")
GUICtrlSetData($retail_price,"=")
GUICtrlSetData($remainder,"=")
GUICtrlSetData($fix_num,"=")
GUICtrlSetState($fix_num,$GUI_DISABLE)
GUICtrlSetData($real_price,"=")
GUICtrlSetState($real_price,$GUI_DISABLE)
GUICtrlSetData($description,"")
GUICtrlSetData($ps_info,"")
GUICtrlSetState($fix_buy_btn,$GUI_DISABLE)
Case $GUI_EVENT_CLOSE
GUIDelete($buy_gui)
ExitLoop
EndSwitch
WEnd
EndFunc
;创建表结构
Func _sql_create()
_SQLite_Open($sql_name)
Local $sql
$sql = "CREATE TABLE IF NOT EXISTS brand_table (id INTEGER PRIMARY KEY ASC," & _
"brand_name Text,is_use Text,description Text,create_time Text," & _
"modify_time Text);"
_SQLite_Exec(-1, $sql)
$sql = "CREATE TABLE IF NOT EXISTS item_table (id INTEGER PRIMARY KEY ASC," & _
"brand_id INTEGER,item_name Text,korea_price Text,korea_to_china_price Text,"& _
"china_price Text,net_price Text,discount Text,discount_price Text," & _
"item_num Text,international_freight Text, internal_freight Text, retail_price Text," & _
"cost Text, description Text, create_time Text, modify_time Text,is_use Text);"
_SQLite_Exec(-1, $sql)
$sql = "CREATE TABLE IF NOT EXISTS user_item_table (id INTEGER PRIMARY KEY ASC," & _
"user_name Text, phone_num Text, brand_name Text, item_name Text," & _
"buy_num Text, real_price Text, disparity_price Text, description Text, " & _
"buy_time Text, is_pay Text, pay_time Text," & _
"is_deliver Text, deliver_goods_time Text, order_path Text, modify_time Text,"& _
"is_success Text,success_time Text,exchange_rate Text);"
_SQLite_Exec(-1, $sql)
$sql = "CREATE TABLE IF NOT EXISTS user_table (id INTEGER PRIMARY KEY ASC," & _
"user_name Text, phone_num Text, qq_num Text, weixin_num Text, address Text," & _
"create_time Text, modify_time Text);"
_SQLite_Exec(-1, $sql)
_SQLite_Close()
EndFunc
;添加新用户
Func _user_add($user_name,$user_phone,$user_qq,$user_weixin,$user_address,$create_time)
_SQLite_Open($sql_name)
$sql = "SELECT * FROM user_table WHERE phone_num = '" & $user_phone & "';"
_SQLite_QuerySingleRow(-1, $sql, $aRow)
$Temp = $aRow[0]
If $Temp = "" Then
$sql = "INSERT INTO user_table values(null,'"&$user_name&"','"&$user_phone&"','"&$user_qq&"','"&$user_weixin&"','"&$user_address&"','"&$create_time&"','"&$create_time&"');"
_SQLite_Exec(-1, $sql)
_SQLite_Close ()
Return "添加用户成功。"
Else
_SQLite_Close ()
Return "添加用户 "&$user_name&" 失败。该用户手机号已经存在,如需添加请更改手机号。"
EndIf
EndFunc
;查询所有用户信息并回显到页面中
Func _find_all_user($user_listbox)
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($user_listbox))
_SQLite_Open($sql_name)
Local $sql = "SELECT * FROM user_table ORDER BY ID DESC;"
_SQLite_Query(-1, $sql, $hQuery)
While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK
$Temp = $aRow[0]
If $Temp == "" Then
_SQLite_Close()
Return "没有插入任何数据,我什么都找不到。"
Else
_GUICtrlListView_AddItem($user_listbox, $aRow[0])
_GUICtrlListView_AddSubItem($user_listbox, _GUICtrlListView_FindInText($user_listbox, $aRow[0]), $aRow[1], 1)
_GUICtrlListView_AddSubItem($user_listbox, _GUICtrlListView_FindInText($user_listbox, $aRow[0]), $aRow[2], 2)
_GUICtrlListView_AddSubItem($user_listbox, _GUICtrlListView_FindInText($user_listbox, $aRow[0]), $aRow[3], 3)
_GUICtrlListView_AddSubItem($user_listbox, _GUICtrlListView_FindInText($user_listbox, $aRow[0]), $aRow[4], 4)
_GUICtrlListView_AddSubItem($user_listbox, _GUICtrlListView_FindInText($user_listbox, $aRow[0]), $aRow[5], 5)
EndIf
WEnd
_SQLite_Close()
EndFunc
;通过用户id和name查找用户
Func _find_user_by_id_name($user_listbox,$user_id,$user_name,$u_name,$u_phone,$u_qq,$u_weixin,$u_address)
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($user_listbox))
_SQLite_Open($sql_name)
Local $sql = "SELECT * FROM user_table WHERE ",$mark = 0
If StringLen($user_id) == 0 And StringLen($user_name) <> 0 Then
$sql &= "user_name LIKE '%" & $user_name & "%' ORDER BY ID DESC;"
_SQLite_Query(-1, $sql, $hQuery)
GUICtrlSetData($u_name,"")
GUICtrlSetData($u_phone,"")
GUICtrlSetData($u_qq,"")
GUICtrlSetData($u_weixin,"")
GUICtrlSetData($u_address,"")
While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK
$Temp = $aRow[0]
If $Temp == "" Then
_SQLite_Close()
Else
_GUICtrlListView_AddItem($user_listbox, $aRow[0])
_GUICtrlListView_AddSubItem($user_listbox, _GUICtrlListView_FindInText($user_listbox, $aRow[0]), $aRow[1], 1)
_GUICtrlListView_AddSubItem($user_listbox, _GUICtrlListView_FindInText($user_listbox, $aRow[0]), $aRow[2], 2)
_GUICtrlListView_AddSubItem($user_listbox, _GUICtrlListView_FindInText($user_listbox, $aRow[0]), $aRow[3], 3)
_GUICtrlListView_AddSubItem($user_listbox, _GUICtrlListView_FindInText($user_listbox, $aRow[0]), $aRow[4], 4)
_GUICtrlListView_AddSubItem($user_listbox, _GUICtrlListView_FindInText($user_listbox, $aRow[0]), $aRow[5], 5)
$mark = 1
EndIf
WEnd
_SQLite_Close()
ElseIf StringLen($user_id) <> 0 And StringLen($user_name) == 0 Then
$sql &= "id = " & $user_id & ";"
_SQLite_QuerySingleRow(-1, $sql, $aRow)
$Temp = $aRow[0]
If $Temp = "" Then
_SQLite_Close()
Return "没有关于ID=" & $user_id & "的用户信息。"
Else
_GUICtrlListView_AddItem($user_listbox, $aRow[0])
_GUICtrlListView_AddSubItem($user_listbox, _GUICtrlListView_FindInText($user_listbox, $aRow[0]), $aRow[1], 1)
GUICtrlSetData($u_name,$aRow[1])
_GUICtrlListView_AddSubItem($user_listbox, _GUICtrlListView_FindInText($user_listbox, $aRow[0]), $aRow[2], 2)
GUICtrlSetData($u_phone,$aRow[2])
_GUICtrlListView_AddSubItem($user_listbox, _GUICtrlListView_FindInText($user_listbox, $aRow[0]), $aRow[3], 3)
GUICtrlSetData($u_qq,$aRow[3])
_GUICtrlListView_AddSubItem($user_listbox, _GUICtrlListView_FindInText($user_listbox, $aRow[0]), $aRow[4], 4)
GUICtrlSetData($u_weixin,$aRow[4])
_GUICtrlListView_AddSubItem($user_listbox, _GUICtrlListView_FindInText($user_listbox, $aRow[0]), $aRow[5], 5)
GUICtrlSetData($u_address,$aRow[5])
$mark = 1
EndIf
_SQLite_Close()
ElseIf StringLen($user_id) <> 0 And StringLen($user_name) <> 0 Then
$sql &= "id = " & $user_id & " AND user_name LIKE '%" & $user_name & "%';"
_SQLite_QuerySingleRow(-1, $sql, $aRow)
$Temp = $aRow[0]
If $Temp = "" Then
_SQLite_Close()
Else
_GUICtrlListView_AddItem($user_listbox, $aRow[0])
_GUICtrlListView_AddSubItem($user_listbox, _GUICtrlListView_FindInText($user_listbox, $aRow[0]), $aRow[1], 1)
GUICtrlSetData($u_name,$aRow[1])
_GUICtrlListView_AddSubItem($user_listbox, _GUICtrlListView_FindInText($user_listbox, $aRow[0]), $aRow[2], 2)
GUICtrlSetData($u_phone,$aRow[2])
_GUICtrlListView_AddSubItem($user_listbox, _GUICtrlListView_FindInText($user_listbox, $aRow[0]), $aRow[3], 3)
GUICtrlSetData($u_qq,$aRow[3])
_GUICtrlListView_AddSubItem($user_listbox, _GUICtrlListView_FindInText($user_listbox, $aRow[0]), $aRow[4], 4)
GUICtrlSetData($u_weixin,$aRow[4])
_GUICtrlListView_AddSubItem($user_listbox, _GUICtrlListView_FindInText($user_listbox, $aRow[0]), $aRow[5], 5)
GUICtrlSetData($u_address,$aRow[5])
$mark = 1
EndIf
_SQLite_Close()
EndIf
If $mark <> 1 Then
Return "没有关于ID=" & $user_id & " 姓名="&$user_name&" 的用户信息。"
EndIf
EndFunc
;根据id对用户进行修改操作
Func _update_user_by_id($user_id,$user_name,$user_phone,$user_qq,$user_weixin,$user_address,$modify_time)
_SQLite_Open($sql_name)
Local $sql = "SELECT * FROM user_table WHERE user_name = '" & $user_name & "' and id <> "& $user_id &";"
_SQLite_QuerySingleRow(-1, $sql, $aRow)
$Temp = $aRow[0]
If $Temp = "" Then
$sql = "UPDATE user_table SET user_name='" & $user_name &"',phone_num='" & $user_phone &"',qq_num='" & $user_qq &"',weixin_num='" & $user_weixin &"',address ='" & $user_address &"',modify_time ='" & $modify_time & "' WHERE id=" & $user_id & ";"
_SQLite_Exec(-1,$sql)
Else
_SQLite_Close()
Return "用户名" & $user_name & "已经存在,不能更新此数据。"
EndIf
_SQLite_Close()
Return "用户" & $user_name & "修改成功。"
EndFunc
;通过id查询用户信息
Func _find_user_by_id($user_listbox,$user_id)
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($user_listbox))
_SQLite_Open($sql_name)
Local $sql = "SELECT * FROM user_table WHERE id = " & $user_id & ";"
_SQLite_QuerySingleRow(-1, $sql, $aRow)
_GUICtrlListView_AddItem($user_listbox, $aRow[0])
_GUICtrlListView_AddSubItem($user_listbox, _GUICtrlListView_FindInText($user_listbox, $aRow[0]), $aRow[1], 1)
_GUICtrlListView_AddSubItem($user_listbox, _GUICtrlListView_FindInText($user_listbox, $aRow[0]), $aRow[2], 2)
_GUICtrlListView_AddSubItem($user_listbox, _GUICtrlListView_FindInText($user_listbox, $aRow[0]), $aRow[3], 3)
_GUICtrlListView_AddSubItem($user_listbox, _GUICtrlListView_FindInText($user_listbox, $aRow[0]), $aRow[4], 4)
_GUICtrlListView_AddSubItem($user_listbox, _GUICtrlListView_FindInText($user_listbox, $aRow[0]), $aRow[5], 5)
_SQLite_Close()
EndFunc
;查找所有品牌
Func _find_brand()
_SQLite_Open($sql_name)
Local $sql = "SELECT * FROM brand_table;",$set_string = ""
_SQLite_Query(-1, $sql, $hQuery)
While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK
$Temp = $aRow[0]
If $Temp == "" Then
_SQLite_Close()
Else
$set_string = "|" & $aRow[1] & $set_string
EndIf
WEnd
_SQLite_Close()
Return $set_string
EndFunc
;通过名称查找品牌信息
Func _find_brand_by_name($b_name,$brand_name,$y_radio,$n_radio,$brand_view)
_SQLite_Open($sql_name)
Local $sql = "SELECT * FROM brand_table WHERE brand_name = '" & $b_name & "';"
_SQLite_QuerySingleRow(-1, $sql, $aRow)
GUICtrlSetData($brand_name,$aRow[1])
If $aRow[2] == 0 Then
GUICtrlSetState($n_radio,$GUI_CHECKED)
EndIf
If $aRow[2] == 1 Then
GUICtrlSetState($y_radio,$GUI_CHECKED)
EndIf
GUICtrlSetData($brand_view,$aRow[3])
_SQLite_Close()
EndFunc
;添加一个品牌
Func _brand_add($name,$choose,$description,$time)
_SQLite_Open($sql_name)
Local $sql = "SELECT * FROM brand_table WHERE brand_name = '" & $name & "';"
_SQLite_QuerySingleRow(-1, $sql, $aRow)
$Temp = $aRow[0]
If $Temp = "" Then
$description = StringReplace($description,"'","""")
$sql = "INSERT INTO brand_table VALUES(null,'" & $name & "','" & $choose & "','" & $description & "','" & $time & "','" & $time & "');"
_SQLite_Exec(-1, $sql)
_SQLite_Close ()
Return "添加品牌成功。"
Else
_SQLite_Close ()
Return "添加品牌 " & $name & " 失败。该品牌已经存在,如需添加请更改名称。"
EndIf
EndFunc
;通过名称查找品牌id
Func _find_brand_id_by_name($b_name)
_SQLite_Open($sql_name)
Local $sql = "SELECT id FROM brand_table WHERE brand_name = '" & $b_name & "';"
_SQLite_QuerySingleRow(-1, $sql, $aRow)
Return $aRow[0]
EndFunc
;通过id更新品牌
Func _update_brand_by_id($brand_id,$b_name,$choose,$description,$time)
_SQLite_Open($sql_name)
Local $sql = "SELECT * FROM brand_table WHERE brand_name = '" & $b_name & "' and id <> "& $brand_id &";"
_SQLite_QuerySingleRow(-1, $sql, $aRow)
$Temp = $aRow[0]
If $Temp = "" Then
$description = StringReplace($description,"'","’")
$sql = "UPDATE brand_table SET brand_name='" & $b_name &"',is_use='" & $choose &"',description='" & $description &"',modify_time ='" & $time & "' WHERE id=" & $brand_id & ";"
_SQLite_Exec(-1,$sql)
Else
_SQLite_Close()
Return "品牌名" & $b_name & "已经存在,不能进行此次更新。"
EndIf
_SQLite_Close()
Return "品牌 " & $b_name & " 修改成功。"
EndFunc
;对摸个品牌添加一个新商品
Func _item_add($brand_id,$item_name,$item_kprice,$item_cprice,$item_net_price,$item_discount,$item_num,$item_international_freight,$item_internal_freight,$item_retail_price,$item_description)
_SQLite_Open($sql_name)
Local $sql = "SELECT * FROM item_table WHERE item_name = '" & $item_name & "' AND brand_id = "& $brand_id &";"
_SQLite_QuerySingleRow(-1, $sql, $aRow)
$Temp = $aRow[0]
If $Temp = "" Then
$time = @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC
$item_description = StringReplace($item_description,"'","’")
If StringLen($item_discount) <> 0 Then
$item_discount = "0." & $item_discount
EndIf
$cost = $item_discount / $krw * $item_discount + $item_internal_freight + $item_retail_price
$sql = "INSERT INTO item_table VALUES(null," & $brand_id & ",'" & $item_name & "','" & $item_kprice & "','" & $item_kprice / $krw & "','" & $item_cprice & "','" & $item_net_price & "','" & $item_discount & "','" & $item_discount / $krw & "','" & $item_num & "','" & $item_international_freight & "','" & $item_internal_freight & "','" & $item_retail_price & "','" & $cost & "','" & $item_description & "','" & $time & "','" & $time & "','1');"
_SQLite_Exec(-1, $sql)
_SQLite_Close ()
Return "添加商品成功。"
Else
_SQLite_Close ()
Return "添加商品 " & $item_name & " 失败。同类品牌已经存在此商品,如需添加请更改名称。"
EndIf
EndFunc
;无条件查找所有的商品
Func _find_all_item($item_listbox)
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($item_listbox))
_SQLite_Open($sql_name)
Local $sql = "SELECT * FROM item_table ORDER BY ID DESC;"
_SQLite_Query(-1, $sql, $hQuery)
While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK
$Temp = $aRow[0]
If $Temp == "" Then
_SQLite_Close()
MsgBox(0,"INFO","没有插入任何数据,我什么都找不到。")
ExitLoop
Else
_GUICtrlListView_AddItem($item_listbox, $aRow[0])
_GUICtrlListView_AddSubItem($item_listbox, _GUICtrlListView_FindInText($item_listbox, $aRow[0]), $aRow[2], 1)
_GUICtrlListView_AddSubItem($item_listbox, _GUICtrlListView_FindInText($item_listbox, $aRow[0]), Round($aRow[4],2), 2)
_GUICtrlListView_AddSubItem($item_listbox, _GUICtrlListView_FindInText($item_listbox, $aRow[0]), $aRow[5], 3)
_GUICtrlListView_AddSubItem($item_listbox, _GUICtrlListView_FindInText($item_listbox, $aRow[0]), Round($aRow[13],2), 4)
_GUICtrlListView_AddSubItem($item_listbox, _GUICtrlListView_FindInText($item_listbox, $aRow[0]), $aRow[12], 5)
If $aRow[17] = 0 Then
_GUICtrlListView_AddSubItem($item_listbox, _GUICtrlListView_FindInText($item_listbox, $aRow[0]), "拉黑", 6)
EndIf
If $aRow[17] = 1 Then
_GUICtrlListView_AddSubItem($item_listbox, _GUICtrlListView_FindInText($item_listbox, $aRow[0]), "活跃", 6)
EndIf
EndIf
WEnd
_SQLite_Close()
EndFunc
;通过id查找商品
Func _find_item_by_id($item_listbox,$item_id,$p_name,$p_kprice,$p_cprice,$p_net_price,$p_discount,$p_num,$p_international_freight,$p_internal_freight,$p_retail_price,$p_view)
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($item_listbox))
_SQLite_Open($sql_name)
Local $sql = "SELECT * FROM item_table WHERE id = " & $item_id & ";"
_SQLite_QuerySingleRow(-1, $sql, $aRow)
$Temp = $aRow[0]
If $Temp = "" Then
_SQLite_Close()
Return "找不到id=" & $item_id & " 的商品。"
Else
_GUICtrlListView_AddItem($item_listbox, $aRow[0])
_GUICtrlListView_AddSubItem($item_listbox, _GUICtrlListView_FindInText($item_listbox, $aRow[0]), $aRow[2], 1)
_GUICtrlListView_AddSubItem($item_listbox, _GUICtrlListView_FindInText($item_listbox, $aRow[0]), Round($aRow[4],2), 2)
_GUICtrlListView_AddSubItem($item_listbox, _GUICtrlListView_FindInText($item_listbox, $aRow[0]), $aRow[5], 3)
_GUICtrlListView_AddSubItem($item_listbox, _GUICtrlListView_FindInText($item_listbox, $aRow[0]), Round($aRow[13],2), 4)
_GUICtrlListView_AddSubItem($item_listbox, _GUICtrlListView_FindInText($item_listbox, $aRow[0]), $aRow[12], 5)
If $aRow[17] = 0 Then
_GUICtrlListView_AddSubItem($item_listbox, _GUICtrlListView_FindInText($item_listbox, $aRow[0]), "拉黑", 6)
EndIf
If $aRow[17] = 1 Then
_GUICtrlListView_AddSubItem($item_listbox, _GUICtrlListView_FindInText($item_listbox, $aRow[0]), "活跃", 6)
EndIf
GUICtrlSetData($p_name,$aRow[2])
GUICtrlSetData($p_kprice,$aRow[3])
GUICtrlSetData($p_cprice,$aRow[5])
GUICtrlSetData($p_net_price,$aRow[6])
If StringInStr($aRow[7],"0.") == 1 Then
$arr = StringSplit($aRow[7],".")
$aRow[7] = $arr[2]
EndIf
GUICtrlSetData($p_discount,$aRow[7])
GUICtrlSetData($p_num,$aRow[9])
GUICtrlSetData($p_international_freight,$aRow[10])
GUICtrlSetData($p_internal_freight,$aRow[11])
GUICtrlSetData($p_retail_price,$aRow[12])
GUICtrlSetData($p_view,$aRow[14])
EndIf
_SQLite_Close()
EndFunc
;通过id将商品进行删除,即将商品的使用状态改变掉,使其在正常的使用中不显示在预定信息中
Func _delete_item_by_id($item_id)
_SQLite_Open($sql_name)
Local $sql = "SELECT * FROM item_table WHERE id = " & $item_id & ";"
_SQLite_QuerySingleRow(-1, $sql, $aRow)
$Temp = $aRow[0]
If $Temp = "" Then
_SQLite_Close()
Return "商品ID=" & $item_id & " 的商品,MS不存在,请检查后再删除。"
Else
$sql = "UPDATE item_table SET is_use='0' WHERE id = " & $item_id & ";"
_SQLite_Exec(-1,$sql)
EndIf
_SQLite_Close()
Return "ID为" & $item_id & " 的商品已被拉黑。"
EndFunc
Func _update_item_by_id($item_id,$item_name,$item_kprice,$item_cprice,$item_net_price,$item_discount,$item_num,$item_international_freight,$item_internal_freight,$item_retail_price,$item_description)
_SQLite_Open($sql_name)
Local $sql = "SELECT * FROM item_table WHERE id <> " & $item_id & " AND item_name='" & $item_name & "';"
_SQLite_QuerySingleRow(-1, $sql, $aRow)
$Temp = $aRow[0]
If $Temp = "" Then
$k_to_c = $item_kprice / $krw
If StringLen($item_discount) <> 0 Then
$item_discount = "0." & $item_discount
EndIf
$time = @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC
$cost = $item_discount / $krw * $item_discount + $item_internal_freight + $item_retail_price
$d_p = $item_net_price * $item_discount
$sql = "UPDATE item_table SET item_name='" & $item_name & "',korea_price='" & $item_kprice & "',korea_to_china_price='" & $k_to_c & "',china_price='" & $item_cprice & "',net_price='" & $item_net_price & "',discount='" & $item_discount & "',discount_price='" & $d_p & "',item_num='" & $item_num & "',international_freight='" & $item_international_freight & "',internal_freight='" & $item_internal_freight & "',retail_price='" & $item_retail_price & "',cost='" & $cost & "',description='" & $item_description & "',modify_time='" & $time & "',is_use='1' WHERE id=" & $item_id & ";"
_SQLite_Exec(-1,$sql)
Else
_SQLite_Close()
Return "商品ID=" & $item_id & " 名称=" & $item_name & " 的商品,貌似已经存在,请检查后再进行修改。"
EndIf
_SQLite_Close()
Return "商品ID=" & $item_id & " 名称=" & $item_name & " 的商品修改成功。"
EndFunc
;查找所有品牌
Func _find_brand_is_use()
_SQLite_Open($sql_name)
Local $sql = "SELECT * FROM brand_table WHERE is_use='1';",$set_string = ""
_SQLite_Query(-1, $sql, $hQuery)
While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK
$Temp = $aRow[0]
If $Temp == "" Then
_SQLite_Close()
Else
$set_string = "|" & $aRow[1] & $set_string
EndIf
WEnd
_SQLite_Close()
Return $set_string
EndFunc
;通过brand_id查找下面的所有商品
Func _find_item_by_brand_id($brand_id)
_SQLite_Open($sql_name)
Local $sql = "SELECT item_name FROM item_table WHERE brand_id=" & $brand_id & " AND is_use='1';"
Local $set_string = ""
_SQLite_Query(-1, $sql, $hQuery)
While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK
$Temp = $aRow[0]
If $Temp == "" Then
_SQLite_Close()
Else
$set_string = "|" & $aRow[0] & $set_string
EndIf
WEnd
_SQLite_Close()
Return $set_string
EndFunc
;通过brand_id和item_name查找对应的商品信息
Func _find_item_info_by_brand_id_and_item_name($brand_id,$item_name,$korea_price,$china_price,$cost_price,$retail_price,$description)
_SQLite_Open($sql_name)
Local $sql = "SELECT * FROM item_table WHERE brand_id=" & $brand_id & " AND item_name='" & $item_name & "';"
_SQLite_QuerySingleRow(-1, $sql, $aRow)
GUICtrlSetData($korea_price,Round($aRow[4],2))
GUICtrlSetData($china_price,$aRow[5])
GUICtrlSetData($cost_price,Round($aRow[13],2))
GUICtrlSetData($retail_price,Round($aRow[12],2))
GUICtrlSetData($description,$aRow[14])
_SQLite_Close()
EndFunc
;通过电话号码查找用户是否存在
Func _find_user_by_phone($user_phone)
_SQLite_Open($sql_name)
Local $sql = "SELECT * FROM user_table WHERE phone_num='" & $user_phone & "';"
_SQLite_QuerySingleRow(-1, $sql, $aRow)
$Temp = $aRow[0]
If $Temp = "" Then
_SQLite_Close()
Return "no"
Else
_SQLite_Close()
Return "yes"
EndIf
EndFunc
;通过brand_id和item_name获取item总数
Func _find_num_by_brand_id_and_item_name($brand_id,$item_name)
_SQLite_Open($sql_name)
Local $sql = "SELECT item_num FROM item_table WHERE brand_id=" & $brand_id & " AND item_name='" & $item_name & "' ORDER BY ID DESC;"
_SQLite_Query(-1, $sql, $hQuery)
Local $all_num = 0
While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK
$Temp = $aRow[0]
If $Temp == "" Then
_SQLite_Close()
Else
$all_num = $all_num + $aRow[0]
EndIf
WEnd
_SQLite_Close()
Return $all_num
EndFunc
;通过brand_name和item_name获取实际卖出item的总数
Func _find_num_by_brand_name_and_item_name($brand_name,$item_name)
_SQLite_Open($sql_name)
Local $sql = "SELECT buy_num FROM user_item_table WHERE brand_name='" & $brand_name & "' AND item_name='" & $item_name & "' ORDER BY ID DESC;"
_SQLite_Query(-1, $sql, $hQuery)
Local $all_num = 0
While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK
$Temp = $aRow[0]
If $Temp == "" Then
_SQLite_Close()
Else
$all_num = $all_num + $aRow[0]
EndIf
WEnd
_SQLite_Close()
Return $all_num
EndFunc
;新增用户购买信息
Func _add_user_and_item_info($user_name,$user_phone,$brand_name,$item_name,$num,$price,$ps,$dispart,$time)
_SQLite_Open($sql_name)
Local $sql = "INSERT INTO user_item_table values(null,'"&$user_name&"','"&$user_phone&"','"&$brand_name&"','"&$item_name&"','"&$num&"','"&$price&"','"&$dispart&"','" & $ps & "','" & $time & "','0','','0','','','','0','','" & $krw & "');"
$return_code = _SQLite_Exec(-1, $sql)
If $return_code = 0 Then
_SQLite_Close()
Return 1
Else
_SQLite_Close()
Return 0
EndIf
EndFunc
;查找所有的用户购买信息
Func _find_all_user_buy_item_info($main_listbox)
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($main_listbox))
_SQLite_Open($sql_name)
Local $sql = "SELECT * FROM user_item_table ORDER BY ID DESC;"
_SQLite_Query(-1, $sql, $hQuery)
While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK
$Temp = $aRow[0]
If $Temp == "" Then
_SQLite_Close()
Return "没有插入任何数据,我什么都找不到。"
Else
_GUICtrlListView_AddItem($main_listbox, $aRow[0])
_GUICtrlListView_AddSubItem($main_listbox, _GUICtrlListView_FindInText($main_listbox, $aRow[0]), $aRow[1], 1)
_GUICtrlListView_AddSubItem($main_listbox, _GUICtrlListView_FindInText($main_listbox, $aRow[0]), $aRow[2], 2)
_GUICtrlListView_AddSubItem($main_listbox, _GUICtrlListView_FindInText($main_listbox, $aRow[0]), $aRow[3], 3)
_GUICtrlListView_AddSubItem($main_listbox, _GUICtrlListView_FindInText($main_listbox, $aRow[0]), $aRow[4], 4)
_GUICtrlListView_AddSubItem($main_listbox, _GUICtrlListView_FindInText($main_listbox, $aRow[0]), $aRow[6], 5)
_GUICtrlListView_AddSubItem($main_listbox, _GUICtrlListView_FindInText($main_listbox, $aRow[0]), $aRow[5], 6)
_GUICtrlListView_AddSubItem($main_listbox, _GUICtrlListView_FindInText($main_listbox, $aRow[0]), $aRow[9], 7)
If $aRow[10] = 0 Then
_GUICtrlListView_AddSubItem($main_listbox, _GUICtrlListView_FindInText($main_listbox, $aRow[0]), "没给钱呢", 8)
ElseIf $aRow[10] = 1 Then
_GUICtrlListView_AddSubItem($main_listbox, _GUICtrlListView_FindInText($main_listbox, $aRow[0]), "已付款", 8)
EndIf
If $aRow[12] = 0 Then
_GUICtrlListView_AddSubItem($main_listbox, _GUICtrlListView_FindInText($main_listbox, $aRow[0]), "否", 9)
ElseIf $aRow[12] = 1 Then
_GUICtrlListView_AddSubItem($main_listbox, _GUICtrlListView_FindInText($main_listbox, $aRow[0]), "是", 9)
EndIf
_GUICtrlListView_AddSubItem($main_listbox, _GUICtrlListView_FindInText($main_listbox, $aRow[0]), $aRow[13], 10)
If $aRow[16] = 0 Then
_GUICtrlListView_AddSubItem($main_listbox, _GUICtrlListView_FindInText($main_listbox, $aRow[0]), "无反馈", 11)
ElseIf $aRow[16] = 1 Then
_GUICtrlListView_AddSubItem($main_listbox, _GUICtrlListView_FindInText($main_listbox, $aRow[0]), "已完成", 11)
EndIf
EndIf
WEnd
_SQLite_Close()
EndFunc
;~ "CREATE TABLE IF NOT EXISTS user_item_table (id INTEGER PRIMARY KEY ASC," & _
;~ "user_name Text, phone_num Text, brand_name Text, item_name Text," & _
;~ "buy_num Text, real_price Text, disparity_price Text, description Text, " & _
;~ "buy_time Text, is_pay Text, pay_time Text," & _
;~ "is_deliver Text, deliver_goods_time Text, order_path Text, modify_time Text,"& _
;~ "is_success Text,success_time Text,exchange_rate Text);"
;通过多状态查找当前的订购信息
Func _find_user_item_by_time_name_pay_deliver_success($main_listbox,$time_from,$time_to,$user,$pay_choose,$deliver_choose,$success_choose)
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($main_listbox))
_SQLite_Open($sql_name)
Local $set_string = ""
Local $sql = "SELECT * FROM user_item_table WHERE "
If StringLen($time_from) <> 0 Or StringLen($user) <> 0 Or StringLen($pay_choose) == 1 Or StringLen($deliver_choose) == 1 Or StringLen($success_choose) == 1 Then
If StringLen($time_from) <> 0 And StringLen($time_to) <> 0 Then
$sql &= " buy_time > '" & $time_from & "' AND buy_time < '" & $time_to & "' AND"
EndIf
If StringLen($user) <> 0 Then
$sql &= " user_name = '" & $user & "' AND"
EndIf
If StringLen($pay_choose) <> 0 Then
$sql &= " is_pay = '" & $pay_choose & "' AND"
EndIf
If StringLen($deliver_choose) <> 0 Then
$sql &= " is_deliver = '" & $deliver_choose & "' AND"
EndIf
If StringLen($success_choose) <> 0 Then
$sql &= " is_success = '" & $success_choose & "' AND"
EndIf
$sql = StringReplace($sql,"AND"," ORDER BY ID DESC;",-1)
;~ $sql &= $sub_sql
Else
$sql &= " 1=1 ORDER BY ID DESC;"
EndIf
_SQLite_Query(-1, $sql, $hQuery)
While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK
$Temp = $aRow[0]
If $Temp == "" Then
_SQLite_Close()
MsgBox(0,"INFO","按照当前条件进行搜索,没有任何的记录信息。")
Return $set_string
Else
_GUICtrlListView_AddItem($main_listbox, $aRow[0])
_GUICtrlListView_AddSubItem($main_listbox, _GUICtrlListView_FindInText($main_listbox, $aRow[0]), $aRow[1], 1)
_GUICtrlListView_AddSubItem($main_listbox, _GUICtrlListView_FindInText($main_listbox, $aRow[0]), $aRow[2], 2)
_GUICtrlListView_AddSubItem($main_listbox, _GUICtrlListView_FindInText($main_listbox, $aRow[0]), $aRow[3], 3)
_GUICtrlListView_AddSubItem($main_listbox, _GUICtrlListView_FindInText($main_listbox, $aRow[0]), $aRow[4], 4)
_GUICtrlListView_AddSubItem($main_listbox, _GUICtrlListView_FindInText($main_listbox, $aRow[0]), $aRow[6] * $aRow[5], 5)
_GUICtrlListView_AddSubItem($main_listbox, _GUICtrlListView_FindInText($main_listbox, $aRow[0]), $aRow[5], 6)
_GUICtrlListView_AddSubItem($main_listbox, _GUICtrlListView_FindInText($main_listbox, $aRow[0]), $aRow[9], 7)
If $aRow[10] = 0 Then
_GUICtrlListView_AddSubItem($main_listbox, _GUICtrlListView_FindInText($main_listbox, $aRow[0]), "没给钱呢", 8)
ElseIf $aRow[10] = 1 Then
_GUICtrlListView_AddSubItem($main_listbox, _GUICtrlListView_FindInText($main_listbox, $aRow[0]), "已付款", 8)
EndIf
If $aRow[12] = 0 Then
_GUICtrlListView_AddSubItem($main_listbox, _GUICtrlListView_FindInText($main_listbox, $aRow[0]), "否", 9)
ElseIf $aRow[12] = 1 Then
_GUICtrlListView_AddSubItem($main_listbox, _GUICtrlListView_FindInText($main_listbox, $aRow[0]), "是", 9)
EndIf
_GUICtrlListView_AddSubItem($main_listbox, _GUICtrlListView_FindInText($main_listbox, $aRow[0]), $aRow[13], 10)
If $aRow[16] = 0 Then
_GUICtrlListView_AddSubItem($main_listbox, _GUICtrlListView_FindInText($main_listbox, $aRow[0]), "无反馈", 11)
ElseIf $aRow[16] = 1 Then
_GUICtrlListView_AddSubItem($main_listbox, _GUICtrlListView_FindInText($main_listbox, $aRow[0]), "已完成", 11)
EndIf
$set_string = $set_string & "|" & $aRow[0] & "~" & $aRow[1] & "~" & $aRow[2] & "~" & $aRow[3] & "~" & $aRow[4] & "~" & $aRow[6] * $aRow[5] & "~" & $aRow[5] & "~" & $aRow[10] & "~" & $aRow[12] & "~" & $aRow[16] & "~" & $aRow[14]
EndIf
WEnd
_SQLite_Close()
Return $set_string
EndFunc
http://www.techug.com/10-algorithm-help-programmer-grow-up