Beispiel #1
0
        protected internal Datasource(string connectionString, Core.DataProvider provider)
        {
            try 
            {
                dataProvider = provider;

                if (dataProvider ==  Core.DataProvider.SQL)
                { sqlConnection = new SqlConnection(connectionString); }
                else 
                { oledbConnection = new OleDbConnection(connectionString); }
            }
            catch (Exception)
            {
                throw;
            }          
        }
Beispiel #2
0
 public Connection(string connectionString, Core.DataProvider provider)             
 {
     checkConnection = new Data.CheckConnection(connectionString, provider);
     dataProvider = provider; 
 }
Beispiel #3
0
 public CheckConnection(string connectionString, Core.DataProvider provider) 
 {
     datasource = new Datasource(connectionString, provider);  
 }
Beispiel #4
0
        protected internal bool IsValueAlreadyExist(string tableName, string fieldName, string originalvalue, string currentValue, Core.Operation operation)
        {
            try
            {
                string sql = "";


                if (Core.ProjectDataProvider == Core.DataProvider.OLEDB)
                {

                    if (operation == Core.Operation.INSERT)
                    {
                        sql += "SELECT " +
                             " IIF(COUNT(" + fieldName + ") > 0 ,1,0)" +
                             " FROM " +
                             " " + tableName + " " +
                             " WHERE " +
                             " " + fieldName + " = '" + currentValue + "'";
                    }
                    else
                    {
                        sql += "SELECT " +
                             " IIF(COUNT(" + fieldName + ") > 0 ,1,0)" +
                             " FROM " +
                             " " + tableName + " " +
                             " WHERE " +
                             " " + fieldName + " = '" + currentValue + "' AND " + fieldName + " <> '" + originalvalue + "'";
                    }
                }
                else if (Core.ProjectDataProvider == Core.DataProvider.SQL)
                {
                    if (operation == Core.Operation.INSERT)
                    {
                        sql += "SELECT " +
                              " CASE WHEN COUNT(" + fieldName + ") > 0 THEN " +
                              "     1 " +
                              " ELSE " +
                              "     0 " +
                              " END " +
                              " FROM " +
                              " " + tableName + " " +
                              " WHERE " +
                              " " + fieldName + " = '" + currentValue + "'";
                    }
                    else if (operation == Core.Operation.UPDATE)
                    {
                        sql = "SELECT " +
                            " CASE WHEN COUNT(" + fieldName + ") > 0 THEN " +
                            "   1" +
                            " ELSE " +
                            "   0" +
                            " END  " +
                            " FROM " +
                            " " + tableName + "" +
                            " WHERE " +
                            " " + fieldName + " = '" + currentValue + "' AND " + fieldName + " <> '" + originalvalue + "'";
                    }
                }

                DataTable dt;

                dt = ExecuteQuery(sql).Tables[0];


                if (dt.Rows[0].Field<int?>(0) == 1) return true;
                return false;

            }
            catch (Exception)
            {
                throw;
            }
        }