Commit ab14864b by Cam Hayes

Finished the changes discussed with Dave and Elias

parent aba393fe
......@@ -186,6 +186,7 @@ object FViewAddCustomer: TFViewAddCustomer
ElementID = 'btndelete'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnDeleteClick
end
object btnClose: TWebButton
Left = 19
......@@ -319,18 +320,6 @@ object FViewAddCustomer: TFViewAddCustomer
end>
DataSource = wdsShipTo
end
object btnAddAddress: TWebButton
Left = 190
Top = 420
Width = 96
Height = 25
Caption = 'Add Address'
ChildOrder = 21
ElementID = 'btnaddaddress'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnAddAddressClick
end
object edtShippingAddress: TWebEdit
Left = 190
Top = 460
......@@ -338,8 +327,10 @@ object FViewAddCustomer: TFViewAddCustomer
Height = 22
ChildOrder = 22
ElementID = 'edtshippingaddress'
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = edtShippingAddressChange
end
object edtShippingState: TWebEdit
Left = 190
......@@ -348,8 +339,10 @@ object FViewAddCustomer: TFViewAddCustomer
Height = 22
ChildOrder = 22
ElementID = 'edtshippingstate'
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = edtShippingAddressChange
end
object edtShippingContact: TWebEdit
Left = 190
......@@ -358,8 +351,10 @@ object FViewAddCustomer: TFViewAddCustomer
Height = 22
ChildOrder = 22
ElementID = 'edtshippingcontact'
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = edtShippingAddressChange
end
object edtShippingZip: TWebEdit
Left = 190
......@@ -368,8 +363,10 @@ object FViewAddCustomer: TFViewAddCustomer
Height = 22
ChildOrder = 22
ElementID = 'edtshippingzip'
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = edtShippingAddressChange
end
object edtShippingCity: TWebEdit
Left = 190
......@@ -378,20 +375,135 @@ object FViewAddCustomer: TFViewAddCustomer
Height = 22
ChildOrder = 22
ElementID = 'edtshippingcity'
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = edtShippingAddressChange
end
object memoShipBlock: TWebMemo
Left = 508
Top = 460
Width = 185
Height = 89
ElementID = 'memoshipblock'
Enabled = False
HeightPercent = 100.000000000000000000
SelLength = 0
SelStart = 0
WidthPercent = 100.000000000000000000
OnChange = edtShippingAddressChange
end
object memoAddressBlock: TWebMemo
Left = 162
Top = 86
Width = 185
Height = 89
ElementID = 'memoaddressblock'
Enabled = False
HeightPercent = 100.000000000000000000
SelLength = 0
SelStart = 0
WidthPercent = 100.000000000000000000
OnChange = memoAddressBlockChange
end
object btnAdd: TWebButton
Left = 19
Top = 535
Width = 96
Height = 25
Caption = 'Add'
ChildOrder = 84
ElementID = 'btnadd'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnAddClick
end
object btnShipSave: TWebButton
Left = 339
Top = 441
Width = 96
Height = 25
Caption = 'Save'
ChildOrder = 79
ElementID = 'btnshipconfirm'
ElementPosition = epRelative
HeightPercent = 100.000000000000000000
Role = 'null'
WidthPercent = 100.000000000000000000
OnClick = btnShipSaveClick
end
object btnShipCancel: TWebButton
Left = 339
Top = 480
Width = 96
Height = 25
Caption = 'Cancel'
ChildOrder = 79
ElementID = 'btnshipcancel'
ElementPosition = epRelative
HeightPercent = 100.000000000000000000
Role = 'null'
WidthPercent = 100.000000000000000000
OnClick = btnCancelClick
end
object btnClear: TWebButton
Left = 296
Top = 420
object btnShipDelete: TWebButton
Left = 339
Top = 410
Width = 96
Height = 25
Caption = 'Clear'
ChildOrder = 27
ElementID = 'btnclear'
Caption = 'Delete'
ChildOrder = 79
ElementID = 'btnshipdelete'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnShipDeleteClick
end
object btnShipEdit: TWebButton
Left = 339
Top = 511
Width = 96
Height = 25
Caption = 'Edit'
ChildOrder = 83
ElementID = 'btnshipedit'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnShipEditClick
end
object btnShipAdd: TWebButton
Left = 339
Top = 549
Width = 96
Height = 25
Caption = 'Add'
ChildOrder = 84
ElementID = 'btnshipadd'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnShipAddClick
end
object btn_confirm_delete: TWebButton
Left = 725
Top = 433
Width = 96
Height = 25
Caption = 'Delete'
ChildOrder = 82
ElementID = 'btn_confirm_delete'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btn_confirm_deleteClick
end
object edtFirstLine: TWebEdit
Left = 190
Top = 430
Width = 121
Height = 22
ChildOrder = 35
ElementID = 'edtfirstline'
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnClearClick
end
object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection
......@@ -482,4 +594,10 @@ object FViewAddCustomer: TFViewAddCustomer
FieldName = 'contact'
end
end
object tmrReturn: TWebTimer
Enabled = False
OnTimer = tmrReturnTimer
Left = 542
Top = 42
end
end
......@@ -5,9 +5,9 @@ object FAddOrder: TFAddOrder
object WebLabel1: TWebLabel
Left = 4
Top = 81
Width = 35
Width = 95
Height = 15
Caption = 'Search'
Caption = 'Search Customers'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
......@@ -16,7 +16,7 @@ object FAddOrder: TFAddOrder
Top = 81
Width = 113
Height = 15
Caption = 'Selected Company ID'
Caption = 'Selected Customer ID'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
......@@ -74,7 +74,7 @@ object FAddOrder: TFAddOrder
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 70.000000000000000000
Width = 90.000000000000000000
end
item
BorderWidth = 1
......@@ -119,7 +119,7 @@ object FAddOrder: TFAddOrder
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 382.000000000000000000
Width = 362.000000000000000000
end
item
BorderWidth = 1
......
......@@ -154,9 +154,9 @@ begin
// Set up column headers
TMSFNCGrid1.ColumnCount := 4;
TMSFNCGrid1.RowCount := 1;
TMSFNCGrid1.Cells[0, 0] := 'DBID';
TMSFNCGrid1.Cells[1, 0] := 'ID';
TMSFNCGrid1.Cells[2, 0] := 'Name';
TMSFNCGrid1.Cells[0, 0] := 'Customer Num';
TMSFNCGrid1.Cells[1, 0] := 'Customer ID';
TMSFNCGrid1.Cells[2, 0] := 'Customer Name';
TMSFNCGrid1.Cells[3, 0] := 'Address';
// Populate the grid with data from the dataset
......
......@@ -114,15 +114,15 @@ object FViewCustomers: TFViewCustomers
Columns = <
item
DataField = 'CUSTOMER_ID'
Title = 'Customer ID'
Title = 'Customer Num'
end
item
DataField = 'SHORT_NAME'
Title = 'Account Name'
Title = 'Customer ID'
end
item
DataField = 'NAME'
Title = 'Name'
Title = 'Customer Name'
end
item
DataField = 'START_DATE'
......
......@@ -22,7 +22,7 @@
<button id="btnaddcustomer" class="btn btn-secondary">Add Customer</button>
</div>
<div class="col-auto">
<label style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Company Account Name:</label>
<label style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Customer ID:</label>
<input id="edtfilter" type="text" class="form-control" style="width: 200px;" />
</div>
</div>
......
......@@ -15,7 +15,6 @@ uses
type
TFViewCustomers = class(TWebForm)
lblEntries: TWebLabel;
btnAddCustomer: TWebButton;
wcbPageSize: TWebComboBox;
pnlMessage: TWebPanel;
......@@ -30,6 +29,7 @@ type
xdwdsCustomersCUSTOMER_ID: TIntegerField;
wdbtcCustomers: TWebDBTableControl;
edtFilter: TWebEdit;
lblEntries: TWebLabel;
procedure WebFormCreate(Sender: TObject);
procedure btnAddCustomerClick(Sender: TObject);
procedure wdbtcCustomersDblClickCell(Sender: TObject; ACol, ARow: Integer);
......@@ -115,7 +115,7 @@ begin
else if (PageNumber * PageSize) < customerListLength then
begin
lblEntries.Caption := 'Showing entries ' + IntToStr((PageNumber - 1) * PageSize + 1) +
' - ' + IntToStr(PageNumber * PageSize) +
' - ' + IntToStr(customerListLength) +
' of ' + IntToStr(customerListLength);
end
else if (PageNumber * PageSize) >= customerListLength then
......
......@@ -38,25 +38,25 @@
<div class="col-12 col-md-8">
</div>
<h4 class="custom-h4 mt-3">Company</h4>
<h4 class="custom-h4 mt-3">Customer</h4>
<hr class="custom-hr">
<div class="row">
<div class="col-auto">
<label for="wdbe_first_name" class="form-label mt-2">Company Name:</label>
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Customer Name:</label>
<input id="edtcompanyname" type="text" class="form-control" style="width: 300px;" required/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Provide a Company Name.
Please Provide a Customer Name.
</div>
</div>
<div class="col-auto">
<label for="wdbe_first_name" class="form-label mt-2">Account Company Name:</label>
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Customer ID:</label>
<input id="edtaccountcompanyname"type="text" class="form-control" style="width: 150px" required/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Provide a Company Account Name.
Please Provide a Customer ID Name.
</div>
</div>
<div class="col-auto">
<label for="wdbe_first_name" class="form-label mt-2">In Quickbooks?:</label>
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">In Quickbooks?:</label>
<input id="edtinquickbooks"type="text" class="form-control" style="width: 150px"/>
</div>
</div>
......
......@@ -523,7 +523,7 @@ begin
else
FViewMain.ViewOrders('');
end
else
else
begin
asm
var confirmationModal = new bootstrap.Modal(document.getElementById('confirmation_modal'), {
......
......@@ -34,25 +34,25 @@
</div>
</nav>
<div class="row mx-5">
<h4 class="custom-h4 mt-3">Company</h4>
<h4 class="custom-h4 mt-3">Customer</h4>
<hr class="custom-hr">
<div class="row">
<div class="col-auto">
<label for="wdbe_first_name" class="form-label mt-2">Company Name:</label>
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Customer Name:</label>
<input id="edtcompanyname" type="text" class="form-control" style="width: 300px;" required/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Provide a Company Name.
Please Provide a Customer Name.
</div>
</div>
<div class="col-auto">
<label for="wdbe_first_name" class="form-label mt-2">Account Company Name:</label>
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Customer ID:</label>
<input id="edtaccountcompanyname"type="text" class="form-control" style="width: 150px" required/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Provide a Company Account Name.
Please Provide a Customer ID.
</div>
</div>
<div class="col-auto">
<label for="wdbe_first_name" class="form-label mt-2">In Quickbooks?:</label>
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">>In Quickbooks?:</label>
<input id="edtinquickbooks"type="text" class="form-control" style="width: 150px"/>
</div>
</div>
......
......@@ -34,25 +34,25 @@
</div>
</nav>
<div class="row mx-5">
<h4 class="custom-h4 mt-3">Company</h4>
<h4 class="custom-h4 mt-3">Customer</h4>
<hr class="custom-hr">
<div class="row">
<div class="col-auto">
<label for="wdbe_first_name" class="form-label mt-2">Company Name:</label>
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Customer Name:</label>
<input id="edtcompanyname" type="text" class="form-control" style="width: 300px;" required/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Provide a Company Name.
Please Provide a Customer Name.
</div>
</div>
<div class="col-auto">
<label for="wdbe_first_name" class="form-label mt-2">Account Company Name:</label>
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Customer ID:</label>
<input id="edtaccountcompanyname"type="text" class="form-control" style="width: 150px" required/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Provide a Company Account Name.
Please Provide a Customer ID.
</div>
</div>
<div class="col-auto">
<label for="wdbe_first_name" class="form-label mt-2">In Quickbooks?:</label>
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">In Quickbooks?:</label>
<input id="edtinquickbooks"type="text" class="form-control" style="width: 150px"/>
</div>
</div>
......
......@@ -129,11 +129,11 @@ object FViewOrders: TFViewOrders
end
item
DataField = 'ID'
Title = 'ID'
Title = 'Customer ID'
end
item
DataField = 'companyName'
Title = 'Company Name'
Title = 'Customer Name'
end
item
DataField = 'jobName'
......
......@@ -149,7 +149,7 @@ object FSearch: TFSearch
Top = 56
Width = 107
Height = 14
Caption = 'Search Companies:'
Caption = 'Search Customers:'
Font.Charset = ANSI_CHARSET
Font.Color = clBlack
Font.Height = -11
......@@ -162,9 +162,9 @@ object FSearch: TFSearch
object lblCompanyID: TWebLabel
Left = 174
Top = 56
Width = 68
Width = 72
Height = 14
Caption = 'Company ID:'
Caption = 'Customer ID:'
Font.Charset = ANSI_CHARSET
Font.Color = clBlack
Font.Height = -11
......@@ -207,9 +207,9 @@ object FSearch: TFSearch
object WebLabel5: TWebLabel
Left = 338
Top = 56
Width = 89
Width = 93
Height = 14
Caption = 'Company Name:'
Caption = 'Customer Name:'
Font.Charset = ANSI_CHARSET
Font.Color = clBlack
Font.Height = -11
......@@ -457,7 +457,7 @@ object FSearch: TFSearch
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 40.000000000000000000
Width = 80.000000000000000000
end
item
BorderWidth = 1
......@@ -502,7 +502,7 @@ object FSearch: TFSearch
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 320.000000000000000000
Width = 280.000000000000000000
end
item
BorderWidth = 1
......
......@@ -274,9 +274,9 @@ begin
// Set up column headers
TMSFNCGrid1.ColumnCount := 4;
TMSFNCGrid1.RowCount := 1;
TMSFNCGrid1.Cells[0, 0] := 'DBID';
TMSFNCGrid1.Cells[1, 0] := 'ID';
TMSFNCGrid1.Cells[2, 0] := 'Name';
TMSFNCGrid1.Cells[0, 0] := 'Customer Num';
TMSFNCGrid1.Cells[1, 0] := 'Customer ID';
TMSFNCGrid1.Cells[2, 0] := 'Customer Name';
TMSFNCGrid1.Cells[3, 0] := 'Address';
// Populate the grid with data from the dataset
......
......@@ -397,6 +397,7 @@ type
function AddUser(userInfo: string): string;
function AddItem(itemInfo: string): string;
function AddShippingAddress(Addressinfo: string): TJSONObject;
function DelShippingAddress(AddressID, CustomerID: string): TJSONObject;
function DelUser(username: string): string;
function DelOrder(orderID, orderType, UserID: string): TJSONObject;
function EditUser(const editOptions: string): string;
......
......@@ -55,6 +55,7 @@ type
function AddCuttingDieOrder(orderInfo: string): TJSONObject;
function AddShippingAddress(AddressInfo: string): TJSONObject;
function delOrder(OrderID, OrderType, UserID: string): TJSONObject;
function DelShippingAddress(AddressID, CustomerID: string): TJSONObject;
function GenerateSubQuery(currStatus: string): string;
......@@ -90,6 +91,38 @@ begin
inherited;
end;
function TLookupService.DelShippingAddress(AddressID, CustomerID: string): TJSONObject;
var
SQL: string;
ADDRESS_LIST: TJSONArray;
ADDRESS: TJSONObject;
begin
SQL := 'DELETE FROM customers_ship WHERE customer_ship_id = ' + AddressID;
OrdersDB.UniQuery1.SQL.Text := SQL;
OrdersDB.UniQuery1.ExecSQL;
result := TJSONObject.Create;
result.AddPair('status', 'Success:Address Successfully Deleted');
SQL := 'select * FROM customers c LEFT JOIN customers_ship s ON c.CUSTOMER_ID = s.customer_id WHERE c.CUSTOMER_ID = ' + CustomerID;
doQuery(ordersDB.UniQuery1, SQL);
ADDRESS_LIST := TJSONArray.Create;
while not ordersDB.UniQuery1.Eof do
begin
ADDRESS := TJSONObject.Create;
ADDRESS.AddPair('ADDRESS', ordersDB.UniQuery1.FieldByName('ship_block').AsString);
ADDRESS.AddPair('shipping_address', ordersDB.UniQuery1.FieldByName('address').AsString);
ADDRESS.AddPair('city', ordersDB.UniQuery1.FieldByName('city').AsString);
ADDRESS.AddPair('state', ordersDB.UniQuery1.FieldByName('state').AsString);
ADDRESS.AddPair('zip', ordersDB.UniQuery1.FieldByName('zip').AsString);
ADDRESS.AddPair('contact', ordersDB.UniQuery1.FieldByName('contact').AsString);
ADDRESS.AddPair('ship_id', ordersDB.UniQuery1.FieldByName('customer_ship_id').AsString);
ADDRESS_LIST.Add(ADDRESS);
ordersDB.UniQuery1.Next;
end;
Result.AddPair('ADDRESS', ADDRESS_LIST);
TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result);
end;
function TLookupService.GetCustomers: TCustomerList;
// Retrieves a list of customers and sends it to the client in object form.
// The object contains the ID, Name, Short Name, and the shipping address.
......@@ -142,10 +175,7 @@ begin
result.NAME := ordersDB.UniQuery1.FieldByName('NAME').AsString;
result.CUSTOMER_ID := ordersDB.UniQuery1.FieldByName('CUSTOMER_ID').AsInteger;
result.SHORT_NAME := ordersDB.UniQuery1.FieldByName('SHORT_NAME').AsString;
result.staff_fields_invoice_to := ordersDB.UniQuery1.FieldByName('BILL_ADDRESS').AsString +
', ' + ordersDB.UniQuery1.FieldByName('BILL_CITY').AsString +
', ' + ordersDB.UniQuery1.FieldByName('BILL_STATE').AsString +
' ' + ordersDB.UniQuery1.FieldByName('BILL_ZIP').AsString;
result.staff_fields_invoice_to := ordersDB.UniQuery1.FieldByName('BILL_ADDRESS_BLOCK').AsString;
result.START_DATE := ordersDB.UniQuery1.FieldByName('START_DATE').AsString;
result.BILL_ADDRESS := ordersDB.UniQuery1.FieldByName('BILL_ADDRESS').AsString;
result.BILL_CITY := ordersDB.UniQuery1.FieldByName('BILL_CITY').AsString;
......@@ -228,11 +258,18 @@ var
temp: string;
msg: string;
ship_block: string;
ADDRESS: TJSONObject;
ADDRESS_LIST:TJSONArray;
CustomerID: string;
JSONArray: TJSONArray;
Item: TAddressItem;
begin
result := TJSONObject.Create;
JSONData := TJSONObject.ParseJSONValue(AddressInfo) as TJSONObject;
if JSONData = nil then
raise Exception.Create('Invalid JSON format'); // If parsing fails, raise an exception
mode := JSONData.GetValue<string>('mode');
CustomerID := JSONData.GetValue<string>('customer_id');
if mode = 'EDIT' then
ShipID := JSONData.GetValue<integer>('customer_ship_id');
......@@ -267,26 +304,39 @@ begin
Field.AsString := Pair.JsonValue.Value;
end;
end;
//OrdersDB.UniQuery1.FieldByName('address').AsString := JSONData.GetValue<string>('shipping_address');
//TODO Ask about shipping block & link to quickbooks
// OrdersDB.UniQuery1.FieldByName('ship_block') := ship_block;
// Post the record to the database
ordersDB.UniQuery1.Post;
if mode = 'ADD' then
msg := 'Success:Shipping Address Successfully Added'
begin
msg := 'Success:Shipping Address Successfully Added';
end
else
msg := 'Success:Shipping Address Successfully Edited';
Result := TJSONObject.Create.AddPair('status', msg);
SQL := 'select * FROM customers c LEFT JOIN customers_ship s ON c.CUSTOMER_ID = s.customer_id WHERE c.CUSTOMER_ID = ' + CustomerID;
doQuery(ordersDB.UniQuery1, SQL);
ADDRESS_LIST := TJSONArray.Create;
while not ordersDB.UniQuery1.Eof do
begin
ADDRESS := TJSONObject.Create;
ADDRESS.AddPair('ADDRESS', ordersDB.UniQuery1.FieldByName('ship_block').AsString);
ADDRESS.AddPair('shipping_address', ordersDB.UniQuery1.FieldByName('address').AsString);
ADDRESS.AddPair('city', ordersDB.UniQuery1.FieldByName('city').AsString);
ADDRESS.AddPair('state', ordersDB.UniQuery1.FieldByName('state').AsString);
ADDRESS.AddPair('zip', ordersDB.UniQuery1.FieldByName('zip').AsString);
ADDRESS.AddPair('contact', ordersDB.UniQuery1.FieldByName('contact').AsString);
ADDRESS.AddPair('ship_id', ordersDB.UniQuery1.FieldByName('customer_ship_id').AsString);
ADDRESS_LIST.Add(ADDRESS);
ordersDB.UniQuery1.Next;
end;
Result.AddPair('status', msg);
Result.AddPair('ADDRESS', ADDRESS_LIST);
TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result);
except
on E: Exception do
begin
Result := TJSONObject.Create.AddPair('error', E.Message);
Result.AddPair('error', E.Message);
end
end;
end;
......
......@@ -2,7 +2,7 @@
MemoLogLevel=3
FileLogLevel=5
webClientVersion=0.9.2
LogFileNum=518
LogFileNum=537
[Database]
Server=192.168.159.131
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment