Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,

I need Assistance please

I have two tables (X) And (Y)

Table (X) have { ID , material_Name , Material_number ) .Appear on data gridview.
Table (Y) have { ID , Material_Name , Total ).Appear on data gridview.

So, From table (X) i select the material_name from combobox. then i write the number of material in the textbox. then i press add button to insert the value in the table(X).

So let we assume From table (X) i selected the material_name is ( Pen) and the Material_number was (10).Then after three days i inserted the same material name but the material_number was (20).
So the total Pin= 30 for now.

So i want this result (30) appear to me on table (Y) in column (Total )on data Gridview. And it can increase or decrease according to the inserting Material_number from table (X)

As summery ,

In Table (X) :-
First day >>> inserted 10 pens. & 5 soft
Second day >> inserted 20 pens .

The total pens that i have it in right now 10+20= (30). And total soft that i have = (5).


In Table(Y):-
The result (30)pens should be appear to me in column (Material_number)in the row of pens. And the result of soft (5)should be appear to me in the column ( Material_number ) in the row of Soft . And like this for each material.

Any one can help me in this?

Many thanks
Posted

The strategy seems to be like
* One Index View which contain two partial views
- One View contains gridview which is binded to Table X
- One View contains gridview which is binded to Table Y
* The Index view may also contain text fields like Material Number etc.
* On save button click you did following
* Save the information in the Table X using DAL
* Also calculated Totals and save it in Table Y using DAL
* Refresh the Index View

I think this strategy should work for your case.

Cheers
 
Share this answer
 
Dear,

I did like this

For Table (X)

C#
string Coonstring = "datasource=localhost;port=3306;username=root;password=;
 string cmd = "Insert into X ( material_Name , Material_number )values( '" + this.comboBox1.Text + "','" + this.txt_out1.Text + "');";

MySqlConnection connectionDatabase = new MySqlConnection(Coonstring);
MySqlCommand cmddata = new MySqlCommand(cmd, connectionDatabase);
MySqlDataReader myreader;
 try
            {
                connectionDatabase.Open();
                myreader = cmddata.ExecuteReader();
                MessageBox.Show("Done");
                while (myreader.Read())
                {
               }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }


Then i loaded this table to data gridview.


FOR Table (Y)

C#
string Coonstring = "datasource=localhost;port=3306;username=root;password=;
 string cmd = "Insert into Y ( material_Name )values('" + this.txt_out1.Text + "');";

MySqlConnection connectionDatabase = new MySqlConnection(Coonstring);
MySqlCommand cmddata = new MySqlCommand(cmd, connectionDatabase);
MySqlDataReader myreader;
 try
            {
                connectionDatabase.Open();
                myreader = cmddata.ExecuteReader();
                MessageBox.Show("Done");
                while (myreader.Read())
                {
               }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }


Then i loaded it too to data grideview.

So now I have two tables loaded on data gridview

(X) That contain ( material_Name , Material_number) and shown in data gridview .
(Y) that contain (Material_Name , Total ) shown in data girdview. but her i just insert the Material_name and the (Total) appear (0) as initial. This column should be fill by itself when i insert the Material_number in table (X).

So Please, After this what i should do? what you mean by DAL. And how i can make calculation using it and insert the result in the column (Total) in table Y ?

Many thanks.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 15-Apr-14 17:12pm    
Who are you talking to? This is not an answer, and such posts are considered as abuse. Use "Improve question" or comments instead.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900