question

donbradman-4481 avatar image
0 Votes"
donbradman-4481 asked donbradman-4481 commented

Back and forth string format not converting and issues with CanExecute.

I've made a WPF app which takes data from a SQLite table and displays them in a datagrid after filtering using the combo box selected item and a further filter textbox if required. I've also added a CRUD form which appears after a row from the datagrid is selected and the respected column values are displayed in some textbox's and datepicker's.

I'm currently having a couple of issues with this app.

Issue 1:
I want the datepicker's to show the date in the format dd-MM-yyyy but when I save the data it should be saved in the database table in the yyyy-MM-dd format, but that is not happening.

Issue 2:
If I add the parameter CanDoSave in the Save button command i.e. SaveCommand = new RelayCommand(DoSave, CanDoSave); where

         bool CanDoSave(object param)
         {
    
             var bill = SelectedInv as Bills;
             float f = 0;
    
             if (string.IsNullOrEmpty(bill.Party) || string.IsNullOrEmpty(bill.BillNo)|| string.IsNullOrEmpty(bill.BillDt) || string.IsNullOrEmpty(bill.DueDt)||!float.TryParse(bill.Amt, out f))
             {
                 return false;
             }
    
    
             else
                 return true;
         }

I get an error
242676-image.png

How do I solve these.

I've shared by project here for checking/testing


windows-wpfdotnet-wpf-xaml
image.png (233.1 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi,@donbradman-4481 . I'm still looking for a solution, will be back with an update.

0 Votes 0 ·

Hello @HuiLiu-MSFT , is there any update ?

0 Votes 0 ·

0 Answers