예제 #1
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            List <int> listids = new List <int>();
            string     ids     = ",";

            foreach (DataGridViewRow x in dataGridView1.Rows)
            {
                DataGridViewCheckBoxCell cell = (DataGridViewCheckBoxCell)x.Cells[0];
                Boolean flag = Convert.ToBoolean(cell.Value);
                if (flag)
                {
                    ids += x.Cells["id"].Value.ToString() + ",";
                    listids.Add(Convert.ToInt32(x.Cells["id"].Value.ToString()));
                }
            }
            if (listids.Count <= 0)
            {
                MessageBox.Show(string.Format("请选择要删除的数据"), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (MessageBox.Show(string.Format("您将要删除复选框选中的 【{0}】 条专题库", listids.Count), "确认删除", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.OK)
            {
                ids = ids.Trim(',');

                if (ZTHelper.DelZTDB(ids))
                {
                    bind();
                }
            }
        }
예제 #2
0
        public void bind()
        {
            DataTable dt = ZTHelper.GetZTList();

            this.dataGridView1.DataSource = dt;
            this.dataGridView1.ClearSelection();
        }
예제 #3
0
        private void  除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0)
            {
                MessageBox.Show(string.Format("请选择要删除的数据"), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            DataGridViewRow datarow = dataGridView1.SelectedRows[0];
            string          name    = (datarow.Cells["name"].Value == null ? "" : datarow.Cells["name"].Value.ToString());
            string          des     = (datarow.Cells["des"].Value == null ? "" : datarow.Cells["des"].Value.ToString());
            string          type    = (datarow.Cells["type"].Value == null ? "CPRS" : datarow.Cells["type"].Value.ToString());

            if (MessageBox.Show("您确定要删除专题库 【" + name + "】 吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes)
            {
                try
                {
                    if (ZTHelper.DelZTDB(datarow.Cells["Id"].Value.ToString(), name))
                    {
                        bind();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "错误");
                }
            }
        }
예제 #4
0
        private void  除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DataGridViewRow datarow = dataGridView1.SelectedRows[0];
            string          name    = (datarow.Cells["name"].Value == null ? "" : datarow.Cells["name"].Value.ToString());
            string          des     = (datarow.Cells["des"].Value == null ? "" : datarow.Cells["des"].Value.ToString());
            string          type    = (datarow.Cells["type"].Value == null ? "CPRS" : datarow.Cells["type"].Value.ToString());

            if (MessageBox.Show("您确定要删除专题库 【" + name + "】 吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes)
            {
                if (ZTHelper.DelZTDB(datarow.Cells["id"].Value.ToString()))
                {
                    bind();
                }
            }
        }
예제 #5
0
 private void txtName_Leave(object sender, EventArgs e)
 {
     if (this.txtName.Text.Trim() == "")
     {
         this.errorProvider1.SetError(this.txtName, "专题库名称不能为空");
         return;
     }
     if ((this.Text == "修改专题库" && this.ztname != this.txtName.Text.Trim()) || this.Text == "新建专题库")
     {
         if (ZTHelper.ExistZTDB(this.txtName.Text.Trim()))
         {
             this.errorProvider1.SetError(this.txtName, "专题库名称已经存在");
             MessageBox.Show("专题库名称已经存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             this.errorProvider1.Clear();
         }
     }
 }
예제 #6
0
        private void btnSubMit_Click(object sender, EventArgs e)
        {
            bool haserror = false;

            if (this.txtName.Text.Trim() == "")
            {
                haserror = true;
                this.errorProvider1.SetError(this.txtName, "专题库名称不能为空");
            }
            if (this.txtDesc.Text.Trim() == "")
            {
                haserror = true;
                this.errorProvider1.SetError(this.txtDesc, "专题库描述不能为空");
            }
            if (haserror)
            {
                return;
            }
            if ((this.Text == "修改专题库" && this.ztname != this.txtName.Text.Trim()) || this.Text == "新建专题库")
            {
                if (ZTHelper.ExistZTDB(this.txtName.Text.Trim()))
                {
                    haserror = true;
                    this.errorProvider1.SetError(this.txtName, "专题库名称已经存在");
                    MessageBox.Show("专题库名称已经存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            if (haserror)
            {
                return;
            }
            this.errorProvider1.Clear();
            bool   res;
            string type = "";

            foreach (var x in this.Controls)
            {
                if (x.GetType() == typeof(RadioButton))
                {
                    var rb = x as RadioButton;
                    if (rb.Checked == true)
                    {
                        type = rb.Text;
                    }
                }
            }
            if (this.Text == "修改专题库")
            {
                res = ZTHelper.EditZTDB(id, this.txtName.Text.Trim(), this.txtDesc.Text.Trim(), type);
            }
            else
            {
                res = ZTHelper.AddZTDB(this.txtName.Text.Trim(), this.txtDesc.Text.Trim(), type);
            }
            if (res)
            {
                MessageBox.Show(sucess_message + "成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.txtDesc.Text = "";
                this.txtName.Text = "";
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
            else
            {
                MessageBox.Show(sucess_message + "失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }