Search

QDapp.net @ WordPress

Blog site for QDapp.net

Author

qdappnet

My Favorite Apps and Utilities for Windows

Audacity

Audacity is a free, open source, cross-platform audio software for multi-track recording and editing

My usage: Cut, paste, delete, edit mp3 audio/songs for phone ringtones. Increase/amplify volume audio/songs. Format and convert audio formats.

Bulk Rename Utility

Bulk Rename Utility: file renaming software for Windows, free for personal use.
Easily rename files and entire folders based upon extremely flexible criteria.
Add date/time stamps, replace numbers, insert text, convert case, add auto-numbers, process folders and sub-folders

My usage: mass rename files, rename file extension, update file name casing.

…to be continued..

[JavaScript] Popup in middle of the screen using JavaScript

function Popup() {
	var link = "https://qdappnet.wordpress.com/";
	var name = "QDappnet";
	var height = 800;
	var width = 800;
	var top = (screen.height - height )/2;
	var left = (screen.width - width )/2;
	var options = "menubar=no,width=" + width + ",height=" + height + ",resizable=yes,top=" + top + ",left=" + left;
	window.open(link,name,options);
}

[C#] Download a file from a URL to local PC using ASP.NET C#

using System.Net;
using System.IO;
string url = "https://s1.wp.com/i/favicons/android-chrome-192x192.png";

Uri uri = new Uri(url);
string fileName = Path.GetFileName(uri.LocalPath);
string fileExt = Path.GetExtension(uri.LocalPath);
string savePath = Path.Combine(@"C:\Temp\", fileName);

WebClient webClient = new WebClient();
//Optional to access window authenticated files
//webClient.Credentials = new NetworkCredential([username], [password], [domain]);
webClient.DownloadFile(url, savePath);

[C#] Various Functions to Get / Set Data from / to MS SQL for Your C# Apps

ExecuteNonQuery

ExecuteNonQuery() is used for executing statements that do not return result sets (ie. statements like insert data , update data etc.)

public bool SetSQL(string connectionString, string commandString)
{
	try
	{
		using (SqlConnection sqlConn = new SqlConnection(connectionString))
		{
			using (SqlCommand sqlComm = new SqlCommand(commandString, sqlConn))
			{
				sqlConn.Open();
				sqlComm.ExecuteNonQuery();
			}
		}
		return true;
	}
	catch
	{
		return false;
	}
}

ExecuteScalar

ExecuteScalar() is using for retrieve a single value from Database. It executes SQL statements & Stored Procedure and returned a scalar value on first column of first row in the returned Result Set.

public string GetSQLSingle(string connectionString, string commandString)
{
	string strReturn = "";
	try
	{
		using (SqlConnection sqlConn = new SqlConnection(connectionString))
		{
			using (SqlCommand sqlComm = new SqlCommand(commandString, sqlConn))
			{
				sqlConn.Open();
				strReturn = sqlComm.ExecuteScalar().ToString();
			}
		}
		return strReturn;
	}
	catch
	{
		return strReturn;
	}
}

ExecuteReader

ExecuteReader() instantiates a SqlClient.SqlDataReader Object.

public string GetSQL(string connectionString, string commandString)
{
	string strColumn1 = "", strColumn2 = "";
	try
	{
		using (SqlConnection sqlConn = new SqlConnection(connectionString))
		{
			using (SqlCommand sqlComm = new SqlCommand(commandString, sqlConn))
			{
				sqlConn.Open();
				SqlDataReader sqlReader = sqlComm.ExecuteReader();
				while (sqlReader.Read())
				{
					strColumn1 = sqlReader["Column1"].ToString();
					strColumn2 = sqlReader["Column2"].ToString();
				}
				sqlReader.Close();
			}
		}
		return strColumn1 + "," + strColumn2;
	}
	catch
	{
		return "";
	}
}

SqlDataAdapter DataSet

Use SqlDataAdapter to fill a DataSet (data in a table style)

public DataSet GetSQLDataSet(string connectionString, string commandString)
{
	DataSet dataSet = new DataSet();
	try
	{
		using (SqlConnection sqlConn = new SqlConnection(connectionString))
		{
			using (SqlCommand sqlComm = new SqlCommand(commandString, sqlConn))
			{
				sqlConn.Open();
				using (SqlDataAdapter da = new SqlDataAdapter(sqlComm))
				{
					da.Fill(dataSet);
				}
			}
		}
		return dataSet;
	}
	catch
	{
		return dataSet;
	}
}

SqlDataAdapter DataTable

Use SqlDataAdapter to fill a DataTable (data in a table style) – TAKE LESS MEMORY

public DataTable GetSQLDataTable(string connectionString, string commandString)
{
	DataTable dataTable = new DataTable();
	try
	{
		using (SqlConnection sqlConn = new SqlConnection(connectionString))
		{
			using (SqlCommand sqlComm = new SqlCommand(commandString, sqlConn))
			{
				sqlConn.Open();
				using (SqlDataAdapter da = new SqlDataAdapter(sqlComm))
				{
					da.Fill(dataTable);
				}
			}
		}
		return dataTable;
	}
	catch
	{
		return dataTable;
	}
}

How to add bcc function to OpenCart email class

Locate file to edit

OpenCart email class is defined in mail.php: \system\library\mail.php
mail.php may be cached: \system\library\cache\mail.php
If you have vqmod installed, it may be cached here \vqmod\vqcache\vq2-system_library_mail.php

Codes

  1. After “protected $to;” add variable

    protected $bcc;

  2. After “public function setTo($to)” function, add bcc function

    public function setBcc($bcc) {
    $this->bcc = $bcc;
    }

  3. Modify “public function send()” function
    You can add after “if ($this->protocol != ‘mail’) {” statement
    Or you can add to any where within setting “$header” variable section

    if ($this->bcc) {
    $header .= ‘Bcc: ‘ . $this->bcc . ‘\n’
    }

Usage

For example, I was trying to add BCC to admin email in an OpenCart site whenever a user tries to re-set his/her user — See Customize OpenCart Forgotten Password Email
So, I would modify codes on this file \catalog\controller\account\forgotten.php by adding a line of code after “$mail->setTo…”

$mail->setBcc(“myemail@myemailprovider.com”);

Customize OpenCart Forgotten Password Email

To edit text on forgotten email page – route=account/forgotten

Modify file: \catalog\language\english\account\forgotten.php

To edit forgotten email sends to customer

  • Text: \catalog\language\english\account\forgotten.php
  • Codes: \catalog\controller\account\forgotten.php

Customize OpenCart New Customer Email

To enable new customer email sends to admin

Admin => System => Settings => Edit store => Option tab => Account section => Check Yes on New Account Alert Mail

To edit emails send to admin and customer

  • Text: \catalog\language\en-gb\mail\customer.php
  • Content: \catalog\model\account\customer.php

 

How to create, read and update Application Settings (.NET)

Create Application Settings

In Visual Studio, right click on your application project => Properties => Settings
OR Menu => Project => [Your project name] Properties… => Settings

There are 2 scopes:
– User: Can set at design time and update at run time.
– Application: Can only set at design time and can’t be modified at run time.

Read Application Settings

var yourUserSettingValue = Properties.Settings.Default.YOUR_USER_SETTING_NAME;
var yourApplicationSettingValue = Properties.Settings.Default.YOUR_APPLICATION_SETTING_NAME;

Update Application Settings (Only apply to User scope)

Properties.Settings.Default.YOUR_USER_SETTING_NAME = NEW_VALUE;
Properties.Settings.Default.Save();

How to Read Application Settings from the Web.config File

Create Web.config

If you web site doesn’t have Web.config file, you can create one

  • Using Visual Studio: Right click on your web site > Add > Add New Item… > Web Configuration File > Web.config
  • Manually: Create a text file and change name to Web.config at your web site root folder

Add application settings (key-value pair)

Open Web.config

<?xml version=”1.0″?>
<configuration>

<appSettings>
<add key=”KeyName1″ value=”KeyValue2″/>
<add key=”KeyName2″ value=”KeyValue2″/>

</appSettings>
</configuration>

Read application settings

  1. Add:
    using System.Web.Configuration;
  2. Codes:
    var key1 = WebConfigurationManager.AppSettings[“KeyName1”];
    var key2 = WebConfigurationManager.AppSettings[“KeyValue2”];

 

 

Create a free website or blog at WordPress.com.

Up ↑