/// <summary> /// Returns true if ICON table exists otherwise false. /// </summary> /// <param name="iconTableName"></param> /// <param name="dbConnection"></param> /// <returns></returns> public static bool IsIconsTblExists(string iconTableName, DIConnection dbConnection) { bool RetVal = false; string sqlString = "Select count(*) from " + iconTableName + " where 1=2"; try { if ((dbConnection.ExecuteScalarSqlQuery(sqlString) != null)) { RetVal = true; } } catch (Exception ex) { RetVal = false; } return(RetVal); }
/// <summary> /// Get path for selected area starting from root area /// </summary> /// <param name="ElementNid">ID of selected Data</param> /// <param name="DI_QueryBase">This contains Connection Details</param> /// <returns>String containg the path of area node starting from root node</returns> public static string GetAreaChain(int AreaNId, DIConnection DIConnection, DIQueries DIQueries) { string RetVal = string.Empty; string sSql = string.Empty; int AreaLevel = 1; // Get Current Area Level sSql = DIQueries.Area.GetArea(FilterFieldType.NId, AreaNId.ToString()); DataTable dtArea = DIConnection.ExecuteDataTable(sSql); if (dtArea != null & dtArea.Rows.Count > 0) { AreaLevel = (int)dtArea.Rows[0][Area.AreaLevel]; } //Get concatinated Area names sSql = DIQueries.Area.GetAreaChain(AreaNId, AreaLevel, DIConnection.ConnectionStringParameters.ServerType); RetVal = DIConnection.ExecuteScalarSqlQuery(sSql).ToString(); return(RetVal); }
/// <summary> /// Inserts Icon into ICON table /// </summary> /// <param name="dbConnection"></param> /// <param name="dbQueries"></param> /// <param name="buffer"></param> /// <param name="iconType"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="elementType"></param> /// <param name="elementNid"></param> /// <returns></returns> public static int InsertIcon(DIConnection dbConnection, DIQueries dbQueries, byte[] buffer, string iconType, int width, int height, string elementType, string elementNid) { int RetVal = 0; //System.Data.OleDb.OleDbCommand cmd; //OleDbParameter prmPic = new OleDbParameter(); DbCommand Command = dbConnection.GetCurrentDBProvider().CreateCommand(); DbParameter Parameter; string SqlQuery = string.Empty; try { SqlQuery = DevInfo.Lib.DI_LibDAL.Queries.Icon.Insert.InsertIcon(dbQueries.DataPrefix, iconType, width, height, elementType, elementNid); //-- Change for Online Database SqlQuery = SqlQuery.Replace("?", "@Element_Icon"); //SqlQuery = dbQueries.FetchAndUpdateIcons(1, clsIcons.TableName, iconType, width, height, elementType, elementNid); // -- Get New NID generated //cmd = new OleDbCommand(SqlQuery, (OleDbConnection)dbConnection.GetConnection); //cmd.CommandType = CommandType.Text; Command.Connection = dbConnection.GetConnection(); Command.CommandText = SqlQuery; Command.CommandType = CommandType.Text; Parameter = dbConnection.GetCurrentDBProvider().CreateParameter(); { //prmPic.ParameterName = "@Element_Icon"; ////the name used in the query for the parameter //prmPic.OleDbType = OleDbType.Binary; ////set the database type //prmPic.Value = buffer; ////assign the contents of the buffer to the value of the parameter Parameter.ParameterName = "@Element_Icon"; //the name used in the query for the parameter Parameter.DbType = DbType.Binary; //set the database type Parameter.Value = buffer; //assign the contents of the buffer to the value of the parameter } //cmd.Parameters.Add(prmPic); Command.Parameters.Add(Parameter); //-- add the parameter to the command //cmd.ExecuteNonQuery(); Command.ExecuteNonQuery(); //-- this saves the image to the database RetVal = Convert.ToInt32(dbConnection.ExecuteScalarSqlQuery("SELECT @@IDENTITY")); } catch (Exception ex) { throw new ApplicationException(ex.Message); } finally { if ((Command != null)) { Command.Dispose(); } } return(RetVal); }