Пример #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (txtAi.Text.Trim().Length == 0)
            {
                MessageBox.Show("类别名称不能为空!");
                txtAi.Focus();
                return;
            }

            GoldenLadyWS.Service serivce = new GoldenLadyWS.Service();
            bool   flag = true;
            string sql  = "insert into SMSAi (name,forwarddays,sendtime) Values ('" + txtAi.Text.Trim() + "',0,'00:00:00')";

            if (serivce.ExecuteCommandText(sql) <= 0)
            {
                flag = false;
            }
            int newid = Convert.ToInt32(serivce.GetDataSet("select MAX(id) from SMSAi").Tables[0].Rows[0][0].ToString());

            sql = "insert into SMSUsefulExpressions (id,content1) values (" + newid + ",'" + txtUsefulExpressions1.Text.Trim() + "')";
            if (serivce.ExecuteCommandText(sql) <= 0)
            {
                flag = false;
            }
            if (flag)
            {
                MessageBox.Show("添加成功!");
                this.DialogResult = DialogResult.Yes;
            }
            else
            {
                MessageBox.Show("添加失败!");
            }
        }
Пример #2
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (txtAi.Text.Trim().Length == 0)
            {
                MessageBox.Show("类别名称不能为空!");
                txtAi.Focus();
                return;
            }

            if (cmbHH.Text.Length == 1)
            {
                cmbHH.Text = "0" + cmbHH.Text;
            }
            if (cmbMM.Text.Length == 1)
            {
                cmbMM.Text = "0" + cmbMM.Text;
            }

            string sql  = "update SMSAi set name='" + txtAi.Text.Trim() + "',forwarddays=" + Convert.ToInt32(cmbForwardDays.Text) + ",sendtime='" + cmbHH.Text + ":" + cmbMM.Text + ":00" + "' where id=" + Convert.ToInt32(id);
            bool   flag = true;

            GoldenLadyWS.Service serivce = new GoldenLadyWS.Service();
            if (serivce.ExecuteCommandText(sql) <= 0)
            {
                flag = false;
            }
            sql = "update SMSUsefulExpressions set content1='" + txtUsefulExpressions1.Text.Trim() + "' where id=" + Convert.ToInt32(id);
            if (serivce.ExecuteCommandText(sql) <= 0)
            {
                flag = false;
            }
            if (flag)
            {
                MessageBox.Show("修改成功!");
                frmOption_Load(null, null);
                dgv.ClearSelection();
                dgv.Rows[selectIndex].Selected = true;
            }
            else
            {
                MessageBox.Show("修改失败!!");
            }
        }
Пример #3
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     GoldenLadyWS.Service service = new GoldenLadyWS.Service();
     //int Id = Convert.ToInt32(id);
     for (int i = 0; i < dgv.SelectedRows.Count; i++)
     {
         string sql = "delete from SMSAi where id=" + Convert.ToInt32(dgv.SelectedRows[i].Cells[0].Value.ToString());
         if (Convert.ToInt32(dgv.SelectedRows[i].Cells["编号"].Value) < 7)
         {
             continue;
         }
         if (service.ExecuteCommandText(sql) <= 0)
         {
             MessageBox.Show("删除失败!");
         }
     }
     frmOption_Load(null, null);//刷新
     dgv.ClearSelection();
     dgv.Rows[dgv.Rows.Count - 1].Selected = true;
 }