Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cmdStr"></param>
        /// <returns></returns>
        internal static ICmd ParseSqlCmdString(string cmdStr, CoreEA.ICoreEAHander dbe)
        {
            ICmd curCmd = null;

            if (string.IsNullOrEmpty(cmdStr))
            {
                ProcessException.DisplayErrors(new Exception("Empty Command"));
                return(null);
            }
            try
            {
                cmdStr = cmdStr.TrimStart();
                cmdStr = cmdStr.TrimEnd();

                //Can't to lower , otherwise the insert data will never 大写
                //cmdText = cmdText.ToLower();
                string tempCmdText = cmdStr.ToLower();
                if (tempCmdText.StartsWith("select"))
                {
                    curCmd = new SelectCmd(dbe);
                }
                else if (tempCmdText.StartsWith("insert"))
                {
                    curCmd = new InsertCmd(dbe);
                }
                else if (tempCmdText.StartsWith("update"))
                {
                    curCmd = new UpdateCmd(dbe);
                }
                else if (tempCmdText.StartsWith("delete"))
                {
                    curCmd = new DeleteCmd(dbe);
                }
                else if (tempCmdText.StartsWith("alter") || (tempCmdText.StartsWith("drop")))
                {
                    curCmd = new SpecialCmd(dbe);
                }
                else if (tempCmdText.StartsWith("create"))
                {
                    curCmd = new CreateCmd(dbe);
                }
                else if (tempCmdText.StartsWith("sp_rename"))
                {
                    curCmd = new SpecialCmd(dbe);
                }
                else
                {
                    curCmd = null;
                    //throw new Exception("ErrorMsg_CannotParseSqlCmd".GetFromResourece());
                }
            }
            catch (Exception ee)
            {
                ProcessException.DisplayErrors(ee);
            }

            return(curCmd);
        }
Exemplo n.º 2
0
        private void butGetTableList_Click(object sender, RoutedEventArgs e)
        {
            WPFCommonControl.SqlServerLoginControl.X_CollectionData controlResult = sqlServerLoginControl1.X_Result;

            string server   = controlResult.Server;
            string database = controlResult.DbName;
            string username = controlResult.UID;
            string pwd      = controlResult.PWD;

            if (string.IsNullOrEmpty(server) || string.IsNullOrEmpty(database) ||
                string.IsNullOrEmpty(username))
            {
                MessageBox.Show("ImportEachElement".GetFromResourece());
                return;
            }

            //This core will be used later , do not dispose it
            core = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.SqlServer).X_Handler;

            LoginInfo_SqlServer info = new LoginInfo_SqlServer()
            {
                X_Server              = controlResult.Server,
                X_UserName            = controlResult.UID,
                X_Pwd                 = controlResult.PWD,
                X_Port                = sqlServerLoginControl1.X_Result.Port.ToString(),
                IsTrustedConn         = sqlServerLoginControl1.X_Result.IsTrust,
                X_CurDbConnectionMode = sqlServerLoginControl1.X_Result.CurType.CurConnMode,
            };

            try
            {
                core.Open(info);
                if (core.IsOpened)
                {
                    this.tableList.Items.Clear();
                    foreach (string item in core.GetTableListInDatabase(database))
                    {
                        tableList.Items.Add(item);
                    }
                }
            }
            catch (Exception ee)
            {
                ee.HandleMyException();
            }
            finally
            {
            }
        }
Exemplo n.º 3
0
        void IStep.Leave()
        {
            DocDbObject myInfo = (DocDbObject)MyDocDataContext;

            myInfo.LoginInfo = ((LoginInfo_Oledb)((ISrcControl)this).X_Result);

            try
            {
                CoreEA.ICoreEAHander tempHandler = null;

                if ((bool)radAccess.IsChecked)
                {
                    tempHandler = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.OleDb).X_Handler;
                }
                else if ((bool)radCVS.IsChecked)
                {
                    tempHandler = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.CSV).X_Handler;
                }
                else if ((bool)radExcel.IsChecked)
                {
                    tempHandler = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.Excel).X_Handler;
                }

                tempHandler.Open(myInfo.LoginInfo);
                if (tempHandler.IsOpened)
                {
                }
                else
                {
                    throw new Exception("Password not correct");
                }
            }
            catch (Exception ee)
            {
                throw ee;
            }
        }
Exemplo n.º 4
0
 public UpdateCmd(CoreEA.ICoreEAHander dbe)
     : base()
 {
     base.CurDBE = dbe;
 }
Exemplo n.º 5
0
 public SrcTableList(CoreEA.ICoreEAHander inCore)
 {
     core = inCore;
     InitializeComponent();
 }
Exemplo n.º 6
0
 public SpecialCmd(CoreEA.ICoreEAHander dbe)
     : base()
 {
     base.CurDBE = dbe;
 }
Exemplo n.º 7
0
        private void butGetDbList_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(cmbServername.Text))
            {
                cmbServername.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txtUsername.Text))
            {
                txtUsername.Focus();
                return;
            }

            CoreEA.ICoreEAHander core = null;

            switch (X_CurUIMode)
            {
            case CurUIMode.ForSqlServer:
                core = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.SqlServer).X_Handler;
                break;

            case CurUIMode.ForMySql:
                core = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.MySql).X_Handler;
                break;
            }

            LoginInfo_SqlServer info = new LoginInfo_SqlServer();
            X_LoginDbParas      args = cmbConnMode.SelectedItem as X_LoginDbParas;

            if (args.Name == ATTACH_FILE)
            {
                info = new LoginInfo_SqlServer()
                {
                    X_Server  = cmbServername.Text,
                    AttchFile = txtDbFileLocation.Text,
                    //attach file mode need trust connection
                    IsTrustedConn = true,
                };
            }
            else
            {
                info = new LoginInfo_SqlServer()
                {
                    X_Server      = cmbServername.Text,
                    X_UserName    = txtUsername.Text,
                    X_Pwd         = passwordBox1.Password,
                    IsTrustedConn = (bool)chkIsTrustedConn.IsChecked,
                };
            }

            if (cmbConnMode.SelectedItem != null)
            {
                info.X_CurDbConnectionMode = ((X_LoginDbParas)cmbConnMode.SelectedItem).CurConnMode;
            }

            try
            {
                core.Open(info);
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
                return;
            }

            if (core.IsOpened)
            {
                cmbDbName.Items.Clear();

                foreach (var item in core.GetDatabaseList())
                {
                    cmbDbName.Items.Add(item);
                }

                if (cmbDbName.Items.Count > 1)
                {
                    cmbDbName.SelectedIndex = 0;
                }

                core.Close();
                core.Dispose();
            }
        }
Exemplo n.º 8
0
 public InsertCmd(CoreEA.ICoreEAHander dbe)
     : base()
 {
     base.CurDBE = dbe;
 }
Exemplo n.º 9
0
 public SelectCmd(CoreEA.ICoreEAHander dbe)
     : base()
 {
     base.CurDBE = dbe;
 }