1
Answer

the datetime variable value not null it always minvalue

nany nabil

nany nabil

11y
1.7k
1
i have aform that filter data usig four controls..we can filter using one or more control....so the controls may be null and this is the problem 
this is my aspx page code 


   <asp:EntityDataSource ID="BuyEntityDataSource" runat="server" ConnectionString="name=StockyEntities"
                    DefaultContainerName="StockyEntities" EnableFlattening="False" EntitySetName="Buys"
                    Include="Supplier" Where="(it.OrganizationID=@OrganizationID) AND (it.BuyDate >= @DateFrom or @DateTo IS NULL ) AND ( it.BuyDate <= @DateTo or @DateTo IS NULL ) AND (it.InvoiceNumber=@BuyID or @BuyID IS NULL) AND (it.Supplier.SupplierName=@Supplier or @Supplier IS NULL)"
                    EntityTypeFilter="Buy">
                    <WhereParameters>
                        <asp:Parameter Type="Int64" Name="BuyID" />
                        <asp:Parameter Type="String" Name="Supplier" />
                        <asp:Parameter Type="DateTime" Name="DateFrom" />
                        <asp:Parameter Type="DateTime" Name="DateTo" />
                        <asp:SessionParameter DefaultValue="1" Name="OrganizationID" SessionField="OrganizationID"
                            Type="Int32" />
                    </WhereParameters>
                </asp:EntityDataSource>




and this is the code in aspx.cs file code ... so what can i do ..... please help me quicky ...



  DateTime fromDate; DateTime.TryParseExact(FromDateTextBox.Text, "dd/MM/yyyy", null, System.Globalization.DateTimeStyles.None, out fromDate);  //if the control is null it retruns Minvalue (1/1/0001 12:00:00 AM)
            DateTime toDate; DateTime.TryParseExact(ToDateTextBox.Text, "dd/MM/yyyy", null, System.Globalization.DateTimeStyles.None, out toDate);  //if the control is null it retruns Minvalue (1/1/0001 12:00:00 AM)
            string BuyId = BuyIDTextBox.Text;
            string SupplierName = SupplierTextBox.Text;
            string fromDateString = fromDate.ToString();//to current culture format
            string toDateString = toDate.ToString();//to current culture format
            BuyEntityDataSource.WhereParameters["DateTo"].DefaultValue = toDateString;
            BuyEntityDataSource.WhereParameters["DateFrom"].DefaultValue = fromDateString;
            BuyEntityDataSource.WhereParameters["Supplier"].DefaultValue = SupplierName;
            BuyEntityDataSource.WhereParameters["BuyID"].DefaultValue = BuyId;





Answers (1)
0
Lalit M

Lalit M

NA 6.7k 47.9k 15y
Best Practices for FileSystemWatcher

1. Use a shared file queue and only add to the queue in the event handlers
as stated in here: and
to avoid the buffer over-flow limitations and file open limitations.
2. Use two separate FileSystemWatchers to monitor a folder; one for files
and one for folders. You need a separate one for folders, because a move
(cut and paste) operation on a folder will not always generate events for the
individual files within the moved folder but only the renamed event for the
folder name. Thus you will have to call GetFiles() yourself.
3. To minimize duplicate events, do not edit the shared queue but remove
duplicates before adding to the queue with a simple string dictionary of
order; save the last 5 or 10 file names with the TimeStamp and if the same
file name occurs within the last 500 ms than do not add to the queue.
This is all needed because of the following limitations I have come across:

Issues with FileSystemWatcher:

1. Some File / Directory events result in duplicate events being raised.
Example: Edit a file in Notepad and you will get duplicate events. Edit a
file in MS Word and you will get multiple events as it uses a temp file in
that folder (create, change, rename, delete). For example, when a file is
moved from one directory to another, several OnChanged and some OnCreated and
OnDeleted events might be raised. Likewise, some applications (for example,
antivirus software) might cause additional file system events that are
detected by FileSystemWatcher.
2. If my process changes the file, the FSW calls me. How do I know I was
the only one who changed it?
3. Can get buffer over-flow quite easily.
4. Files are not always closed when an event is raised.
5. When moving a watched subfolder within a watched folder the files are not
detected BUT new files are detected if a non-watched folder is moved into a
watched folder.