Ejemplo n.º 1
0
        // not caching Command
        public DataSet RunQuery(String strQueryCommand)
        {
            Database db = CurrentDatabase;

            if (CurrentDatabase == null)
            {
                if (DataStructureProvider.IsQuerySystemDB(strQueryCommand))
                {
                    db = DataQueryProvider.SystemDatabase;
                }
                else
                {
                    db = DataQueryProvider.CompanyDatabase;
                }
            }

            if (DataQueryProvider.IsSQLConnection(db) == false)
            {
                strQueryCommand = SQLiteDatabaseHelper.RepairSelectSQLite(strQueryCommand);
                strQueryCommand = strQueryCommand.Replace("N'", "'");
            }
            DbCommand cmd = GetQuery(strQueryCommand);

            if (cmd == null)
            {
                return(null);
            }

            return(RunCommand(cmd));
        }
Ejemplo n.º 2
0
        public object RunScript(string strScriptQuery, BusinessObject obj)
        {
            Database db = CurrentDatabase;

            if (CurrentDatabase == null)
            {
                if (DataStructureProvider.IsQuerySystemDB(strScriptQuery))
                {
                    db = DataQueryProvider.SystemDatabase;
                }
                else
                {
                    db = DataQueryProvider.CompanyDatabase;
                }
            }

            if (String.IsNullOrWhiteSpace(strScriptQuery))
            {
                return(null);
            }

            if (DataQueryProvider.IsSQLConnection(db) == false)
            {
                strScriptQuery = SQLiteDatabaseHelper.RepairSelectSQLite(strScriptQuery);
            }


            try
            {
                DbCommand cmd = GetScriptCommand(strScriptQuery);
                AddParameterForObject(obj, cmd);

                db.ExecuteNonQuery(cmd);
                Guid ret = ABCHelper.DataConverter.ConvertToGuid(db.GetParameterValue(cmd, DataStructureProvider.GetPrimaryKeyColumn(obj.AATableName)));
                return(ret);
            }
            catch (System.Exception ex)
            {
                ABCHelper.ABCMessageBox.Show(ex.Source + ex.Message, "Database Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(0);
            }
        }
Ejemplo n.º 3
0
        public string ExecuteScript(String strScript)
        {
            Database db = CurrentDatabase;

            if (CurrentDatabase == null)
            {
                if (DataStructureProvider.IsQuerySystemDB(strScript))
                {
                    db = DataQueryProvider.SystemDatabase;
                }
                else
                {
                    db = DataQueryProvider.CompanyDatabase;
                }
            }

            try
            {
                if (DataQueryProvider.IsSQLConnection(db) == false)
                {
                    strScript = SQLiteDatabaseHelper.RepairSelectSQLite(strScript);
                }

                db.ExecuteNonQuery(CommandType.Text, strScript);
                return("Command excute succesfully!");
            }
            catch (System.Exception ex)
            {
                if (ex is System.Data.SqlClient.SqlException)
                {
                    if (((System.Data.SqlClient.SqlException)ex).ErrorCode == -2146232060 && ex.Message.Contains("TCP Provider"))
                    {
                        ShowDisconnectWaitingDialog();
                    }
                }

                return(ex.Message);
            }
        }
Ejemplo n.º 4
0
        // caching Command
        public DataSet RunScript(string strScriptQuery)
        {
            Database db = CurrentDatabase;

            if (CurrentDatabase == null)
            {
                if (DataStructureProvider.IsQuerySystemDB(strScriptQuery))
                {
                    db = DataQueryProvider.SystemDatabase;
                }
                else
                {
                    db = DataQueryProvider.CompanyDatabase;
                }
            }

            if (String.IsNullOrWhiteSpace(strScriptQuery))
            {
                return(null);
            }

            if (DataQueryProvider.IsSQLConnection(db) == false)
            {
                strScriptQuery = SQLiteDatabaseHelper.RepairSelectSQLite(strScriptQuery);
            }


            try
            {
                DbCommand cmd = GetScriptCommand(strScriptQuery);
                return(db.ExecuteDataSet(cmd));
            }
            catch (System.Exception ex)
            {
                ABCHelper.ABCMessageBox.Show(ex.Message);
                return(null);
            }
        }