Exemple #1
0
        /// <summary>
        /// 窗体数据初始化
        /// </summary>
        private void formInit()
        {
            dataGridView1.AutoGenerateColumns = false;
            GSSBLL.Dictionary bll = new GSSBLL.Dictionary();
            DataSet           ds  = bll.GetAllList();

            dataGridView1.DataSource = ds.Tables[0];
        }
 /// <summary>
 /// 初始化窗体
 /// </summary>
 private void InitForm()
 {
     if (_id > 0)
     {
         this.Text = "字典修改";
         f_DicIDTextBox.Enabled = false;
         GSSBLL.Dictionary   bll   = new GSSBLL.Dictionary();
         GSSModel.Dictionary model = bll.GetModel(_id);
         f_DicIDTextBox.Text      = model.F_DicID.ToString();
         f_ParentIDTextBox.Text   = model.F_ParentID.ToString();
         f_ValueTextBox.Text      = model.F_Value;
         f_SortTextBox.Text       = model.F_Sort.ToString();
         f_IsUsedCheckBox.Checked = model.F_IsUsed;
     }
 }
        /// <summary>
        /// 保存数据
        /// </summary>
        private void SaveData()
        {
            //验证数据项
            string msg = CheckData();

            if (msg.Length > 0)
            {
                MessageBox.Show(msg, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //数据准备
            GSSModel.Dictionary model = new GSSModel.Dictionary();
            model.F_DicID    = Convert.ToInt32(f_DicIDTextBox.Text);
            model.F_ParentID = Convert.ToInt32(f_ParentIDTextBox.Text);
            model.F_Value    = f_ValueTextBox.Text;
            model.F_Sort     = Convert.ToInt32(f_SortTextBox.Text);
            model.F_IsUsed   = f_IsUsedCheckBox.Checked;


            //数据提交
            GSSBLL.Dictionary bll = new GSSBLL.Dictionary();
            bool isok             = false;

            if (_id > 0)
            {
                isok = bll.Update(model);
            }
            else
            {
                if (model.F_DicID == 0)
                {
                    MessageBox.Show(LanguageResource.Language.Tip_IDShouldGatherThan0);
                    return;
                }
                isok = bll.Add(model);
            }
            if (isok)
            {
                MessageBox.Show("数据保存成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("数据保存失败!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #4
0
        private void toolStripButtonDelete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("确定要删除选中的数据吗?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
            {
                return;
            }
            int iSelectRowCount = dataGridView1.SelectedRows.Count;

            //判断是否选择了行
            if (iSelectRowCount > 0)
            {
                //循环删除行
                foreach (DataGridViewRow dgvRow in dataGridView1.SelectedRows)
                {
                    GSSBLL.Dictionary bll = new GSSBLL.Dictionary();
                    if (bll.Delete(Convert.ToInt32(dgvRow.Cells[0].Value)))
                    {
                        dataGridView1.Rows.Remove(dgvRow);
                    }
                }
            }
        }