void BindDgv(string commandtext)//重新根据传入的SQL语句绑定数据 { GoldenLadyWS.Service service = new GoldenLadyWS.Service(); string keywords = txtKey.Text.Trim(); commandtext += " and (customername like '%" + keywords + "%' or smsphone like '%" + keywords + "%' or smscontent like '%" + keywords + "%' or name like '%" + keywords + "%' or employeeno like '%" + keywords + "%' or customerno like '" + keywords + "')"; //dtStart = dtpStart.Value.ToString("yyyy-MM-dd") + " 00:00:00"; //dtEnd = dtpEnd.Value.ToString("yyyy-MM-dd")+" 23:59:59"; dtStart = dtpStart.Value.Date.ToString(); dtEnd = dtpStart.Value.Date.ToString(); if (ckbAllTime.Checked) { sqlByTime = ""; } else { //sqlByTime = " and CAST(smstime as datetime) between '" + dtStart + "' and '" + dtEnd + "'"; sqlByTime = " and datediff(dd,SmsTime,'" + dtStart + "')<=0 and datediff(dd,SmsTime,'" + dtEnd + "')>=0"; } commandtext += sqlByTime; if (ckbAllTime.Checked)//所有时间段 { DataSet ds = service.GetDataSet(commandtext); dgvSearchResult.DataSource = ds.Tables[0]; } else { string test = commandtext + sqlByTime; DataSet ds = service.GetDataSet(commandtext); dgvSearchResult.DataSource = ds.Tables[0]; } }
private void frmSendSms_Load(object sender, EventArgs e) { GoldenLadyWS.Service service = new GoldenLadyWS.Service(); string sql = "select sa.id as id,name,content1 as content from SMSUsefulExpressions su,SMSAi sa where su.id=sa.id"; DataSet ds = service.GetDataSet(sql); if (ds != null) { cmbAi.ValueMember = "content"; cmbAi.DisplayMember = "name"; cmbAi.DataSource = ds.Tables[0]; cmbAi.SelectedIndex = -1; foreach (DataRow i in ds.Tables[0].Rows) { listAiID.Add(Convert.ToInt32(i["id"].ToString())); } } }