Beispiel #1
0
        private void btnAdd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            FrmDBMtChild frmAdd = new FrmDBMtChild();
            frmAdd.Text = "增加数据库";

            if (frmAdd.ShowDialog() == DialogResult.OK)
            {
                string strIns = "INSERT INTO BASE_ZT_DB (ZTID, SYSTYPE, DBTYPE, SERVER, USERNAME, PASSWORD, DBNAME) VALUES "
                          + "(:ZTID, :SYSTYPE, :DBTYPE, :SERVER, :USERNAME, :PASSWORD, :DBNAME)";

                cmd = new OracleCommand(strIns, Con);
                Adapter.InsertCommand = cmd;
                Adapter.InsertCommand.Parameters.Add(new OracleParameter("ZTID", OracleType.VarChar, 20, "ZTID"));
                Adapter.InsertCommand.Parameters.Add(new OracleParameter("SYSTYPE", OracleType.VarChar, 20, "SYSTYPE"));
                Adapter.InsertCommand.Parameters.Add(new OracleParameter("DBTYPE", OracleType.VarChar, 100, "DBTYPE"));
                Adapter.InsertCommand.Parameters.Add(new OracleParameter("SERVER", OracleType.VarChar, 20, "SERVER"));
                Adapter.InsertCommand.Parameters.Add(new OracleParameter("USERNAME", OracleType.VarChar, 20, "USERNAME"));
                Adapter.InsertCommand.Parameters.Add(new OracleParameter("PASSWORD", OracleType.VarChar, 20, "PASSWORD"));
                Adapter.InsertCommand.Parameters.Add(new OracleParameter("DBNAME", OracleType.VarChar, 100, "DBNAME"));

                DataRow newRow = dt.NewRow();
                newRow["ZTID"] = frmAdd.getZT();
                newRow["SYSTYPE"] = frmAdd.getSysType();
                newRow["DBTYPE"] = frmAdd.getDBType();
                newRow["SERVER"] = frmAdd.getServer();
                newRow["USERNAME"] = frmAdd.getUser();
                newRow["PASSWORD"] = frmAdd.getPass();
                newRow["DBNAME"] = frmAdd.getDBName();

                dt.Rows.Add(newRow);

                Adapter.Update(ds, "BASE_ZT_DB");

                this.FrmDBMt_Load(sender, e);
            }
        }
Beispiel #2
0
        private void btnUpdate_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string strZTID = dataGridView1.CurrentRow.Cells["账套名称"].Value.ToString();
            string strSysType = dataGridView1.CurrentRow.Cells["系统类型"].Value.ToString();
            string strDBType = dataGridView1.CurrentRow.Cells["数据库类型"].Value.ToString();
            string strServer = dataGridView1.CurrentRow.Cells["主机名"].Value.ToString();
            string strUser = dataGridView1.CurrentRow.Cells["用户名"].Value.ToString();
            string strPass = dataGridView1.CurrentRow.Cells["密码"].Value.ToString();
            string strDBName = dataGridView1.CurrentRow.Cells["数据库名称"].Value.ToString();

            FrmDBMtChild frmUpdate = new FrmDBMtChild(strZTID, strSysType, strDBType, strServer, strUser, strPass, strDBName);
            frmUpdate.Text = "修改数据库";
            frmUpdate.cbAccount.Enabled = false;
            frmUpdate.cbSysType.Enabled = false;

            if (frmUpdate.ShowDialog() == DialogResult.OK)
            {
                string strUpdate = "UPDATE BASE_ZT_DB Set DBTYPE = :DBTYPE, SERVER = :SERVER, "
                                 + "USERNAME = :USERNAME, PASSWORD = :PASSWORD, DBNAME = :DBNAME where ZTID = :ZTID and SYSTYPE = :SYSTYPE";

                cmd = new OracleCommand(strUpdate, Con);
                Adapter.UpdateCommand = cmd;
                Adapter.UpdateCommand.Parameters.Add(new OracleParameter("ZTID", OracleType.VarChar, 20, "ZTID"));
                Adapter.UpdateCommand.Parameters.Add(new OracleParameter("SYSTYPE", OracleType.VarChar, 20, "SYSTYPE"));
                Adapter.UpdateCommand.Parameters.Add(new OracleParameter("DBTYPE", OracleType.VarChar, 100, "DBTYPE"));
                Adapter.UpdateCommand.Parameters.Add(new OracleParameter("SERVER", OracleType.VarChar, 20, "SERVER"));
                Adapter.UpdateCommand.Parameters.Add(new OracleParameter("USERNAME", OracleType.VarChar, 20, "USERNAME"));
                Adapter.UpdateCommand.Parameters.Add(new OracleParameter("PASSWORD", OracleType.VarChar, 20, "PASSWORD"));
                Adapter.UpdateCommand.Parameters.Add(new OracleParameter("DBNAME", OracleType.VarChar, 100, "DBNAME"));

                //dt.Rows[dataGridView1.CurrentRow.Index]["ZTID"] = frmUpdate.getZT();
                //dt.Rows[dataGridView1.CurrentRow.Index]["SYSTYPE"] = frmUpdate.getSysType();
                dt.Rows[dataGridView1.CurrentRow.Index]["DBTYPE"] = frmUpdate.getDBType();
                dt.Rows[dataGridView1.CurrentRow.Index]["SERVER"] = frmUpdate.getServer();
                dt.Rows[dataGridView1.CurrentRow.Index]["USERNAME"] = frmUpdate.getUser();
                dt.Rows[dataGridView1.CurrentRow.Index]["PASSWORD"] = frmUpdate.getPass();
                dt.Rows[dataGridView1.CurrentRow.Index]["DBNAME"] = frmUpdate.getDBName();

                Adapter.Update(ds, "BASE_ZT_DB");

                this.FrmDBMt_Load(sender, e);
            }
        }