|
So I have this list of customer invoices that I need to just group into a list of
Customers
Customers by State,
Customers by City, or Street Address if there are multiple locations in a city
But on a small check, I got a duplicate, 2 customers in Tempe AZ with the same street address.
I did something wrong here but not sure what.
'Group all the Customers together from gInvoices_all
Dim gCustomers As List(Of model_itemDistribution_Invoices) = gInvoices_all.OrderBy(Function(ob) ob.FCUSTNO).GroupBy(Function(v) New With {Key v.FCUSTNO, Key v.FSSTATE, Key v.FSADDR1}).Select(Function(cl) New model_itemDistribution_Invoices() With {
.FCUSTNO = cl.First().FCUSTNO,
.FSSTATE = cl.First().FSSTATE,
.FSADDR1 = cl.First().FSADDR1,
.FCOMPANY = cl.First().FCOMPANY,
.FSALESPN = cl.First().FSALESPN,
.FCONTACT = cl.First().FCONTACT,
.FPHONE = cl.First().FPHONE,
.FSADDR2 = cl.First().FSADDR2,
.FSCITY = cl.First().FSCITY,
.FSZIPCODE = cl.First().FSZIPCODE,
.FSCOUNTRY = cl.First().FSCOUNTRY,
.FCSAMT = 0.0
}).ToList()
If it ain't broke don't fix it
|
|
|
|
|
At least one of the three columns you're grouping by will be different. Check for leading/trailing white-space, and if you're querying an in-memory collection, check the case of the values too.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I'll do a trim, startswith or contains and see what happens
If it ain't broke don't fix it
|
|
|
|
|
jkirkerx wrote: But on a small check, I got a duplicate, 2 customers in Tempe AZ with the same street address. Do these two customers have the same FCUSTNO, or different ones? I'd assume that the street address is not the primary key, or even a unique value.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
The duplicate has the same FCUSTNO, Same FSTATE, duplicate is the FADDR1
For now I ran the GroupBy twice and got a completly different result, less records but it looks correct.
If it ain't broke don't fix it
|
|
|
|
|
I've tried so many approaches... a simple "one-tier" JSON structure us easy, but when it comes to more complex objects, I cannot figure this out, despite help from various articles here and elsewhere (thought here aren't that many I've found.)
A typical structure I need to parse is like this:
{
"odata.metadata" : "blahblah",
"value" : [
{
"prop1" : 69,
"prop2" : 96,
"prop3" : "Blah",
"prop4" : "Blah",
"prop5" : [
{
"sub1" : 269,
"sub2" : 3,
"sub3" : "something",
"sub4" : null
}
],
"prop6" : []
},
{
"prop1" : 23,
"prop2" : 45,
"prop3" : "Blah2",
"prop4" : null,
"prop5" : [],
"prop6" : [
{
"sub1" : 169,
"sub2" : 7,
"sub3" : null,
"sub4" : "2017-10-01"
}
]
}
],
"odata.nextLink" : "blahblahURL"
}
They all have the same three top-level elements: "odata.metadata", "odata.nextLink" and "value", and it is only the "value" element that may differ - some will have more or fewer properties, but typically as above.
I start by defining a class:
Friend MustInherit Class Response
<JsonProperty("odata.metadata")>
Public MetaData As String
<JsonProperty("odata.nextLink")>
Public NextLink As String
End Class
Friend Class ClsTest
Inherits Response
<JsonProperty("value")>
Public Property TESTS() As Linq.JArray
End Class
I keep ClsTest separate as I may want to have different ones for different JSON structures, depending on what the final approach is....
then I can deserialize it in two different ways - if "json" is the string representing the object above:
1. using the class:
Dim cls As clsTest = JsonConvert.DeserializeObject(Of clsTest)(json)
2. or using a JObject
Dim jsonObject As Linq.JObject = JsonConvert.DeserializeObject(json)
but after each I can't get beyond extracting the "odata" values - I can't figure out how to get the "values" and read them into something I can work with in my application: - classes, lists arrays, whatever...
I realise this is still a rather general question and maybe not specific enough, but really any hints or help will be appreciated...
modified 15-Oct-17 7:53am.
|
|
|
|
|
bwah-ha - who needs help anyway! Woke up at 4 a.m. last night thinking "I could do it this way!" and lo and behold, it works! 
|
|
|
|
|
In my current (Windows Forms Application) project, I have a form which includes a number of DataGridViews, which are used to display tabular data for the user to look at and edit. The data sets are of known, fixed, size, and the DGVs are designed to allow the data sets to fit neatly within them. The ability to scroll the view (in any direction) is neither wanted nor needed.
I have disabled the scroll bars and set AllowUserToAddRows to false, but navigating down with the arrow keys still causes a blank row to appear at the bottom and the top row of data to disappear; arrowing all the way up reverses this. One odd aspect of this is that the scrolling up happens when you arrow down from the last but one to the last real row. If you use the mouse to select a cell in the last row and then try to arrow down, nothing happens.
There is what appears to be a fair amount of discussion of this problem in various places, but the solution generally given is to disable the scroll bars and set AllowUserToAddRows to false, which doesn't seem to work for me. I have also tried capturing the Scroll Event and repositioning the Selected Cell to the top of the DGV within it, which sort of works, but this has other unwanted side-effects. Has anyone else run into this problem and/or come up with a good solution?
|
|
|
|
|
After spending a lot of time researching this, I was able to come up with a solution which works, but there should be an easier way! There are a lot of 'gotchas', apparently 'baked in' to the design of the control. Not only does the view scroll up (by default) when you arrow down into a cell in the last row, but it also scrolls up if you arrow left or right while in the last row.
Implementing my solution involves a number of steps:
1) Subclass the DataGridView control so that you can (optionally) override its ProcessCmdKey method to disable special handling of the arrow keys (you don't actually need to mess with the up arrow key, but I found it easier to disable all of them.
2) Substitute references to your new MyDataGridView control for those to the original version in the containing Form's Designer.vb file - for me, using VS 2013, two references needed to be changed for each affected control. Then, either in the designer or in initialization code, set the option to disable the arrow keys for the modified controls.
3) Write code for the KeyUp and KeyDown Events for each affected control - the KeyDown code does apparently need to be there, but it only has to set the Handled event argument to True; the KeyUp code has to do the work of changing the current cell appropriately for the arrow key pressed. For any arrow keystroke that results in a move to a cell in the bottom row (including a lateral one), the KeyUp code also has to set the control's FirstDisplayedScrollingRowIndex Property to 0 after implementing the move. This is what scrolls the view back down again to abolish the empty row, but it does cause a visible 'glitch'.
4) If you don't want the view to appear to 'glitch' when the user is moving to or on the bottom row, it is best to surround the working KeyUp code with calls to disable and re-enable screen painting while it is (in effect) moving the focus about.
|
|
|
|
|
My question is about that I want to change this demo's menustrip's font? How can I change? https://www.codeproject.com/Articles/18429/An-XML-Driven-Menu-Strip
Thank you for helping!!! 
|
|
|
|
|
|
Hello,
how can I change the fomat from the
Worksheets(Db).Cells(uGeraet, 1).Value to add it to the sheetname.
Whole code sample:
Sheets.Add
ActiveSheet.Name = "Example" & Worksheets(Db).Cells(uGeraet, 1).Value
Thanks
|
|
|
|
|
ActiveSheet.Name = "Example" & Worksheets(Db).Cells(uGeraet, 1).Value.ToString()
|
|
|
|
|
i have developed software in vb language for agriculture field. Software is design basic sprinkler irrigation system and calculate tentative quot for that design. please give some software details which is done in same subbejects.
|
|
|
|
|
We still do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.
Try it yourself, you may find it is not as difficult as you think!
If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Member 13451330 wrote: please give some software details which is done in same subbejects
That is called research and this is the wrong place to do that research. You need to search for the existing software and papers on that software design in the subject you are supposed to be learning about.
Once you have found the details you need and if you have trouble with the coding then feel free to ask those questions here.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Please tell mi the software developmnt in agriculture sector with vb language. I am agriculture student persuing masters in Irrigation Water Management from Govt university. i have done Sprinkler irrigation design software but i need more help regarding with irrigation and vb language.
|
|
|
|
|
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.
Try it yourself, you may find it is not as difficult as you think!
If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I have 2 tables in the same database.
tblAircraft - ACID, ACName
tblMaster - MasterID, ACID, and many others that are not relevant to my question.
tblAircraft is a lookup table with all the aircraft listed. tblMaster is the main table and holds all the detail information.
I have a DataGridView that has several columns. Column 1 is a combobox column that has the ACName from tblAircraft. The rest of the columns are textbox columns with data from tblMaster. My application works as far as displaying all the data and I can use a dataadapter update command to update tblMaster (good) and the other datasource updates tblAircraft (bad) with the DataGridView. My problem is that I want ACID in tblMaster to be updated with the ACID from the combobox. Of course it won't because it belongs to the datasource for tblAircraft. How can I use the selection in the combo box to update the tblMaster table along with the other fields in the DataGridView?
I have spent hours and hours trying to figure this out. I hope my explanation is clear. Thank you in advance for any help you can provide.
<pre>
Private Sub cboAC_SelectionChangeCommitted(sender As Object, e As EventArgs) Handles cboAC.SelectionChangeCommitted
dsACGrid = LoadDataSet()
'Refreshes DataGridView
If dgvTasks.ColumnCount > 0 Then
For i As Integer = 0 To dgvTasks.ColumnCount - 1
dgvTasks.Columns.RemoveAt(0)
Next
End If
'Connection obj to database
Conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\SupportGeneral.accdb"
Dim cbColumn As New DataGridViewComboBoxColumn With
{
.DataPropertyName = "ACName",
.DataSource = dsACGrid.Tables(1),
.DisplayMember = "ACName",
.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing,
.Name = "cbColumn",
.HeaderText = "Aircraft",
.SortMode = DataGridViewColumnSortMode.NotSortable,
.ValueMember = "ACName"
}
dgvTasks.Columns.Insert(0, cbColumn)
Dim GSTask As New DataGridViewTextBoxColumn With {.DataPropertyName = "GSTask", .HeaderText = "Gen Spt Task"}
Dim LCOMTask As New DataGridViewTextBoxColumn With {.DataPropertyName = "LCOMTask", .HeaderText = "LCOM Task"}
Dim AFSC As New DataGridViewTextBoxColumn With {.DataPropertyName = "AFSC", .HeaderText = "AFSC"}
Dim ReqSkill As New DataGridViewTextBoxColumn With {.DataPropertyName = "ReqSkill", .HeaderText = "Req Skill"}
Dim ReqGrade As New DataGridViewTextBoxColumn With {.DataPropertyName = "ReqGrade", .HeaderText = "Req Grade"}
Dim NotesQuestions As New DataGridViewTextBoxColumn With {.DataPropertyName = "NotesQuestions", .HeaderText = "Notes/Questions"}
Dim AvgTimeHours As New DataGridViewTextBoxColumn With {.DataPropertyName = "AvgTimeHours", .HeaderText = "Avg Time-Hours"}
Dim CrewSizeMin As New DataGridViewTextBoxColumn With {.DataPropertyName = "CrewSizeMin", .HeaderText = "Crew Size Min"}
Dim CrewSizeMax As New DataGridViewTextBoxColumn With {.DataPropertyName = "CrewSizeMax", .HeaderText = "Crew Size Max"}
Dim Manhours As New DataGridViewTextBoxColumn With {.DataPropertyName = "Manhours", .HeaderText = "Manhours"}
Dim FreqQty As New DataGridViewTextBoxColumn With {.DataPropertyName = "FreqQty", .HeaderText = "Freq Qty"}
Dim FreqRate As New DataGridViewTextBoxColumn With {.DataPropertyName = "FreqRate", .HeaderText = "Freq Rate"}
Dim PAFSC As New DataGridViewTextBoxColumn With {.DataPropertyName = "PAFSC", .HeaderText = "PAFSC"}
Dim PAFSCQty As New DataGridViewTextBoxColumn With {.DataPropertyName = "PAFSCQty", .HeaderText = "PAFSC Qty"}
Dim AltAFSC1 As New DataGridViewTextBoxColumn With {.DataPropertyName = "AltAFSC1", .HeaderText = "Alt AFSC1"}
Dim AltAFSC1Qty As New DataGridViewTextBoxColumn With {.DataPropertyName = "AltAFSC1Qty", .HeaderText = "Alt AFSC1 Qty"}
Dim AltAFSC2 As New DataGridViewTextBoxColumn With {.DataPropertyName = "AltAFSC2", .HeaderText = "Alt AFSC2"}
Dim AltAFSC2Qty As New DataGridViewTextBoxColumn With {.DataPropertyName = "AltAFSC2Qty", .HeaderText = "Alt AFSC2 Qty"}
Dim AltAFSC3 As New DataGridViewTextBoxColumn With {.DataPropertyName = "AltAFSC3", .HeaderText = "Alt AFSC3"}
Dim AltAFSC3Qty As New DataGridViewTextBoxColumn With {.DataPropertyName = "AltAFSC3Qty", .HeaderText = "Alt AFSC3 Qty"}
Dim AltAFSC4 As New DataGridViewTextBoxColumn With {.DataPropertyName = "AltAFSC4", .HeaderText = "Alt AFSC4"}
Dim AltAFSC4Qty As New DataGridViewTextBoxColumn With {.DataPropertyName = "AltAFSC4Qty", .HeaderText = "Alt AFSC4 Qty"}
Dim ACSelected As New DataGridViewCheckBoxColumn With {.DataPropertyName = "ACSelected", .HeaderText = "Selected"}
With dgvTasks
.AutoGenerateColumns = False
.Columns.AddRange(New DataGridViewColumn() {GSTask, LCOMTask, AFSC, ReqSkill, ReqGrade,
NotesQuestions, AvgTimeHours, CrewSizeMin, CrewSizeMax, Manhours, FreqQty, FreqRate,
PAFSC, PAFSCQty, AltAFSC1, AltAFSC1Qty, AltAFSC2, AltAFSC2Qty,
AltAFSC3, AltAFSC3Qty, AltAFSC4, AltAFSC4Qty, ACSelected})
End With
'Bind the dataset after all operation to the datagrid
dgvTasks.DataSource = dsACGrid.Tables(0)
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
Conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\SupportGeneral.accdb"
'Loads dropdown for aircraft type
Dim strSQL As String = "Select * from tblAircraft"
Dim daAC As OleDbDataAdapter = New OleDbDataAdapter(strSQL, Conn)
daAC.Fill(dsAC, "tblAircaft")
Dim dr As DataRow = dsAC.Tables(0).NewRow()
dr("ACName") = ""
dsAC.Tables(0).Rows.InsertAt(dr, 0)
Using cmd As New OleDbCommand(strSQL, Conn)
With cboAC
.DataSource = dsAC.Tables(0)
.DisplayMember = "ACName"
.ValueMember = "ACName"
End With
End Using
dsAC.Tables.RemoveAt(0)
End Sub
Private Function LoadDataSet() As DataSet
Conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\SupportGeneral.accdb"
'This code refreshes the datasets and data tables.
If dtACGrid.Rows.Count > 0 Then
dsACGrid.Tables.RemoveAt(0)
dtACGrid.Clear()
End If
If dtAircraft.Rows.Count > 0 Then
dsACGrid.Tables.RemoveAt(0)
dtAircraft.Clear()
End If
dsACGrid.Tables.Add(dtACGrid)
'Load Master table
strACGrid = "select * from tblMaster where ACName = '" & cboAC.SelectedValue & "'"
daACGrid = New OleDbDataAdapter(strACGrid, Conn)
cbACGrid = New OleDbCommandBuilder(daACGrid)
cbACGrid.QuotePrefix = "["
cbACGrid.QuoteSuffix = "]"
daACGrid.Fill(dtACGrid)
dsACGrid.Tables.Add(dtAircraft)
'Load Aircraft table
strACGrid = "select * from tblAircraft"
daACGrid = New OleDbDataAdapter(strACGrid, Conn)
cbACGrid = New OleDbCommandBuilder(daACGrid)
cbACGrid.QuotePrefix = "["
cbACGrid.QuoteSuffix = "]"
daACGrid.Fill(dtAircraft)
Return dsACGrid
End Function
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
daACGrid.Update(dtACGrid)
Me.Close()
End Sub
End Class
</pre>
|
|
|
|
|
This is a design issue, the way most of us settle it is not to allow editing in a complex (more than 1 or 2 editable fields) DGV.
I make the user doubleclick on the row that want to edit and pop a dialog box. An Add button allows you to pop an empty dialog box for entry.
Then save the AC details getting the ID as a return value, then save the detail record with the ACID.
Better still is to break your form into 2 forms, a list of aircraft and an Aircraft form with 2 areas, Aircraft details as the parent (single record) area with the details in the grid. User doubleclicks on the aircraft in the list form and the aircraft form displays, then the user maintains the Aircraft details in the top panel and doubleclicks the detail row to maintain.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I am creating a some PDF and Word docs on the fly, using itextsharp and an Aspose component for each respectively, importing some images. The raw images are 1000x1000 px, which is way too large - I need to fit two per page, above each other (and some text). I find they have to be no bigger than 300x300 for my requirements.
I can take two approaches:
1) import the images as are, and display them at 300x300 using appropriate object properties
2) re-size the images first to 300x300 then import these and display them at that size.
Approach 1) works beautifully. But with 14 such images the final product is over about 14MB - somewhat large for emailing.
Approach 2) works... but the image quality is lousy. Below is my code for re-sizing the images - my questions is:
Can this code be improved - and how come the docs can re-size them on the fly and retain such high quality, but this code is so bad?
The images are PNG's.
Private Function ResizePlayoutImage(ByVal sFile As String) As Boolean
Try
Dim FullSizeImage As System.Drawing.Image
FullSizeImage = System.Drawing.Image.FromFile(xmlPath & "Playout_images\\" & sFile)
If FullSizeImage.Width = 300 Then
FullSizeImage.Dispose()
If File.Exists(xmlPath & "Edited_images\\" & sFile) Then File.Delete(xmlPath & "Edited_images\\" & sFile)
File.Copy(xmlPath & "Playout_images\\" & sFile, xmlPath & "Edited_images\\" & sFile)
Else
Dim tmp As Bitmap
Dim gX As System.Drawing.Graphics
tmp = New Bitmap(300, 300)
gX = System.Drawing.Graphics.FromImage(tmp)
gX.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic
gX.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality
gX.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality
gX.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality
gX.DrawImage(FullSizeImage, 0, 0, 300, 300)
If File.Exists(xmlPath & "Edited_images\\" & sFile) Then File.Delete(xmlPath & "Edited_images\\" & sFile)
tmp.Save(xmlPath & "Edited_images\\" & sFile, System.Drawing.Imaging.ImageFormat.Png)
tmp.Dispose()
gX.Dispose()
FullSizeImage.Dispose()
End If
Return True
Catch ex As Exception
adp.WriteLog("ResizePlayoutImage", ex.Message & vbCrLf & sFile)
Return False
End Try
End Function
(PS there's something not quite right in the editor here, CP - NB I have to add a \ before any quotes or it messes up the display - but of course the code doesn't need that.)
modified 3-Oct-17 8:58am.
|
|
|
|
|
A_Griffin wrote: something not quite right in the editor here, CP - NB I have to add a \ Most likely because you have use language neutral <pre> tags round your code block. Use the code button to select the appropriate programming language.
|
|
|
|
|
|
some one please help me in designing database tables to record financial transactions in a central university in india. we are using double entry system. database shall be used for in-house development team.
M KAMIL
|
|
|
|
|
Have a look through these data structures
Never underestimate the power of human stupidity
RAH
|
|
|
|
|