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

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

            if (f_DepartNameTextBox.Text.Trim().Length == 0)
            {
                msg += "部门名不能为空!\r\n";
            }
            if (f_ParentIDComboBox.SelectedValue.ToString() == f_DepartIDTextBox.Text && f_DepartIDTextBox.Text != "0")
            {
                msg += "上级部门不能选择本部门!\r\n";
            }

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

            //数据准备
            GSSModel.Department model = new GSSModel.Department();
            model.F_ParentID   = int.Parse(f_ParentIDComboBox.SelectedValue.ToString());
            model.F_DepartName = f_DepartNameTextBox.Text;
            model.F_Note       = f_NoterichTextBox.Text;



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

            if (_id != 0)
            {
                model.F_DepartID = int.Parse(f_DepartIDTextBox.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);
            }
        }
Пример #3
0
 /// <summary>
 /// 初始化窗体
 /// </summary>
 private void InitForm()
 {
     GSSServerLibrary.ServerUtil.BindDropDLTDept(this.f_ParentIDComboBox);
     if (_id != 0)
     {
         this.Text = "部门修改";
         GSSBLL.Department   bll   = new GSSBLL.Department();
         GSSModel.Department model = bll.GetModel(_id);
         f_DepartIDTextBox.Text           = model.F_DepartID.ToString();
         f_ParentIDComboBox.SelectedValue = model.F_ParentID;
         f_DepartNameTextBox.Text         = model.F_DepartName;
         f_NoterichTextBox.Text           = model.F_Note;
     }
 }
        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.Department bll = new GSSBLL.Department();
                    if (bll.Delete(Convert.ToInt32(dgvRow.Cells[0].Value)))
                    {
                        dataGridView1.Rows.Remove(dgvRow);
                    }
                }
            }
        }