376

(3 replies, posted in General)

Manix,
I threw together a quick and dirty project to demonstrate the use of an attached SQLite database as a second database using the commands Dimtry has shown. Keep in mind that to manipulate an attached database you need to use SQL because MVD does not recognize it in it's normal process.  I tried to somewhat mock what MVD does in updating the database.  Hope it helps

377

(5 replies, posted in General)

Very creative Manix and Brian.

378

(34 replies, posted in General)

Nice one Derek on the memo line feeds.

379

(34 replies, posted in General)

See attached.


frmInvoice.cbSIcustCountry.dbItemID := -1;

what the above line does?

This clears the dbitemid. For a new sale it was not cleared and showing a country for an empty customer.


2. How can I change each text line font style, size and color in supplier memo field?
For instance, making Supplier name line font size 10 and style underlined or bold.

Unfortunately you cannot change the font attributes on individual lines inside a memo field. What I did in the attached project is removed the memo field and created a panel with supplier labels inside it. Visually it looks the same with the exception that you can control fonts, colors, etc on the labels.


3. Is it possible to hide lines or copied fields within supplier memo field when there is no data entered for certain fields?. For instance if there is no city, lines moves up to fill blank (visially) space (I moved city to it's own line rather than having city, state and zip on same line) or if there is no state, can we move zip code to a left (filling the spacer)

I took care of this through script.


4. This would be a bonus if you also provide getting supplier fields into supplier memo field using SQLExecute. What you have done perfectly fine for this project. It'd be great reference info for my code repository for future projects.

I also took care of this. However, I know you are trying to learn various techniques and ways to do things, but you should try to stay away from doing extraneous SqlExecutes to retrieve data when MVD already has retrieved the data through normal processes.

380

(34 replies, posted in General)

Adam,
Since I don't have your most recent project, I used one of the previous projects to show how the memo field can be filled with the supplier fields which are already on the form but hidden.

381

(34 replies, posted in General)

Yes you can. Use the following:


frmInvoice.Memo1.Lines.add(.....);

Replace the dots with your data, either form fields or SqlExecute to retrieve the data. You need this line for each item (Name,Address,City, etc)

382

(4 replies, posted in General)

In addition to the OnShow event, you also need to place your code on the OnChange event as Math pointed out for both comboxes. And you should have an else along with it so it catches when it's equal such as


if frmassistencia.cbcriacaolocal.dbItemID <> frmassistencia.cbtransferido.dbitemid then
    frmassistencia.cbcriacaolocal.Color := clred else frmassistencia.cbcriacaolocal.Color := clDefault

If you want to color the text only, you can do the following

frmassistencia.cbcriacaolocal.Font.Color := clred else frmassistencia.cbcriacaolocal.Font.Color := clDefault

383

(34 replies, posted in General)

Check out the attached for a possible solution for the items of concern. No1, I don't think it's practical to have users put in new purchase invoices after a sale. No 2, the solution takes care of the traceability issue as Derek astutely pointed out. Basically a purchase invoice is maintained in play when a sale takes place. In other words, a sale will create a new sale invoice record while the purchase invoice remains in tact as is.

384

(4 replies, posted in General)

You can also do the following to get the table Id


procedure Form2_OnShow (Sender: string; Action: string);
begin
    Form2.Edit1.Value := Form2.ButtonSave.dbGeneralTableId;   // Make sure you use the button definition which does the save action
end;

I put an example in Derek's project.

385

(34 replies, posted in General)

Adam and Derek,

I may have the solution to both. Since I'm not sure how MVD constructs the sql when you have the same tablegrid also as the search. Its hard to say what its doing behind the scenes. So what I did was put together the query on the button. Doing this I know what its going to display.


I also fixed the tax rate problem. Derek was right. You have to get to the tax rate through the invoice.


My internet service had been going in and out so my fix is on my previous post. I wasn't able to get to Derek's solution.

386

(34 replies, posted in General)

Adam,

I'm in agreement with Derek. Not sure why you need to display the same field three times on the same form. Since there is only one tax field recorded, I basically put the same dbitemid, populated by Derek, into the other two tax fields on the refund form. The two lines follow Derek's lines.


As far as your other issues, I was not able to replicate them. I did notice that on one of your search buttons you were displaying the Tax.Id rather than the TaxRate. I changed that for you.

387

(34 replies, posted in General)

Adam,

I added a line to your purchase refund and a line to your sale refund. Look for "EHW - Added the following line". Also, I commented out a couple of lines on the refund buttons click event. They were not needed.

388

(1 replies, posted in General)

You have your calculation commented out. Just uncomment (remove slashes) and it works fine.


procedure computeTotal (Sender: string);
begin
      //frmZakaz.edTotal.Value := frmZakaz.edCost.Value*frmZakaz.edQ.Value;
end;

389

(12 replies, posted in General)

It's fixed.  See attached.


https://s21.postimg.org/ohwxcg0x3/Base_On_Close.png

390

(12 replies, posted in General)

I think you need to attach your project so we can determine what is going on. Otherwise it's just a guessing game on everybody's part.

391

(13 replies, posted in General)

David,

Make sure you place the $ sign in both the tablegrid settings and the Search button settings. I tested it and it works fine.

392

(5 replies, posted in General)

Thank you Dimitry. Was not aware of GetRowAtPos(x,y). The help file does not have this particular definition. It will undoubtedly come in handy to know. I'm sure Derek will be pleased. Thanks again.

393

(5 replies, posted in General)

Interesting there Derek. I understand what you want to do and I don't have an answer either. Apparently the "SelectedRow" property does not get updated till the full click (down and up) is completed.  So hopefully Dimitry will have a way to do it. It actually could be the beginning stages of a drag and drop type functionality as well.


For the challenge I put together a kind of alternative to your situation. I'm sure you probably already tested various scenarios including what I have so my alternative will probably not be right for your project, but I included it here in case it may be a fit for someone else's projects.


A click on the magnifying glass in the tablegrid will show the call memo. Another click anywhere except the magnifying glass on another row will remove the memo.

394

(6 replies, posted in General)

Adam,

Your way is fine. If you wanted to use my line then you can precede it with the following


If Form1.GridEmployees.Cells[2,Form1.GridEmployees.SelectedRow] = '' then
      Form1.DateTimePicker2.Checked := False else

Since the fields being populated are disabled, an alternative and probably the way I would go is to define the date field as text. Then it doesn't matter if it's empty or not. The you could replace my line with the following.


Form1.edDOB.Text := Form1.GridEmployees.Cell,Form1.GridEmployees.SelectedRow];

