add undo and comments

This commit is contained in:
Trowbridge 2020-02-14 17:24:02 -05:00
parent 3932e224f0
commit 3b3785dbd8
8 changed files with 173 additions and 84 deletions

BIN
build.frx

Binary file not shown.

View File

@ -21,6 +21,29 @@ Private Sub cbCancel_Click()
End Sub
Private Sub cbUndo_Click()
Dim logid As Integer
Dim i As Integer
Dim fail As Boolean
For i = 0 To Me.lbHist.ListCount - 1
If Me.lbHist.Selected(i) Then
Call handler.undo_changes(x(i, 5), fail)
If fail Then
MsgBox ("undo did not work")
Exit Sub
End If
End If
Next i
Sheets("Orders").PivotTables("PivotTable1").PivotCache.Refresh
Me.Hide
End Sub
Private Sub lbHist_Change()
Dim i As Integer

Binary file not shown.

View File

@ -67,9 +67,10 @@ Private Sub butAdjust_Click()
Dim fail As Boolean
Dim com As String
com = InputBox("Enter any comments to describe the change")
If adjust("source") = "" Then
MsgBox ("No adjustments provided")
Exit Sub
End If
Call handler.request_adjust(JsonConverter.ConvertToJson(adjust), fail)
If fail Then
@ -77,6 +78,8 @@ Private Sub butAdjust_Click()
Exit Sub
End If
Me.tbCOM = ""
Me.Hide
Set adjust = Nothing

BIN
fpvt.frx

Binary file not shown.

View File

