0
Answer

How can i show multi checkbox on datagridview

toon junt

toon junt

12y
1.2k
1
i need show multi checkbox on datagridview.

i have 4 checkbox when select 2 checkbox it's show 2 checkbox on datagridview.

Ex. 2 checkbox.

CheckBox missShw
    0001
    0002

CheckBox leaveFull
    0003
    0004

i'm First select CheckBox missShw and CheckBox leaveFull it's output.
    0003
    0004
OR


i'm First select CheckBox leaveFull and CheckBox missShw it's output.

    0001
    0002

i need output when 2 checkbox.
    0001
    0002
    0003
    0004

now, i'm select 2 checkbox, so it's show all data to datagridview but it's don't show all data.

This code:

public void missShw() 
            {
                SqlConnection conn = new SqlConnection(appConn);
                string sql = "SELECT [filesTA].EmpNo,[Employee].Title + ' ' + [Employee].[First Name] + ' ' + [Employee].[Last Name] as 'FullName',[filesTA].ChkDate"
                + ",Convert(nvarchar(5),[filesTA].ChkIn,108) as 'ChkIn',Convert(nvarchar(5),[filesTA].ChkOut,108) as 'ChkOut"
                + ",[filesTA].LateMin"
                + " From [WebSP].[dbo].[filesTA] inner join [WebSP].[dbo].[Employee] on [Employee].EmployeeNo=[filesTA].EmpNo INNER JOIN [WebSP].[dbo].[CompanyData] On [CompanyData].Company = [Employee].Company"
                + " WHERE [filesTA].ChkDate ='" + dateTimePicker.Value.ToString("yyyy-MM-dd") + "'"
                + " and [Employee].Section = '" + cbSection.SelectedValue + "'"
                + " and [Employee].Team = '" + cbTeam.SelectedValue + "'"
                + " and [filesTA].ErrorCode = '2'";

                da = new SqlDataAdapter(sql, Conn);
                DataSet ds = new DataSet();
                da.Fill(ds);
                Conn.Close();

                dgvShow.DataSource = ds.Tables[0];
            }

    public void leaveFull()
            {
                SqlConnection conn = new SqlConnection(appConn);
                string sql = "SELECT [filesTA].EmpNo,[Employee].Title + ' ' + [Employee].[First Name] + ' ' + [Employee].[Last Name] as 'FullName',[filesTA].ChkDate"
                + ",Convert(nvarchar(5),[filesTA].ChkIn,108) as 'ChkIn',Convert(nvarchar(5),[filesTA].ChkOut,108) as 'ChkOut"
                + ",[filesTA].LateMin"
                + " From [WebSP].[dbo].[filesTA] inner join [WebSP].[dbo].[Employee] on [Employee].EmployeeNo=[filesTA].EmpNo INNER JOIN [WebSP].[dbo].[CompanyData] On [CompanyData].Company = [Employee].Company"
                + " WHERE [filesTA].ChkDate ='" + dateTimePicker.Value.ToString("yyyy-MM-dd") + "'"
                + " and [Employee].Section = '" + cbSection.SelectedValue + "'"
                + " and [Employee].Team = '" + cbTeam.SelectedValue + "'"
                + " and [filesTA].ErrorCode = '3'";

                da = new SqlDataAdapter(sql, Conn);
                DataSet ds = new DataSet();
                da.Fill(ds);
                Conn.Close();

                dgvShow.DataSource = ds.Tables[0];
            }

    //missShw()
            private void checkBox4_CheckedChanged(object sender, EventArgs e)
            {
                if (checkBox4.Checked == true)
                {
                    missShw();                
                }
            }

    //leaveFull()
            private void checkBox3_CheckedChanged(object sender, EventArgs e)
            {
                if (checkBox3.Checked == true)
                {
                    leaveFull();                
                }
            }

Thanks for your time. :)