I put both ways in the attached.

395

(6 replies, posted in General)

Don't mean to step on your toes Derek. I had a couple of minutes to look at the project.  Adam, I think the problem lies with the ShowRecord on your hidden buttons plus the fields at the bottom of the form being directly linked to the database table. The ShowRecord is populating the fields at the bottom of each of the tabsheets as well as the search fields and that's what is messing up the tablegrid displays as you mentioned with incremental searches. I removed the linking of the fields to the table. I also removed the ShowRecord action from the hidden buttons and replaced it with script to populate the fields at the bottom of the tabsheets with the entries in the respective tablegrid. Hopefully I'm on target with the problem and solution for you.


Derek, if you have another way, by all means include it. I know there is usually more than one way to solve things in MVD.

396

(3 replies, posted in General)

You can also place the following inside the Save button OnClick event to stop it from saving another new record. Any subsequent field changes on the form will update the newly created record only.


 Form2.SaveButton.dbDontResetID := True;

397

(9 replies, posted in General)

Adam,
There's not a whole lot you can do with disabled components when it involves events. You could use popup hints but all the components would need to be set to ReadOnly and not disabled. Groupboxes cannot be set to Readonly. Each field would need to be set to Readonly. Since you said that your project would contain a lot of fields, it may not be feasible to do it this way. The closest I could come up with to do what you are looking for is attached. The combobox needs to be the first field to have focus on the form.

Derek (the master of little to no script and I say that warmly)

Prod_Lookup.TableGrid1.PopupMenu := nil disables the right-click popup menu from showing.

DBK, Derek,

I threw together a quick project to demonstrate a possible solution for you. First and foremost this project is by no means anywhere close to a productional app. My solution is along the same lines as to what Derek mentioned. I used a slightly different approach than the normal combobox methodology in MVD. The combobox for products is still there in order to make the connection to invoice items, but it is hidden. The lookup is done using a tablegrid instead. So on the invoice detail form the user can either type in a freeform text field or do a lookup into the product table. The lookup will fill in the invoice line item text field and price field from the product table. The invoice detail form will let you know whether you have a stock item or a non-stock item. If you have a stock item assigned to the line, you have the ability through a button to remove the stock item and put in a freeform text description in it's place. Hope it helps. If not, it was good practice for me anyway. LOL.

400

(6 replies, posted in General)

Here you go.