Socarsky
Well-known member
- Joined
- Mar 3, 2014
- Messages
- 59
- Programming Experience
- Beginner
How can I bind a condition of Boolean data type?
there is a bit field which contain false or true in the Database, when scrolling the data Movenext or Moveprevious either of them must checked Yes Or No checkbox as the database field but I need to make a condition to use that in scrolling.
there is a bit field which contain false or true in the Database, when scrolling the data Movenext or Moveprevious either of them must checked Yes Or No checkbox as the database field but I need to make a condition to use that in scrolling.
private void preparingScrollingData() { using (SqlConnection con = new SqlConnection(ConnString1)) { con.Open(); string specifyDate = dateTimeInput1.Value.Date.ToString("yyyy/MM/dd"); string strSqlCommand1 = "Select e.nRecordID as RecordID, e.sSeriNum as [Serial Nm], e.sSONum as [SO Number], e.sFormType as [Form Type]," + " e.sItemCode as [Item Code], e.bJudgement as Judgement, f.sDetectType as [Detect Type], e.dDate as [Record Date]," + " g.sPICName as [PIC Name], e.sRemark as [Remark]" + " FROM tbRecords e left outer join tbDetect f on f.nDetectTypeID = e.nDetectTypeID left outer join tbPIC g on g.nPICID = e.nPICID" + " WHERE e.dDate = '" + specifyDate + "' ORDER BY e.nRecordID ASC"; using (SqlCommand command = new SqlCommand(strSqlCommand1, con)) { SqlDataAdapter da = new SqlDataAdapter(command); DataTable dt = new DataTable(); da.SelectCommand = command; da.Fill(dt); bs = new BindingSource(); bs.DataSource = dt; txtSerialNum.DataBindings.Clear(); txtSerialNum.DataBindings.Add(new Binding("Text", bs, "Serial Nm")); txtSONum.DataBindings.Clear(); txtSONum.DataBindings.Add(new Binding("Text", bs, "SO Number")); cmbFormType.DataBindings.Clear(); cmbFormType.DataBindings.Add(new Binding("SelectedItem", bs, "Form Type")); txtItemCode.DataBindings.Clear(); txtItemCode.DataBindings.Add(new Binding("Text", bs, "Item Code")); chkYes.DataBindings.Clear(); chkYes.DataBindings.Add(new Binding("Checked", bs, "Judgement", true, DataSourceUpdateMode.OnPropertyChanged)); if (chkYes.Checked) { chkYes.Checked = true; chkNo.Checked = false; } else { chkYes.Checked = false; chkNo.Checked = true; } cmbDetectType.DataBindings.Clear(); cmbDetectType.DataBindings.Add(new Binding("SelectedItem", bs, "Detect Type")); cmbPIC.DataBindings.Clear(); cmbPIC.DataBindings.Add(new Binding("SelectedItem", bs, "PIC Name")); txtRemark.DataBindings.Clear(); txtRemark.DataBindings.Add(new Binding("Text", bs, "Remark")); da.Dispose(); command.Dispose(); } } }