[EXCEL]商品保质期管理

news/2025/4/21 9:02:58/

先看看界面

首页

数据库

已售数据库

信息录入

功能介绍:

      根据录入的商品信息,查询是否过期。盘存后点击过期日期,将已售罄商品信息保存到已售数据库中并删除数据库中信息。

代码:

ThisWorkbook

Private Sub Workbook_BeforeClose(Cancel As Boolean)Call clear_ClickActiveWorkbook.Save
End Sub

UserForm1

Private Sub btn_tj_Click()Application.ScreenUpdating = False  '关闭屏幕刷新Dim n%Dim ctltxt_pch.Value = txt_txm.Value & "-" & txt_scrq.ValueIf Not Sheets("Data").[A:A].Find(txt_pch.Value) Is Nothing ThenMsgBox "该批次号商品已存在!"Elsen = Sheets("Data").[A65536].End(xlUp).Row + 1With Sheets("Data").Cells(n, "A").Value = txt_pch.Value '批次号.Cells(n, "B").Value = txt_txm.Value '条形码.Cells(n, "C").Value = txt_spmc.Value '商品名称.Cells(n, "D").Value = txt_sl.Value '数量.Cells(n, "E").Value = txt_jhsj.Value '进货时间.Cells(n, "F").Value = txt_scrq.Value '生产日期.Cells(n, "G").Value = txt_bzq.Value '保质期.Cells(n, "H").Value = txt_gqrq.Value '过期时间.Cells(n, "I").Value = txt_txts.Value '提醒天数.Cells(n, "J").Value = txt_txrq.Value '提醒日期End WithMsgBox "商品信息已添加!"ActiveWorkbook.SaveApplication.ScreenUpdating = True   '开启屏幕刷新End IfFor Each ctl In Me.ControlsIf ctl.Name Like "txt*" Then'MsgBox c.Namectl.Text = ""End IfNextMe.txt_txm.SetFocusEnd SubPrivate Sub txt_bzq_Exit(ByVal Cancel As MSForms.ReturnBoolean)Dim scrq, gqrqIf Me.txt_bzq <> "" And IsNumeric(Me.txt_bzq) Thenscrq = Left(Me.txt_scrq, 4) & "/" & Mid(Me.txt_scrq, 5, 2) & "/" & Right(Me.txt_scrq, 2)gqrq = DateAdd("d", Me.txt_bzq, scrq)Me.txt_gqrq = Format(gqrq, "YYYYMMDD")ElseMsgBox "保质期必须为数字!"Cancel = TrueMe.txt_bzq = ""Me.txt_bzq.SetFocusEnd IfEnd SubPrivate Sub txt_scrq_Exit(ByVal Cancel As MSForms.ReturnBoolean)Dim scrq, gqrqscrq = Left(Me.txt_scrq, 4) & "/" & Mid(Me.txt_scrq, 5, 2) & "/" & Right(Me.txt_scrq, 2)If IsDate(scrq) And Len(Me.txt_scrq) = 8 ThenMe.txt_pch = Me.txt_txm & "-" & Me.txt_scrqElseMsgBox "日期格式错误!"Cancel = TrueMe.txt_scrq = ""Me.txt_scrq.SetFocusEnd IfEnd SubPrivate Sub txt_txts_Exit(ByVal Cancel As MSForms.ReturnBoolean)Dim gqrq, txrq, txtsgqrq = Left(Me.txt_gqrq, 4) & "/" & Mid(Me.txt_gqrq, 5, 2) & "/" & Right(Me.txt_gqrq, 2)If IsNumeric(Me.txt_txts) = False ThenMsgBox "提醒天数必须是数字!"Cancel = TrueMe.txt_txts = ""Me.txt_txts.SetFocusElseIf IsDate(gqrq) And Len(Me.txt_gqrq) = 8 Thentxts = CInt(Me.txt_txts) * -1txrq = DateAdd("d", txts, gqrq)Me.txt_txrq = Format(txrq, "YYYYMMDD")ElseMsgBox "日期格式错误!"Cancel = TrueMe.txt_scrq = ""Me.txt_scrq.SetFocusEnd IfEnd Sub

模块1


