开发者

Adding sql data to a grid view based on the input value?

Had no hits on the asp side so I thought id try here.I finally got one query working that inserts the employees name and department but now I want to add their hours worked for the week in a table or a grid view like a typical time sheet report. any Ideas on how to accomplish this I'm new to programming "still a student"

 string cmdquery = "SELECT * from Employees WHERE Badge ='" + Badge + "'";
                string HrQuery = "SELECT CLOCK_IN_TIME, CLOCK_OU开发者_开发百科T_TIME FROM CLOCK_HISTORY WHERE Badge ='" + Badge + "'";

                OracleCommand cmd = new OracleCommand(cmdquery);
                cmd.Connection = conn;
                cmd.CommandType = CommandType.Text;
                conn.Open();
                using (OracleDataReader reader = cmd.ExecuteReader())
                {

                    while (reader.Read())
                    {
                        this.xUserNameLabel.Text += reader["EMPLOYEE_NAME"];
                        this.xDepartmentLabel.Text += reader["REPORT_DEPARTMENT"];

                    }

                    //OracleCommand HrQuery = new OracleCommand(HrQuery);




                }

                conn.Close();

here's an example of the old time sheets format that I'm trying to replicate and improve.

Clock In Time    Clock Out Time     Subtotal    " Actual Time" // user can input data

Sunday
6/20/10 6/20/10 

0

Monday
6/21/10 6/21/10 

0

Tuesday
6/22/10 6/22/10 

0

Wednesday
6/23/10 6/23/10 

0

Thursday
6/24/10 6/24/10 

0

Friday
6/25/10 6/25/10 

0

Saturday
6/26/10 6/26/10 

0


This article specifies how to populate a gridview in C# from SQL statements.

For me I use Windows From in Visual Studio. From there you can bind the data to the gridview through the Design mode or add the code to the gridview with code.

From the DESIGN mode you can click on the gridcontrol and then click on the triangle on the top right. From there you can choose a datasource for the table. This is an sql statement that you have already made.

This site, eggheadcafe, has a question that is applicable to your question. It shows how to connect your Oracle to the datagrid. The only difference I would use is have a way to get/set you badge. Thus instead of

 string ora_cmd = "select * from customers";

you could instead put:

  string ora_cmd = "SELECT CLOCK_IN_TIME, CLOCK_OUT_TIME FROM CLOCK_HISTORY WHERE Badge ='" + getBadge() + "'";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