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

            dataGridView1.DataSource = ds.Tables[0];
        }
        /// <summary>
        /// 保存数据
        /// </summary>
        private void SaveData()
        {
            //验证数据项
            string msg = "";

            if (f_RoleNameTextBox.Text.Trim().Length == 0)
            {
                msg += "角色名不能为空!\r\n";
            }
            if (msg.Length > 0)
            {
                MessageBox.Show(msg, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //数据准备
            GSSModel.Roles model = new GSSModel.Roles();
            model.F_RoleName = f_RoleNameTextBox.Text;
            model.F_IsUsed   = f_IsUsedCheckBox.Checked;
            model.F_Power    = GetTreeValue(null);
            model.F_Power   += ",";


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

            if (_id != 0)
            {
                model.F_RoleID = int.Parse(f_RoleIDTextBox.Text);
                isok           = bll.Update(model);
            }
            else
            {
                int num = bll.Add(model);
                if (num > 0)
                {
                    isok = true;
                }
            }
            if (isok)
            {
                MessageBox.Show("数据保存成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("数据保存失败!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// 初始化窗体
        /// </summary>
        private void InitForm()
        {
            BindPower();
            if (_id != 0)
            {
                this.Text = "角色修改";
                GSSBLL.Roles   bll   = new GSSBLL.Roles();
                GSSModel.Roles model = bll.GetModel(_id);
                f_RoleIDTextBox.Text     = model.F_RoleID.ToString();
                f_RoleNameTextBox.Text   = model.F_RoleName;
                f_IsUsedCheckBox.Checked = model.F_IsUsed;

                SetTreeValue(null, model.F_Power);
            }
        }
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.Roles bll = new GSSBLL.Roles();
                    if (bll.Delete(Convert.ToInt32(dgvRow.Cells[0].Value)))
                    {
                        dataGridView1.Rows.Remove(dgvRow);
                    }
                }
            }
        }