Sub add_Click()Worksheets("Data").ActivateWorksheets("Data").SelectUserForm1.Show
End SubSub query_Click()Call clear_ClickDim n%, i%, txrq, y, m, d 'txrq提醒日期Application.ScreenUpdating = False  '关闭屏幕刷新'MsgBox Format(Now(), "YYYY年" & "MM月" & "DD日")n = Sheets("Data").Range("J" & Rows.Count).End(xlUp).Row    '获取表 Data J列最大行数'MsgBox nFor i = n To 2 Step -1txrq = Sheets("Data").Cells(i, "J")y = Left(txrq, 4)m = Mid(txrq, 5, 2)d = Right(txrq, 2)txrq = DateSerial(y, m, d)If Now() > txrq ThenSheets("Main").Rows(6).InsertSheets("Data").Rows(i).Copy Sheets("Main").Rows(6)End IfNext iApplication.ScreenUpdating = True   '开启屏幕刷新Range("A1").Select
End SubSub clear_Click()Dim n%Application.ScreenUpdating = False  '关闭屏幕刷新n = Sheets("Main").[A65536].End(xlUp).Row   '获取最大数据行数If n > 5 Then Range(Rows(6), Rows(n)).Delete    '删除第6行到最大数据行Application.ScreenUpdating = True  '开启屏幕刷新
End Sub

 


http://www.ppmy.cn/news/720244.html

相关文章

牙膏的妙用

1&#xff0e;电熨斗用久了&#xff0c;其底部会积一层煳锈。可在电熨斗断电冷却的情况下&#xff0c;在底部抹上少许牙膏&#xff0c;用干净软布轻轻擦拭&#xff0c;即可将糊锈除去。 2&#xff0e;手电筒的反光镜日久发黑&#xff0c;用细纱布沾少许牙膏轻擦&#xff0c;就…

一支口红用了5年_一支口红多久该扔掉?保质期过了还能用吗?

夏日约惠盛典 前段时间“关于口红保质期”上了热搜 很多妹子表示想让各大色号出小样 因为专柜买的太肉疼了&#xff01; 保质期太短了&#xff0c;这支没涂完 下一支就过期了 而且涂来涂去也不过是那几个颜色 所以口红小样就是天才发明 即使快速集齐24铅笔色 钱包也不会瞬间干瘪…

品甜蜜“醇时代”,享幸福“鑫品质”豫鑫糖醇盛装亮相2023生物发酵展

品甜蜜“醇时代”&#xff0c;享幸福“鑫品质”河南豫鑫糖醇盛装亮相BIO CHINA2023第11届济南生物发酵展&#xff0c;诚邀您莅临参观。 BIO CHINA2023第11届济南生物发酵展&#xff0c;将于3月30-4月1号山东国际会展中心盛大开幕&#xff01;目前已成为生物发酵产业一年一度行业…

食品保质期提醒应用 android,保质期提醒app

保质期提醒app是一款非常有趣的生活工具软件&#xff0c;这款软件可以为我们记录生活上各种食品的保质期&#xff0c;我们选择的生活中&#xff0c;家里经常会碰到各种商品经常过期了还不知道&#xff0c;有些食品一旦过期的&#xff0c;吃了对身体还有害&#xff0c;用户一旦有…

燕教授使用体验,从漱口水到牙膏

龋齿、口臭、牙龈红肿等口腔问题关乎每个人的生活幸福感&#xff0c;因此使用一些有助于解决口腔问题的产品是很重要的。 牙膏、漱口水是我们日常生活中常用到管理口腔健康的产品&#xff0c;但是其作用效果良莠不齐&#xff0c;很难选到一款效果好且适合的产品。 前不久&…

一支口红用了5年_一支口红可以用多久 口红保质期

大家知道一支口红可以用多久吗&#xff0c;口红保质期是多久呢&#xff1f;口红开封了可以用多久呢&#xff1f;口红可以怎么用呢&#xff1f;今天就一起来看看吧&#xff01; 一支口红可以用多久 口红和其他所有化妆品一样&#xff0c;作为工业生产的产物&#xff0c;都有它们…

PG系列(opengauss)普通用户通过函数来查看data_directory等目录参数值

直接上函数语句: 必须以超级用户来创建 create function public.list_settings() returns setof pg_catalog.pg_settings as $$ select *from pg_catalog.pg_settings; $$ language sql security definer;参数解释&#xff1a; security definer&#xff1a;是以创建者的权限来…

氟离子选择性电极测定含氟牙膏中氟含量

1-实验目的&#xff1a; 1、了解氟离子选择性电极的基本结构及工作原理。 2、掌握离子选择性电极的电位测定法。 3、掌握电位分析中标准曲线定量方法。 2-实验原理&#xff1a; 牙膏中的微量氟对人的牙齿具有保健作用&#xff0c;使用含氟牙膏可以防止龋齿&#xff0c;但过…