Click here to Skip to main content
15,887,350 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# UnauthorizedAccessException Pin
OriginalGriff29-Jan-12 3:53
mveOriginalGriff29-Jan-12 3:53 
AnswerRe: C# UnauthorizedAccessException Pin
Abhinav S29-Jan-12 19:04
Abhinav S29-Jan-12 19:04 
AnswerRe: C# UnauthorizedAccessException Pin
Bernhard Hiller29-Jan-12 20:44
Bernhard Hiller29-Jan-12 20:44 
QuestionQuestion about Chart in C# Pin
pongpanut28-Jan-12 20:31
pongpanut28-Jan-12 20:31 
AnswerRe: Question about Chart in C# PinPopular
OriginalGriff28-Jan-12 21:06
mveOriginalGriff28-Jan-12 21:06 
GeneralRe: Question about Chart in C# Pin
pongpanut28-Jan-12 21:47
pongpanut28-Jan-12 21:47 
GeneralRe: Question about Chart in C# Pin
OriginalGriff28-Jan-12 21:49
mveOriginalGriff28-Jan-12 21:49 
GeneralRe: Question about Chart in C# Pin
pongpanut28-Jan-12 22:20
pongpanut28-Jan-12 22:20 
my code is

C#
string test = "";

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (row.Cells[1].Value != null && (bool)row.Cells[1].FormattedValue)
                {                       
                        String idtoselect = row.Cells[0].Value.ToString();
                        
                        try
                        {
                            string sql2 = "select NAME_Product from Product where  Product.ID_Product = '"+idtoselect+"' ";
                            SqlCommand testcommand2 = new SqlCommand(sql2, conn);
                            rdr = testcommand2.ExecuteReader();

                            if (rdr.Read())
                            {
                                test = rdr["NAME_Product"].ToString();
                            }
                            rdr.Close();

                            try
                            {
                                CultureInfo ci = new CultureInfo("th-TH");
                                string sql = "SELECT * FROM Order1 where ID_Product = @ID AND DATE_Order BETWEEN @D1 AND @D2";
                                da = new SqlDataAdapter(sql, conn);
                                da.SelectCommand.Parameters.AddWithValue("@ID", idtoselect);
                                da.SelectCommand.Parameters.AddWithValue("@D1", dateTimePicker1.Value);
                                da.SelectCommand.Parameters.AddWithValue("@D2", dateTimePicker2.Value);
                                
                                ds = new DataSet();
                                da.Fill(ds, "Order1");
                                chart1.DataSource = ds.Tables["Order1"];
                                chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
                                
                                chart1.Series.Add(test);
                                chart1.Series[test].ChartArea = "ChartArea1";
                                chart1.Series[test].BorderWidth = 4;
                                chart1.Series[test].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;                                
                                chart1.Series[test].YValueMembers += "QUANTITY_Order";
                                chart1.Series[test].XValueMember += "DATE_Order";

                                chart1.DataBind();
                                MessageBox.Show("test :" );
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("test :" + ex);
                            }
       
                        }
                        catch
                        {
                            MessageBox.Show("Exception");
                        }
                

                }


i want to select quantity(QUANTITY_Order) that have been sold to show on my chart

if i select only one product chart will be show with correct value but if i choose two product in my list box for compare with two product value of first product will be wrong and it copy value of second product

this's my demo interface
http://image.ohozaa.com/view/8146d

it will show all product in database to list box and datetimepicker1 for select start date to find quantity in database and datetimepicker2 for select finish date

then when i select two data in listbox and i use MessageBox.Show("test :" ); for break to show my chart

this picture will show value of first product
http://image.ohozaa.com/view/8146t

then when i click on messagebox will show second product

http://image.ohozaa.com/view/81473

then you can see the value of first product in blue line will change value like second product Frown | :(

this is my database on mysqlserver 2005

http://image.ohozaa.com/view/8147g

thank you for your answer to much Smile | :)
AnswerRe: Question about Chart in C# Pin
Luc Pattyn28-Jan-12 22:38
sitebuilderLuc Pattyn28-Jan-12 22:38 
GeneralRe: Question about Chart in C# Pin
pongpanut29-Jan-12 0:10
pongpanut29-Jan-12 0:10 
GeneralRe: Question about Chart in C# Pin
OriginalGriff28-Jan-12 23:08
mveOriginalGriff28-Jan-12 23:08 
GeneralRe: Question about Chart in C# Pin
pongpanut29-Jan-12 1:58
pongpanut29-Jan-12 1:58 
GeneralRe: Question about Chart in C# Pin
OriginalGriff29-Jan-12 2:06
mveOriginalGriff29-Jan-12 2:06 
GeneralRe: Question about Chart in C# Pin
pongpanut29-Jan-12 2:16
pongpanut29-Jan-12 2:16 
GeneralRe: Question about Chart in C# Pin
OriginalGriff29-Jan-12 2:58
mveOriginalGriff29-Jan-12 2:58 
AnswerRe: Question about Chart in C# Pin
Luc Pattyn29-Jan-12 8:35
sitebuilderLuc Pattyn29-Jan-12 8:35 
GeneralRe: Question about Chart in C# Pin
Luc Pattyn28-Jan-12 22:12
sitebuilderLuc Pattyn28-Jan-12 22:12 
GeneralRe: Question about Chart in C# Pin
pongpanut28-Jan-12 22:23
pongpanut28-Jan-12 22:23 
QuestionWriting source code in seperate files Pin
Fred 3427-Jan-12 22:27
Fred 3427-Jan-12 22:27 
AnswerRe: Writing source code in seperate files Pin
Richard MacCutchan27-Jan-12 22:37
mveRichard MacCutchan27-Jan-12 22:37 
GeneralRe: Writing source code in seperate files Pin
Eddy Vluggen27-Jan-12 23:44
professionalEddy Vluggen27-Jan-12 23:44 
GeneralRe: Writing source code in seperate files Pin
Richard MacCutchan28-Jan-12 0:19
mveRichard MacCutchan28-Jan-12 0:19 
GeneralRe: Writing source code in seperate files Pin
Eddy Vluggen28-Jan-12 5:19
professionalEddy Vluggen28-Jan-12 5:19 
GeneralRe: Writing source code in seperate files Pin
Richard MacCutchan28-Jan-12 5:26
mveRichard MacCutchan28-Jan-12 5:26 
GeneralRe: Writing source code in seperate files Pin
AmitGajjar28-Jan-12 21:35
professionalAmitGajjar28-Jan-12 21:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.