
penfold69
Avatar/Signature-
Posts
135 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by penfold69
-
Cast the indexed item from the arraylist to a point. like: int num = (Point)(a[0]).x;
-
Does this problem go away (briefly) when you close and reopen the IDE, and is your project "relatively" large? (over 80k lines in total) If so, you might want to look at: http://support.microsoft.com/kb/822690 I had this problem (bloody annoying!) but the hotfix seems to have cured it completely. B.
-
I recently took an existing VS2003 (Net1.1) Visual Basic project consisting of multiple assemblies, several Crystal reports, and three executables (a pretty complicated build!) and imported it into Visual Basic Express Edition 2005. I am happy to say that it came up with around 140 'warnings' (mainly unused variables and uninitialised variables) and NO uncompilable errors. It appears that the project importing transfers across any known changes between properties and methods to Net 2.0 quite effectively. B.
-
C# - Copying Rows between DataTables
penfold69 replied to EFileTahi-A's topic in Database / XML / Reporting
Don't use AcceptChanges at all. It marks the records as 'Accepted and unchanged' so the DataAdapter believes that they don't need to be updated into the database. B. -
Actually, with declarative syntax, you can handle multiple events by using a comma-delimited list of those events. Something like: Private Sub button_Click(.. blah blah args ..) Handles Button1.Click, Button2.Click, Button3.Click
-
Creating a "BETWEEN dates" SQL query...
penfold69 replied to EFileTahi-A's topic in Database / XML / Reporting
Unfortunately, the SQL-99 standard defines dates as being manipulated in the 'American style' of mm/dd/yyyy. As SQL is a text-only language, and can be input on a client in one regional setting, to be run on a server in another regional setting, there needed to be a 'standard' method of referring to dates. In this case, they decided that the US method would be fine for the 'standard'. I work around this using a couple of methods: 1. Use parameters. This will allow you to manipulate the dates using objects that are passed into your sqlCommand 2. Have date conversion functions I have a couple of functions, one most notably 'DateToSql' which allows me to pass in dates in various formats (as a DateTime, text string etc.) and will format appropriately based upon the server-type in use. I use this function for when I absolutely need the raw-speed of issuing an SQL command directly, and not have the associated overhead of parameters (which is absolutely miniscule in most cases) B. -
Playing the devils advocate on this one, its generally *bad practice* to make assumptions during coding - and the assumption that a machine has the ability to contact the internet is still (even in this day and age) "A Bad One " If you *can* make this assumption (eg: its an in-house product) you still need to decide upon the behaviour of your application if it cannot connect to the internet (e.g. a workman just sawed through your fiber!). If it is a commercial package, I'd consider offering something along the lines of the Windows Product Activation - a challenge/response system whereby an installation generates a code based upon "identifying parameters for the computer (as a hash)" that needs to be passed to yourselves (automatically, or by telephone) which generates a response to be entered (automatically, or by telephone). Once this 'code' has been verified, you can store this fact somewhere, along with the unique-to-that-computer hash in a licence file. The beauty of this method is that the license file can only be used on the one machine (because of the hash), and the return code can be configured to carry a 'payload' (eg an expiry date for the software, or 'activation' flags for certain modules) You can also periodically 'dial back' to your authentication server (auto/manual) to allow continued use of the package. Of course, any software-based system *can* be defeated, but the idea is to make it difficult for the 'average' Joe to circumvent. B.
-
I've been working with the Windows Forms datagrid (groan) for some time, and have built up a small collection of classes (that are by no means complete), that handle things like combobox columns, multiline textbox columns, clickable boolean columns, and coloured rows based on values. I'm wondering if some enterprising person would like to take a copy of these and host them somewhere (in source form) so that we, as a community, can create a complete datagrid control that exceeds the capability of the base Datagrid class. They're not very neat, and some work could be done to merge the functionality of them (for example, the colored rows code could be merged into the base datacolumn class, and then the combobox/multiline code could inherit from that class). I have to stress that its not "all" my own work - much thanks to authors here, and at vbcodecentral for a lot of the work and/or inspiration. So, if anyone would be interested, post here and I'll see if I can tidy up the code somewhat and pass it on. Barry.
-
Communicate my applicaction with other hardware devices.
penfold69 replied to Georgen's topic in Water Cooler
Why not look at a swipe-card solution? You can pick up card readers, or keyboards with built-in card readers. You can then access them using the relevant SDK (provided by the hardware vendor) B. -
If System.Diagnostics.Debugger.IsAttached = True Then
-
Altering 100's of 1000's of rows in MS SQL
penfold69 replied to TheWizardofInt's topic in Database / XML / Reporting
My confusion - I thought it was a MySQL database, not an MSSQL database :D -
CReport. reporting silently...
penfold69 replied to EFileTahi-A's topic in Database / XML / Reporting
dim rpt as new NameOfMyReport rpt.PrintToPrinter(1, True, 0, 0) rpt.Dispose() -
Altering 100's of 1000's of rows in MS SQL
penfold69 replied to TheWizardofInt's topic in Database / XML / Reporting
Are you using the ODBC connector, or the MySQL Connector/Net Gamma 1.0.4 ? B. -
They install side-by-side quite happily. I currently have 1.0 1.1 and 2.0 on my development machine B.
-
1. Select entire row when clicked: Private Sub grdData_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles grdData.MouseUp Dim hti As DataGrid.HitTestInfo = grdData.HitTest(e.X, e.Y) If hti.Type = DataGrid.HitTestType.Cell Then grdData.Select(hti.Row) End If End Sub Set individual column widths: Dim ts As New DataGridTableStyle Dim col1 As New DataGridTextBoxColumn col1.MappingName = "ID" col1.HeaderText = "ID" col1.Width = 0 col1.NullText = "" ts.GridColumnStyles.Add(col1) Dim col2 As New DataGridTextBoxColumn col2.MappingName = "ACTUAL_TIME" col2.HeaderText = "Time" col2.Width = 40 col2.NullText = "" ts.GridColumnStyles.Add(col2) ' Repeat for each column grdData.TablesStyles.Clear() grdData.TablesStyles.Add(ts) Make data displayed read only: grdData.ReadOnly = True
-
Check to see if a datatable contains datarows
penfold69 replied to cpopham's topic in Database / XML / Reporting
Assuming dsAcctInfo is a DataTable, simply do: If dsAcctInfo.Rows.Count > 0 then ' your code here End If If it is a DataSet, you would need to do something like: If dsAcctInfo.Tables(0).Rows.Count > 0 Then 'your code Here End If -
Yes, the default is as Hamlet described - I was merely showing that what you want to achieve *is* doable, its just not trivial. B.
-
To implement a MRU list in a menu, you will need to do the following: Decide on how to 'save' the information (XML file, registry entry). Personally, this is a good choice for a registry entry - this is how the Office suite actually store this information - check in regedit under: HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Common\Open Find\Microsoft Excel\Settings\Open\File Name MRU or HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSaveMRU Then, in your applications 'Open' routine, simply add the last opened file to your internal MRU list, and save that list. Whenever populating the menu, dynamically read from this list and create menu items. There is no 'automatic' method of doing this - it is up to the end user to write the code to do so. It is not particularly tricky at all. B
-
Getting the index of a ListView click.
penfold69 replied to haroldjclements's topic in Windows Forms
The listview has, by default, the ability to 'Multi-select', so the relevant item you're interested in is held in a collection. If you have disabled multiselect, you should be able to retrieve the index using: myListView.SelectedIndices(0) I'd personally put a check to ensure that at least ONE item is selected before issuing that code, or you will end up with an IndexOutOfBoundsException.. Something like: If myListView.SelectedIndices.Count >0 then myIndex = myListView.SelectedIndices(0) ' <your code here > End If Just like that! -
Yes, its doable. Create a form that takes a DataRowView in its constructor. From the DataRowView, populate the various controls on the form and allow the user to edit. Set the OK/Cancel buttons to DialogResult.OK and DialogResult.Cancel. Then, in the doubleclick event of the datagrid, find the currently selected row (.SelectedRow iirc?) and pass it (probably with a bit of Typing or casting) into an instance of your form, then show it using .ShowDialog. If the result of .ShowDialog is Ok, then return the values form the controls into the DataRowView (you can use binding, but I find it very inflexible) Then, when you've finished with the form displaying the grid itself, call your relevant DataAdapter.Update(Datatable) method to flush the changes back to the database. B.
-
Pull the MySQL Connetor/Net Gamma 1.0.3 down - it does include some code samples, but the libraries are based on the IConnection, IDataAdapter, IDataReader and ICommand interfaces, so usage is identical (in most respects) to the SqlClient libraries. If you need more help, give me a shout - I've implemented an abstract database layer for my application that uses the interfaces to allow me to connect to practically any supported database type :D B.
-
How do i draw my own toolbars and menu bars to be like this?
penfold69 replied to Winston's topic in Windows Forms
Hmm, the VB Power Pack looks interesting.. I don't suppose anyone actually has a copy they could send through to me - the GotDotNet workspaces are down (again) so I can't even download the damn things. Sigh. B. -
I'd like some input on the best way to calculate working days. On the surface, the problem seems simple - work out how many 'working days' are between two dates. For the purposes of this, a 'working day' is considered Monday to Friday. The tricky part is excluding Bank holidays, and Employee Holidays! I've currently plumped for a method that does the following: Public Function CalculateWorkingDaysBetweenDates(ByRef starttime As Date, ByRef endtime As Date, ByRef Rep As Long) As Long ' This function will calculate the number of working days between two dates Dim datecount As DateTime = starttime Dim endDays As Integer = 0 Dim sSql As String ' Check for rep holidays that start before and end after this period sSql = "SELECT COUNT(*) FROM LU_AM_HOLIDAY WHERE REP=" & Rep sSql &= " AND (START_DATE<'" & DateToSql(starttime.Date) & "' AND END_DATE>'" & DateToSql(endtime.Date) & "') " If App.DB.QueryDatabase(sSql) > 0 Then ' The holiday completely covers the requested time span endDays = 0 Return endDays End If While (datecount.Date <= endtime.Date) Select Case datecount.DayOfWeek Case DayOfWeek.Saturday Case DayOfWeek.Sunday Case Else endDays += 1 End Select datecount = datecount.AddDays(1) End While sSql = "SELECT COUNT(*) FROM LU_BHOL WHERE BHOL>='" & DateToSql(starttime.Date) & "' AND BHOL<='" & DateToSql(endtime.Date) & "' " Dim bhols As Long = Val(App.DB.QueryDatabase(sSql)) endDays -= bhols ' check for rep holidays that fall completely between these dates. sSql = "SELECT SUM(DAYS) FROM LU_AM_HOLIDAY WHERE REP=" & Rep sSql &= " AND (START_DATE>='" & DateToSql(starttime.Date) & "' AND END_DATE<='" & DateToSql(endtime.Date) & "') " Dim rephols As Long = Val(App.DB.QueryDatabase(sSql)) endDays -= rephols ' Check for rep holidays that start before this period and end during sSql = "SELECT * FROM LU_AM_HOLIDAY WHERE REP=" & Rep sSql &= " AND (START_DATE<'" & DateToSql(starttime.Date) & "' AND END_DATE>='" & DateToSql(starttime.Date) & "' AND END_DATE<= '" & DateToSql(endtime.Date) & "') " Dim dt As DataTable = App.DB.RetrieveTable(sSql) For index As Integer = 0 To dt.Rows.Count - 1 Dim row As DataRow = dt.Rows(index) rephols = CDate(row("END_DATE")).Subtract(starttime).Days endDays -= rephols Next ' Check for rep holidays that start during this period and end after sSql = "SELECT * FROM LU_AM_HOLIDAY WHERE REP=" & Rep sSql &= " AND (START_DATE>'" & DateToSql(starttime.Date) & "' AND START_DATE <= '" & DateToSql(endtime.Date) & "' AND END_DATE>'" & DateToSql(endtime.Date) & "') " dt = App.DB.RetrieveTable(sSql) For index As Integer = 0 To dt.Rows.Count - 1 Dim row As DataRow = dt.Rows(index) rephols = endtime.Subtract(row("START_DATE")).Days endDays -= rephols Next dt.Dispose() Return endDays End Function As you can see, this function makes several round trips to the server to request various records containing holidays and bank holidays. However, I'm looking for a neater solution. In addition, I would like a function that will take a start date, and a number of working days, and give me an end date. This too seems like a relatively simple problem. However, it actually is a little more complicated - as you discover 'skippable' days in your timespan, you have to extend your timespan, and therefore discover more 'skippable' days! In all, its a tricky problem that I'd like to elicit some discussion on - perhaps someone has tackled this before? Barry.
-
No Problems - and if you do have issues with it, the developers are available for one-to-one live chats and email conversations - now that is service! B.
-
Unfortunately, the .NET method of enabling "Xp Styles" is a little retarded - for example, tab controls don't actually work correctly, and various other controls break quite badly. I actualy use a product called Skybound Visual Styles, which is a drop-in component that will "XP-ise" your application with very little coding required. http://www.skybound.ca/developer/default.aspx The Visual Styles product is 'Free', but you can purchase a developer license to get access to the source code if required. The only problem I've had is nested groupboxes drawing slowly, but this is going to be addressed, apparently. Check it out - its VERY worth it! Barry.