|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{
OleDbConnection cn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\hesham\Desktop\Database2.accdb");
OleDbDataAdapter da;
DataTable dt = new DataTable();
OleDbCommand cmnd;
public Form1()
{
InitializeComponent();
filldatagridview();
}
void filldatagridview()
{
dt.Clear();
da = new OleDbDataAdapter("Select * From Table1 ", cn);
da.Fill(dt);
dataGridView1.DataSource = dt;
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
cmnd = new OleDbCommand("insert into Table1 values('" + textBox4.Text + "','" + textBox3.Text + "'," + Convert.ToInt32(textBox1.Text) + ",'" + textBox2.Text + "')", cn);
cn.Open();
cmnd.ExecuteNonQuery();
cn.Close();
filldatagridview();
MessageBox.Show("added success ", "add", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void dataGridView1_DoubleClick(object sender, EventArgs e)
{
textBox4.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString();
textBox3.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString();
textBox1.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString();
textBox2.Text = this.dataGridView1.CurrentRow.Cells[3].Value.ToString();
}
private void button2_Click(object sender, EventArgs e)
{
cmnd = new OleDbCommand("Update Table1 Set name ='" + textBox3.Text + "',age = '" + Convert.ToInt32(textBox1.Text) + "', address='" + textBox2.Text + "'Where id='" + textBox4.Text + "", cn);
cn.Open();
cmnd.ExecuteNonQuery();
cn.Close();
filldatagridview();
MessageBox.Show("edit success ", "edit", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void button3_Click(object sender, EventArgs e)
{
cmnd = new OleDbCommand("Delete From Table1 Where id='" + textBox4.Text + "", cn);
cn.Open();
cmnd.ExecuteNonQuery();
cn.Close();
filldatagridview();
MessageBox.Show("delete success ", "delete", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void button4_Click(object sender, EventArgs e)
{
Close();
}
}
}
|
|
|
|
|
Could some .... what?
You haven't asked a question or described a problem. Just posting a code dump doesn't do that.
|
|
|
|
|
Hello Gentlemen,
Could somebody give a good advise for the following :
I am an aspirant in learning c# and I wish to make a GUI that can read canbus J1939 engine data to read RPM .
I could read the can-bus data by tapping to the vessels engine can bus using a can to USB converter called kvaserCAN. I do understand the PGN data frames for the bytes 4 and 5 need to mathematically applied to find the product with .125 rpm / bit to get the right rpm. (byte 4 being the least )
basically how can we tap the can info on the USB port that does not fall on the usual com port but on the kvaser com port as we see it using the device manager.
appreciate if a sample code be shared to start bit by bit programming to be used on a C# .
Sincerely
|
|
|
|
|
Here[^] seem to be a load of examples.
noop()
|
|
|
|
|
Hi Phil , could not find the proper answer to the query ,,,,thanks anyways
kind regards
FIROZ
|
|
|
|
|
I need to do simulated annealing for facility planing with c# codes .. Im tryig but I couldnt
|
|
|
|
|
... and? You never asked a question or described any kind of problem, so it's pretty much impossible top guess what you're looking for.
|
|
|
|
|
It's time for you to get to work: now !
What research have you done on simulated annealing ? What algorithms have you implemented in what languages ?
You show us code; you ask specific questions about the code; you include error messages, and analysis of what you think is happening.
Then ... we help you.
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
|
|
|
|
|
I'm sure it is important - to you - but it's equally important that what you submit as your final project is your own work, not ours.
So if you have a problem, we'll help - but you have to show us what you have done. We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, it's part of your grades and it wouldn't be at all fair for us to do it all for you.
So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
If you "couldn't", change your major to something you can handle. Maybe French Literature, or Janitorial Science.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Hi all,
imagine this scenario:
- a tree structure is to be be built (edit/insert/delete nodes) by a group of several users
- the tree is expected to be quite large once finished (~100.000 nodes!)
- inserting, moving, copying/pasting nodes is required
- child nodes can result from individual requirements ("make a child node named A") or
from applying domain values (e.g. countries, currencies etc): "make child nodes for the
countries I select in a list".
My ideas so far:
- parent-child database table on MS SQL
- tree versioning similar to a sourcecode management system; each "check in" makes a new tree
version, so that older versions are present (for comparison, as copy/paste source)
- display in a multicolumn treeview using Infragistics Ultracontrols' UltraTree (present)
- nesting is done by parentID, and order of siblings (=children of the same parent)
is controlled by an additional integer value, so it can be changed ("move up/down").
Main problems:
- concurrency managment: my initial approach (timestamps for optimistic locking) could lead to
"outdated" branches, so that hours of work could not be saved, as the database status is newer
- key generation: classical parent-child-trees need keys to be referenced. Usually, I use
identity integer values in hierarchical dataset, so new nodes (-1, -2, -3) get their IDs on
dataset.Update, but here, the reference is recursive (not just hierarchical). Creating a branch
has to create the nodes "top down".
Of course, if a commercial solutions provides a way to edit/manage a huge tree with several users, I'd be glad not to have to reinvent the wheel.
Any ideas or hints?
Thanks!
Martin
|
|
|
|
|
That's not hard to ... imagine. But, imagining a single developer implementing this ... who is not already a wizard with an advanced DB that supports the features you describe ... that's hard.
There's lots of $ implementations out there: at the low end, checkout TreePad.
You might look into graph databases like Neo4j, or Amazon AWS Neptune (cloud), if you foresee the need for a highly connected set of entities where creating/manipulating linkages between nodes is critical.
A recent overview of graph DB's: [^]
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
modified 11-May-19 22:15pm.
|
|
|
|
|
Thanks, I'll have a look at these.
Maybe my replies to the others' Posts may provide deeper insight.
modified 13-May-19 8:33am.
|
|
|
|
|
atrus2711 wrote: Maybe my replies to the others' Posts may provide deeper insight. ... uhhh ... no ... I keep bumping into too many other blind wise men in the room with the elephant
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
|
|
|
|
|
Sorry, doesn't sound like an application.
atrus2711 wrote: child nodes can result from individual requirements ("make a child node named A") or
from applying domain values (e.g. countries, currencies etc): "make child nodes for the
countries I select in a list". From what list in which application? Let me guess, a "domain value" can be anything? The reason I'm sceptical is because I've seen this before; a tree that should hold everything (and then the spec stops).
atrus2711 wrote: - display in a multicolumn treeview using Infragistics Ultracontrols' UltraTree (present) Yuck. A treeview with a datagridview next to it would work better and probably perform better. You want to mix extra data (unknown # of columns) into a tree, displayed in a single control. I'd be going for a simple tree, loading only the expanded nodes, and only fetching the data for the grid on the selected node.
atrus2711 wrote: - concurrency managment: my initial approach (timestamps for optimistic locking) could lead to
"outdated" branches, so that hours of work could not be saved, as the database status is newer Most people lock the stuff that edited. If they are inserting the same info, then there's a problem with the workflow, not the application.
atrus2711 wrote: - key generation: classical parent-child-trees need keys to be referenced. Usually, I use
identity integer values in hierarchical dataset, so new nodes (-1, -2, -3) get their IDs on
dataset.Update, but here, the reference is recursive (not just hierarchical). Creating a branch
has to create the nodes "top down". You can still use a unique number, you just can't expect those numbers to stay sequential in the database. People will move branches, delete them; so the numbering won't stay consistent in the db.
Also, users don't like to have to expand over 10 branches just to get to their data. If the only stuff they work on is hidden three levels deep, I'll bet you that they want the tree to open THERE, without including all the stuff they're not using.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Thanks for your post.
The tree is a chart of accounts for a financial company, i.e. the root items are things like "assets", "liabilities", "Profit and loss" and "Notes", each of them having thousands (!) of sub-branches. The leafs are to be booked on to, the non-leafs are sums.
You don't want to know how this giant tree is built up to today.
Quote: Let me guess, a "domain value" can be anything
The whole tree consists of nodes which are "bookable accounts or "sum positions". Each of them can result from different reasons. E.g. some node might Need breakdown in currencies, another one is detailed in customer groups. The reasons vary, as the lawmakers/regulatory authorities' mind changes.
Quote: Yuck. A treeview with a datagridview next to it would work better and probably perform better.
For input, yes. But the tree has to show several columns and once, which the built-in treeviews in MS VisualStudio do not provide.
Quote: Most people lock the stuff that edited.
Not here, as the whole account plan has to be built and seen. A position like "other" might occur several times, but is not expressive itself: it's only the "fullpath" that Shows what the Position is talking about. "others" might be other customer types, currencies, ...
Quote: You can still use a unique number, you just can't expect those numbers to stay sequential in the database. People will move branches, delete them; so the numbering won't stay consistent in the db.
There's no need for sequential numbers. The Position in the tree would be determined by parentID and "location within siblings". Yet, the Keywould either be created by the database, resulting in a timelag between node Insertion and db roundtrip, or the Client would create a key itself (e.g. a GUID).
Quote: Also, users don't like to have to expand over 10 branches just to get to their data. If the only stuff they work on is hidden three levels deep, I'll bet you that they want the tree to open THERE, without including all the stuff they're not using.
I wish it was like this. Tree partitions are meaningless, as explained just above....
Maybe my replies to the others' Posts may provide deeper insight.
modified 13-May-19 8:32am.
|
|
|
|
|
atrus2711 wrote: There's no need for sequential numbers. The Position in the tree would be determined by parentID and "location within siblings". Yet, the Keywould either be created by the database, resulting in a timelag between node Insertion and db roundtrip, or the Client would create a key itself (e.g. a GUID). Table names are unique within their database. Meaning each row in each table in each db can be uniquely identified by using the primary key, tablename and databasename. That would give you a key for your tree that has a unique name for each node, one that can be used to backtrace the item it is supposed to represent in the database.
atrus2711 wrote: Not here, as the whole account plan has to be built and seen. ..but not edited in its whole - that's why there's table level locking for example. Again, a problem that has been solved already, there's a lot of databases out there where multiple users are editing data.
atrus2711 wrote:
For input, yes. But the tree has to show several columns and once, which the built-in treeviews in MS VisualStudio do not provide. Read the UX Guide. A treeview should not have tabular data. It is there to navigate to a node, not to display columns. That kind of data goes into another control that is specialized for that purpose, either a datagridview or a datalistview. See explorer, see regedit, see any decent application.
The idea that you "need" to edit a column as part of your tree in the same control is nonsense.
atrus2711 wrote: the root items are things like "assets", "liabilities", "Profit and loss" and "Notes", each of them having thousands (!) of sub-branches. Because there is NO other way of making a selection beforehand - it HAS to be part of the tree, and cannot simply be a button saying "Notes"
Good luck
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Quote: Table names are unique within their database. Meaning each row in each table in each db can be uniquely identified by using the primary key, tablename and databasename. That would give you a key for your tree that has a unique name for each node, one that can be used to backtrace the item it is supposed to represent in the database.
You are NOT suggesting to make a single table for each tree Version, are you? "Same things go in the same table". All tree items are - tree items.
Quote: ..but not edited in its whole - that's why there's table level locking for example. Again, a problem that has been solved already, there's a lot of databases out there where multiple users are editing data.
hmmmm... It's rather similiar to a "merge" function used in source code Management Systems like git or Subversion: you edit local code (= local changes of the plan), try to commit, and find that someone edited the items you were referring to. Git demands a "sort ort/merge" process. And that's not automated - one has to find out what is code to be accepted or rejected. It's not as easy as "John locked the table - get time to get some coffee..."...
Quote: Read the UX Guide. A treeview should not have tabular data. It is there to navigate to a node, not to display columns. That kind of data goes into another control that is specialized for that purpose, either a datagridview or a datalistview. See explorer, see regedit, see any decent application
Assumed we use a "single column tree": Which column would that be? The description? The ID? The "account number" used in the target (Downstream) system? Whatever it is: the others might by needed. Search can be assisted by a separate dialogue, but this would be - as you Claim - a nonhierachical "list". How would we distinguinsh the ~500 "other"-items, if not by their nesting (fullpath)?
Quote: Because there is NO other way of making a selection beforehand - it HAS to be part of the tree, and cannot simply be a button saying "Notes
Well - a new node in root "assets" will almost always "need" additional, non-determined nodes in the "Notes" section, thousands of accounts far away. Imagine that the new asset Position is e.g. "machines", then there'll be probably (as the authorities demand) "explaining" positions like "machines bought" and "machines sold" or non-sum-up-breakdowns like "of which..."... It's difficult, it's whatever the auditors decree, and it's definitely not cast to stones that the root nodes will be "assets", "liabilities" etc. forever. So, any button will not Show "Notes", but "Root". Whatever its Name is. We do not make up this hierachy. We are bound by law/regulation to implement it.
So, any irony is futile - the Auditors are right. Even if they're not.
|
|
|
|
|
atrus2711 wrote: You are NOT suggesting to make a single table for I always expect 3NF. Not a suggestion, but simply something that is expected.
atrus2711 wrote: And that's not automated - one has to find out what is code to be accepted or rejected. It's not as easy as "John locked the table - get time to get some coffee..."... Because someone has to authorize a new branch, because someone is responsible for the entire project (a project leader). That is not the case with simple data-editing. The checkin cannot be automated, because a machine cannot make that decision.
atrus2711 wrote: Assumed we use a "single column tree" A tree has no columns. You may link any kind or amount of columns to a node though.
atrus2711 wrote: We do not make up this hierachy. We are bound by law/regulation to implement it. Law does not state that you make a UI as useless as possible.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
You haven't described any "use cases". Nothing about number of users.
Talk of "huge", concurrent and versioning seems premature at this point.
It's actually easier to roll your own than you might think.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Thanks for your post.
Quote: You haven't described any "use cases". Nothing about number of users.
Yes I did:
- several users (Ok, Detail to ~5-10, all working on LAN in one floor)
- use cases: inserting, editing, deleting, moving, copying nodes.
Quote: Talk of "huge", concurrent and versioning seems premature at this point.
Well, compared to the way it's done until now, it's not premature, it's high time.
Huge = Needs a decent way of keeping track (cannot be memorized by a account Guru).
Concurrent: There's no single Editor who takes care of the tree. A whole Division is working on it.
Versioning: the trees Change over time, whenever the legislators/regulatory authorities decree a new set of reporting demands. Last year, we used Version 8236, this year, we need a new tree with some new Detail positions and some dropped ones.
And, finally, of cause this tree is not "isolated" in the application I imagine. It is fed ("exported") to a Company application which uses business rules to "route" postings (etc) to the positions in the tree. And no, it's not SAP.
"Route interest postings of construction customers in Belgium, caused by loans backed by mortgages meant for constructing shopping malls located in Ghana, to positon thisandthat."
Maybe my replies to the others' Posts may provide deeper insight.
|
|
|
|
|
A WPF or UWP ListView; hosting a custom control for each node (expander icon, text) for the tree; virtualized over the display height.
The data source can be any database.
Your "use case" is CRUD. Generic in the absence of extra detail. "Objects".
The "chart of accounts" ACCOUNT type is a single class; with ONE PARENT; and optional children. It's one of the simplest and most sensible hierarchical structures around.
The COA is not 100K; EXCLUDING the detail posting accounts (e.g. Clients), it's not more than several 1000 (and that's anal); and is STATIC for the most part once created.
A division of 5 to 10 users ... Optimistic locking.
About 1000-2000 lines of C# code; with comments.
Easy if you understand recursion. (And Accounting).
The part everyone usually under values (or over values) and messes up the most is the "account code".
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
modified 13-May-19 9:52am.
|
|
|
|
|
Quote: The COA is not 100K; EXCLUDING the detail posting accounts (e.g. Clients), it's not more than several 1000 (and that's anal); and is STATIC for the most part once created.
Currently, we have ~30000 non-leafs and ~70000 leafs. As soon as "higher forces" require a leaf to be detailed, it's no leaf any longer. So, if you mean "STATIC" as "unchanged", it's not true. IF you mean static as a access modifier, you might have a point.
|
|
|
|
|
As I said, the account structure is usually what gets messed up.
Your concept of leaf and non-leaf may have no relationship to what one might consider as a "typical" COA for a particular industry.
This isn't about your design; it's about generally accepted accounting practices (GAAP).
Study their financial statements to see what the purpose of the COA is and how it relates. You won't find 30,000 accounts or anything close.
I think you're confusing the COA (i.e. static "codes") with the General Ledger and subledgers (posting accounts). While the two are related, they are separate things; and where DELETES are strictly verboten.
(It's your BLOCK CHAIN ... in other words)
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
modified 13-May-19 13:02pm.
|
|
|
|
|