コード例 #1
0
 private void BT_over_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < CLB_changjia.Items.Count; i++)
     {
         if (CLB_changjia.GetItemChecked(i))
         {
             CLB_changjia.SetItemChecked(i, false);
         }
         else
         {
             CLB_changjia.SetItemChecked(i, true);
         }
     }
 }
コード例 #2
0
        private void BT_result_Click(object sender, EventArgs e)
        {
            string sql  = "select * From mygas_meter_result INNER JOIN mygas_manufacture on ManufactureName_id = id WHERE 1=1";
            string sql2 = "Select * From mygas_meterplat WHERE 1=1";

            if (CB_id.Checked == true)
            {
                sql += string.Format(@" AND MeterId = '{0}'", TB_ID.Text);
                sql += string.Format(@" AND MeterId = '{0}'", TB_ID.Text);
            }
            if (CB_checktime.Checked == true)
            {
                sql += string.Format(@" AND CheckTime>'{0}' AND CheckTime<'{1}'", dtp_checktime_start, dtp_chencktime_end);
            }
            int f = 0;

            sql += " AND(1=1";
            for (int i = 0; i < CLB_changjia.Items.Count; i++)
            {
                if (CLB_changjia.GetItemChecked(i))
                {
                    if (f == 0)
                    {
                        sql += string.Format(@" AND ManufactureName='{0}'", CLB_changjia.GetItemText(CLB_changjia.Items[i]));
                    }
                    else
                    {
                        sql += string.Format(@" OR ManufactureName='{0}'", CLB_changjia.GetItemText(CLB_changjia.Items[i]));
                    }
                    f++;
                }
            }
            sql += " )";
            f    = 0;
            DataTable           dt  = MysqlHepler.SqlReturnDs(sql).Tables[0];
            DataTable           dt2 = MysqlHepler.SqlReturnDs(sql2).Tables[0];
            IList <MeterSearch> li  = Dt2serch_result(Dt2listmetersearch(dt), Dt2distmeterplat(dt2));

            DGV_result.DataSource = li;
            AutoSizeColumn(DGV_result);
        }