Ejemplo n.º 1
0
        private void MenuItemAddRcd_Click(object sender, EventArgs e)
        {   //added by chulili 2011-02-24 添加记录功能
            TableForm myTableForm = new TableForm(gridControl, m_connstr, m_TableName);

            myTableForm.InitForm("ADD");
            myTableForm.ShowDialog();
            OleDbCommandBuilder builder = new OleDbCommandBuilder(m_Adapter);

            //将数据提交到数据库更新

            try
            {
                m_Adapter.Update(m_dataTable);
                //提交后重新获取数据,避免ID列的值与数据库中不一致
                m_dataTable.Clear();
                m_Adapter.Fill(m_dataTable);
                gridControl.DataSource = null;
                gridControl.DataSource = m_dataTable;
                //gridControl.Update();
            }
            catch (System.Exception m)
            {
                Console.WriteLine(m.Message);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 增加双击启动编辑
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gridControl_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (gridControl.DataSource == null)
            {
                return;
            }
            //如果未选中记录。。。
            if (gridControl.SelectedRows.Count == 0)
            {
                MessageBox.Show("未选中记录!");
                return;
            }
            //如果选中多行记录。。。
            if (gridControl.SelectedRows.Count > 1)
            {
                MessageBox.Show("仅可修改一行!");
                return;
            }
            int idx = gridControl.SelectedRows[0].Index;//yjl20111103 add
            //初始化修改记录对话框
            //初始化添加记录对话框
            TableForm myTableForm = new TableForm(gridControl, m_connstr, m_TableName);

            myTableForm.InitForm("MODIFY");
            myTableForm.ShowDialog();
            //记录修改后再次初始化dataview控件
            InitDataInfoList(m_TableName);
            ////ZQ   20111017   add  及时更新数据字典
            switch (m_TableName)
            {
            case "属性对照表":
                SysCommon.ModField.InitNameDic(Plugin.ModuleCommon.TmpWorkSpace, SysCommon.ModField._DicFieldName, "属性对照表");
                break;

            case "标准图层代码表":
                SysCommon.ModField.InitLayerNameDic(Plugin.ModuleCommon.TmpWorkSpace, SysCommon.ModField._DicLayerName);
                break;
                //default:
                //    ///ZQ 20111020 add 增加重启提示
                //    MessageBox.Show("添加的记录只有应用系统重启以后才能生效!","提示!");
                //    break;
            }
            //yjl20111103 add
            if (gridControl.Rows.Count > idx)
            {
                //取消默认的第1行选中
                gridControl.Rows[0].Selected = false;
                //设置选择行
                gridControl.Rows[idx].Selected = true;
                //设置当前行
                gridControl.CurrentCell = gridControl.Rows[idx].Cells[0];
            }
            /////

            Plugin.LogTable.Writelog("修改记录");//xisheng 2011.07.09 增加日志
        }
Ejemplo n.º 3
0
        private void MenuItemModifyRcd_Click(object sender, EventArgs e)
        {   //added by chulili 2011-02-24 修改记录功能
            if (gridControl.SelectedRows.Count == 0)
            {
                MessageBox.Show("未选中记录!");
                return;
            }
            if (gridControl.SelectedRows.Count > 1)
            {
                MessageBox.Show("仅可修改一行!");
                return;
            }

            TableForm myTableForm = new TableForm(gridControl, m_connstr, m_TableName);

            myTableForm.InitForm("MODIFY");
            myTableForm.ShowDialog();

            InitDataInfoList(m_TableName);

            //OleDbCommandBuilder builder = new OleDbCommandBuilder(m_Adapter);
            //////将数据提交到数据库更新

            //try
            //{
            //    m_Adapter.Update(m_dataTable);
            //    //提交后重新获取数据,避免ID列的值与数据库中不一致
            //    m_dataTable.Clear();
            //    m_Adapter.Fill(m_dataTable);
            //    gridControl.DataSource = null;
            //    gridControl.DataSource = m_dataTable;
            //}
            //catch (System.Exception m)
            //{
            //    Console.WriteLine(m.Message);
            //}
        }
Ejemplo n.º 4
0
        //添加记录菜单响应
        public override void OnClick()
        {
            if (m_Hook.GridCtrl == null)
            {
                return;
            }
            FaceControl  pfacecontrol = (FaceControl)m_Hook.MainUserControl;
            DataGridView pGridControl = m_Hook.GridCtrl;

            if (pfacecontrol.getEditable() == false)
            {
                return;
            }
            string connstr, Tablename;

            //获取数据库连接串和表名
            connstr   = pfacecontrol.m_connstr;
            Tablename = pfacecontrol.m_TableName;
            FaceControl pFaceControl = (FaceControl)(m_Hook.MainUserControl);

            if (pGridControl.DataSource == null)
            {
                return;
            }
            //如果未选中记录。。。
            if (pGridControl.SelectedRows.Count == 0)
            {
                MessageBox.Show("未选中记录!");
                return;
            }
            //如果选中多行记录。。。
            if (pGridControl.SelectedRows.Count > 1)
            {
                MessageBox.Show("仅可修改一行!");
                return;
            }
            int idx = pGridControl.SelectedRows[0].Index;//yjl20111103 add
            //初始化修改记录对话框
            TableForm myTableForm = new TableForm(pGridControl, connstr, Tablename);

            myTableForm.InitForm("MODIFY");
            myTableForm.ShowDialog();
            //记录修改后再次初始化dataview控件
            pfacecontrol.InitDataInfoList(Tablename);
            ////ZQ   20111017   add  及时更新数据字典
            switch (Tablename)
            {
            case "属性对照表":
                SysCommon.ModField.InitNameDic(Plugin.ModuleCommon.TmpWorkSpace, SysCommon.ModField._DicFieldName, "属性对照表");
                break;

            case "标准图层代码表":
                SysCommon.ModField.InitLayerNameDic(Plugin.ModuleCommon.TmpWorkSpace, SysCommon.ModField._DicLayerName);
                break;
                //default:
                //    ///ZQ 20111020 add 增加重启提示
                //    MessageBox.Show("修改的记录只有应用系统重启以后才能生效!", "提示!");
                //    break;
            }


            //yjl20111103 add
            if (pGridControl.Rows.Count > idx)
            {
                //取消默认的第1行选中
                pGridControl.Rows[0].Selected = false;
                //设置选择行
                pGridControl.Rows[idx].Selected = true;
                //设置当前行
                pGridControl.CurrentCell = pGridControl.Rows[idx].Cells[0];
            }
            /////
            if (this.WriteLog)
            {
                Plugin.LogTable.Writelog(Caption);//xisheng 2011.07.09 增加日志
            }

            /*       Exception eError;
             *     AddGroup frmGroup = new AddGroup();
             *     if (frmGroup.ShowDialog() == DialogResult.OK)
             *     {
             *         ModuleOperator.DisplayRoleTree("", m_Hook.RoleTree, ref ModData.gisDb, out eError);
             *         if (eError != null)
             *         {
             *             ErrorHandle.ShowFrmError("提示", eError.Message);
             *             return;
             *         }
             *     }
             */
        }
Ejemplo n.º 5
0
        //添加记录菜单响应
        public override void OnClick()
        {
            if (m_Hook.GridCtrl == null)
            {
                return;
            }
            FaceControl  pfacecontrol = (FaceControl)m_Hook.MainUserControl;
            DataGridView pGridControl = m_Hook.GridCtrl;

            if (pfacecontrol.getEditable() == false)
            {
                return;
            }
            string connstr, Tablename;

            //获取数据库连接串和表名
            connstr   = pfacecontrol.m_connstr;
            Tablename = pfacecontrol.m_TableName;
            FaceControl pFaceControl = ( FaceControl )(m_Hook.MainUserControl);

            if (pGridControl.DataSource == null)
            {
                return;
            }
            //初始化添加记录对话框
            TableForm myTableForm = new TableForm(pGridControl, connstr, Tablename);

            myTableForm.InitForm("ADD");
            DialogResult result = myTableForm.ShowDialog();

            if (result == DialogResult.OK) //changed by xisheng 2011.06.16
            {                              //记录添加后再次初始化dataview控件
                pfacecontrol.InitDataInfoList(Tablename, true);
            }
            else
            {
                pfacecontrol.InitDataInfoList(Tablename, false);
            }
            ////ZQ   20111017   add  及时更新数据字典
            switch (Tablename)
            {
            case "属性对照表":
                SysCommon.ModField.InitNameDic(Plugin.ModuleCommon.TmpWorkSpace, SysCommon.ModField._DicFieldName, "属性对照表");
                break;

            case "标准图层代码表":
                SysCommon.ModField.InitLayerNameDic(Plugin.ModuleCommon.TmpWorkSpace, SysCommon.ModField._DicLayerName);
                break;
                //default:
                //    ///ZQ 20111020 add 增加重启提示
                //    MessageBox.Show("添加的记录只有应用系统重启以后才能生效!","提示!");
                //    break;
            }
            /////
            if (this.WriteLog)
            {
                Plugin.LogTable.Writelog(Caption);//xisheng 2011.07.09 增加日志
            }
            //OleDbCommandBuilder builder = new OleDbCommandBuilder(pFaceControl.m_Adapter );
            ////将数据提交到数据库更新
            //try
            //{
            //    pFaceControl.m_Adapter.Update(pFaceControl.m_dataTable);
            //    //提交后重新获取数据
            //    pFaceControl.m_dataTable.Clear();
            //    pFaceControl.m_Adapter.Fill(pFaceControl.m_dataTable);
            //    pGridControl.DataSource = null;
            //    pGridControl.DataSource = pFaceControl.m_dataTable;
            //    //gridControl.Update();
            //}
            //catch (System.Exception m)
            //{
            //    Console.WriteLine(m.Message);
            //}
            //pGridControl = null;
            //pFaceControl = null;

            /*       Exception eError;
             *     AddGroup frmGroup = new AddGroup();
             *     if (frmGroup.ShowDialog() == DialogResult.OK)
             *     {
             *         ModuleOperator.DisplayRoleTree("", m_Hook.RoleTree, ref ModData.gisDb, out eError);
             *         if (eError != null)
             *         {
             *             ErrorHandle.ShowFrmError("提示", eError.Message);
             *             return;
             *         }
             *     }
             */
        }