private void btnSave_Click(object sender, EventArgs e)
        {
            string strReturnMsg = CheckInput();

            if (strReturnMsg != string.Empty)
            {
                MessageBox.Show(strReturnMsg);
                return;
            }
            //新增
            if (m_TreeListDemo == null)
            {
                TreeListDemo model = EntityOperateManager.AddEntity <TreeListDemo>(this.tabPage);
                model.ParentId = m_intParentId;
                int intReturn = m_TreeListDemoDAL.Add(model);
                if (intReturn > 0)
                {
                    MessageBox.Show(@"添加成功");
                    model.Id = intReturn;
                    m_lstTreeListDemo.Add(model);
                    ListTreeListDemo  = m_lstTreeListDemo;
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show(@"添加失败");
                }
            }
            //修改
            else
            {
                m_TreeListDemo = EntityOperateManager.EditEntity(this.tabPage, m_TreeListDemo);
                bool blnReturn = m_TreeListDemoDAL.Update(m_TreeListDemo);
                if (blnReturn)
                {
                    MessageBox.Show(@"修改成功");
                    ListTreeListDemo  = m_lstTreeListDemo;
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show(@"修改失败");
                }
            }
        }
Beispiel #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string strReturnMsg = CheckInput();

            if (strReturnMsg != string.Empty)
            {
                MessageBox.Show(strReturnMsg);
                return;
            }
            //新增
            if (m_TreeListDemo == null)
            {
                string strNameValue = txtEditName.Text.Trim()
                ;
                if (m_TreeListDemoDAL.CalcCount("Name='" + strNameValue + "'") > 0)
                {
                    MessageBox.Show(@"名称已经存在");
                    return;
                }

                TreeListDemo model = EntityOperateManager.AddEntity <TreeListDemo>(this.tabPage);
                model.ParentId = m_intParentId;
                int intReturn = m_TreeListDemoDAL.Add(model);
                if (intReturn > 0)
                {
                    MessageBox.Show(@"添加成功");
                    model.Id = intReturn;
                    m_lstTreeListDemo.Add(model);
                    ListTreeListDemo  = m_lstTreeListDemo;
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show(@"添加失败");
                }
            }
            //修改
            else
            {
                string strNameValue = txtEditName.Text.Trim()
                ;
                if (m_TreeListDemoDAL.CalcCount(" Id !=" + m_TreeListDemo.Id + "   and  Name='" + strNameValue + "'") > 0)
                {
                    MessageBox.Show(@"名称已经存在");
                    return;
                }

                m_TreeListDemo = EntityOperateManager.EditEntity(this.tabPage, m_TreeListDemo);
                bool blnReturn = m_TreeListDemoDAL.Update(m_TreeListDemo);
                if (blnReturn)
                {
                    MessageBox.Show(@"修改成功");
                    ListTreeListDemo  = m_lstTreeListDemo;
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show(@"修改失败");
                }
            }
        }