@ -98,6 +98,10 @@ Sub pg_main_workset(rep As String)
wr = .ResponseText
End With
If Mid(wr, 1, 1) <> "{" Then
MsgBox (wr)
Exit Sub
End If
Set json = JsonConverter.ParseJson(wr)
ReDim res(json("x").Count, 32)
@ -107,34 +111,34 @@ Sub pg_main_workset(rep As String)
res(i, 2) = json("x")(i)("ship_cust_descr")
res(i, 3) = json("x")(i)("shipto_group")
res(i, 4) = json("x")(i)("quota_rep_descr")
res(i, 5) = json("x")(i)("director_descr")
res(i, 5) = json("x")(i)("director")
res(i, 6) = json("x")(i)("segm")
res(i, 7) = json("x")(i)("mod_chan")
res(i, 8) = json("x")(i)("mod_chansub")
res(i, 9) = json("x")(i)("majg_descr")
res(i, 10) = json("x")(i)("ming_descr")
res(i, 11) = json("x")(i)("majs_descr")
res(i, 12) = json("x")(i)("mins_descr")
res(i, 13) = json("x")(i)("brand")
res(i, 14) = json("x")(i)("part_family")
res(i, 15) = json("x")(i)("part_group")
res(i, 16) = json("x")(i)("branding")
res(i, 17) = json("x")(i)("color")
res(i, 18) = json("x")(i)("part_descr")
res(i, 19) = json("x")(i)("order_season")
res(i, 20) = json("x")(i)("order_month")
res(i, 21) = json("x")(i)("ship_season")
res(i, 22) = json("x")(i)("ship_month")
res(i, 23) = json("x")(i)("request_season")
res(i, 24) = json("x")(i)("request_month")
res(i, 25) = json("x")(i)("promo")
res(i, 26) = json("x")(i)("version")
res(i, 27) = json("x")(i)("iter")
res(i, 28) = json("x")(i)("value_loc")
res(i, 29) = json("x")(i)("value_usd")
res(i, 30) = json("x")(i)("cost_loc")
res(i, 31) = json("x")(i)("cost_usd")
res(i, 32) = json("x")(i)("units")
res(i, 7) = json("x")(i)("chan")
res(i, 8) = json("x")(i)("chansub")
res(i, 9) = json("x")(i)("part_descr")
res(i, 10) = json("x")(i)("part_group")
res(i, 11) = json("x")(i)("branding")
res(i, 12) = json("x")(i)("majg_descr")
res(i, 13) = json("x")(i)("ming_descr")
res(i, 14) = json("x")(i)("majs_descr")
res(i, 15) = json("x")(i)("mins_descr")
res(i, 16) = json("x")(i)("order_season")
res(i, 17) = json("x")(i)("order_month")
res(i, 18) = json("x")(i)("ship_season")
res(i, 19) = json("x")(i)("ship_month")
res(i, 20) = json("x")(i)("request_season")
res(i, 21) = json("x")(i)("request_month")
res(i, 22) = json("x")(i)("promo")
res(i, 23) = json("x")(i)("value_loc")
res(i, 24) = json("x")(i)("value_usd")
res(i, 25) = json("x")(i)("cost_loc")
res(i, 26) = json("x")(i)("cost_usd")
res(i, 27) = json("x")(i)("units")
res(i, 28) = json("x")(i)("version")
res(i, 29) = json("x")(i)("iter")
res(i, 30) = json("x")(i)("logid")
res(i, 31) = json("x")(i)("comment")
res(i, 32) = json("x")(i)("module")
Next i
res(0, 0) = "bill_cust_descr"
@ -142,34 +146,34 @@ Sub pg_main_workset(rep As String)
res(0, 2) = "ship_cust_descr"
res(0, 3) = "shipto_group"
res(0, 4) = "quota_rep_descr"
res(0, 5) = "director_descr"
res(0, 5) = "director"
res(0, 6) = "segm"
res(0, 7) = "mod_chan"
res(0, 8) = "mod_chansub"
res(0, 9) = "majg_descr"
res(0, 10) = "ming_descr"
res(0, 11) = "majs_descr"
res(0, 12) = "mins_descr"
res(0, 13) = "brand"
res(0, 14) = "part_family"
res(0, 15) = "part_group"
res(0, 16) = "branding"
res(0, 17) = "color"
res(0, 18) = "part_descr"
res(0, 19) = "order_season"
res(0, 20) = "order_month"
res(0, 21) = "ship_season"
res(0, 22) = "ship_month"
res(0, 23) = "request_season"
res(0, 24) = "request_month"
res(0, 25) = "promo"
res(0, 26) = "version"
res(0, 27) = "iter"
res(0, 28) = "value_loc"
res(0, 29) = "value_usd"
res(0, 30) = "cost_loc"
res(0, 31) = "cost_usd"
res(0, 32) = "units"
res(0, 7) = "chan"
res(0, 8) = "chansub"
res(0, 9) = "part_descr"
res(0, 10) = "part_group"
res(0, 11) = "branding"
res(0, 12) = "majg_descr"
res(0, 13) = "ming_descr"
res(0, 14) = "majs_descr"
res(0, 15) = "mins_descr"
res(0, 16) = "order_season"
res(0, 17) = "order_month"
res(0, 18) = "ship_season"
res(0, 19) = "ship_month"
res(0, 20) = "request_season"
res(0, 21) = "request_month"
res(0, 22) = "promo"
res(0, 23) = "value_loc"
res(0, 24) = "value_usd"
res(0, 25) = "cost_loc"
res(0, 26) = "cost_usd"
res(0, 27) = "units"
res(0, 28) = "version"
res(0, 29) = "iter"
res(0, 30) = "logid"
res(0, 31) = "comment"
res(0, 32) = "module"
Set json = Nothing
@ -253,34 +257,34 @@ Function request_adjust(doc As String, ByRef fail As Boolean) As Object
res(i - 1, 2) = json("x")(i)("ship_cust_descr")
res(i - 1, 3) = json("x")(i)("shipto_group")
res(i - 1, 4) = json("x")(i)("quota_rep_descr")
res(i - 1, 5) = json("x")(i)("director_descr")
res(i - 1, 5) = json("x")(i)("director")
res(i - 1, 6) = json("x")(i)("segm")
res(i - 1, 7) = json("x")(i)("mod_chan")
res(i - 1, 8) = json("x")(i)("mod_chansub")
res(i - 1, 9) = json("x")(i)("majg_descr")
res(i - 1, 10) = json("x")(i)("ming_descr")
res(i - 1, 11) = json("x")(i)("majs_descr")
res(i - 1, 12) = json("x")(i)("mins_descr")
res(i - 1, 13) = json("x")(i)("brand")
res(i - 1, 14) = json("x")(i)("part_family")
res(i - 1, 15) = json("x")(i)("part_group")
res(i - 1, 16) = json("x")(i)("branding")
res(i - 1, 17) = json("x")(i)("color")
res(i - 1, 18) = json("x")(i)("part_descr")
res(i - 1, 19) = json("x")(i)("order_season")
res(i - 1, 20) = json("x")(i)("order_month")
res(i - 1, 21) = json("x")(i)("ship_season")
res(i - 1, 22) = json("x")(i)("ship_month")
res(i - 1, 23) = json("x")(i)("request_season")
res(i - 1, 24) = json("x")(i)("request_month")
res(i - 1, 25) = json("x")(i)("promo")
res(i - 1, 26) = json("x")(i)("version")
res(i - 1, 27) = json("x")(i)("iter")
res(i - 1, 28) = json("x")(i)("value_loc")
res(i - 1, 29) = json("x")(i)("value_usd")
res(i - 1, 30) = json("x")(i)("cost_loc")
res(i - 1, 31) = json("x")(i)("cost_usd")
res(i - 1, 32) = json("x")(i)("units")
res(i - 1, 7) = json("x")(i)("chan")
res(i - 1, 8) = json("x")(i)("chansub")
res(i - 1, 9) = json("x")(i)("part_descr")
res(i - 1, 10) = json("x")(i)("part_group")
res(i - 1, 11) = json("x")(i)("branding")
res(i - 1, 12) = json("x")(i)("majg_descr")
res(i - 1, 13) = json("x")(i)("ming_descr")
res(i - 1, 14) = json("x")(i)("majs_descr")
res(i - 1, 15) = json("x")(i)("mins_descr")
res(i - 1, 16) = json("x")(i)("order_season")
res(i - 1, 17) = json("x")(i)("order_month")
res(i - 1, 18) = json("x")(i)("ship_season")
res(i - 1, 19) = json("x")(i)("ship_month")
res(i - 1, 20) = json("x")(i)("request_season")
res(i - 1, 21) = json("x")(i)("request_month")
res(i - 1, 22) = json("x")(i)("promo")
res(i - 1, 23) = json("x")(i)("value_loc")
res(i - 1, 24) = json("x")(i)("value_usd")
res(i - 1, 25) = json("x")(i)("cost_loc")
res(i - 1, 26) = json("x")(i)("cost_usd")
res(i - 1, 27) = json("x")(i)("units")
res(i - 1, 28) = json("x")(i)("version")
res(i - 1, 29) = json("x")(i)("iter")
res(i - 1, 30) = json("x")(i)("logid")
res(i - 1, 31) = json("x")(i)("comment")
res(i - 1, 32) = json("x")(i)("module")
Next i
Set json = Nothing
@ -517,6 +521,65 @@ Function list_changes(doc As String, ByRef fail As Boolean) As Variant()
End Function
Function undo_changes(ByVal logid As Integer, ByRef fail As Boolean) As Variant()
Dim req As New WinHttp.WinHttpRequest
Dim json As Object
Dim wr As String
Dim i As Integer
Dim j As Integer
Dim res() As Variant
Dim doc As String
Dim ds As Worksheet
doc = "{""logid"":" & logid & "}"
server = handler.server
With req
.Option(WinHttpRequestOption_SslErrorIgnoreFlags) = SslErrorFlag_Ignore_All
.Open "GET", server & "/undo_change", True
.SetRequestHeader "Content-Type", "application/json"
.Send doc
.WaitForResponse
wr = .ResponseText
End With
Set json = JsonConverter.ParseJson(wr)
logid = json("x")(1)("id")
'---------loop through and get a list of each row that needs deleted?-----
Set ds = Sheets("data")
j = 0
For i = 1 To 100
If ds.Cells(1, i) = "logid" Then
j = i
Exit For
End If
Next i
If j = 0 Then
MsgBox ("current data set is not tracking changes, cannot isolate change locally")
fail = True
Exit Function
End If
i = 2
While ds.Cells(i, 1) <> ""
If ds.Cells(i, j) = logid Then
ds.Rows(i).Delete
Else
i = i + 1
End If
Wend
End Function
Sub history()
changes.Show

BIN
openf.frx

Binary file not shown.

BIN
part.frx

Binary file not shown.