using System;
using System.Data.OleDb;
using System.Collections.Generic;
using System.Text;
namespace Web.DataAccess
{
public sealed class AccessHelperUtility
{
private AccessHelperUtility() { }
public static Dictionary<string, OleDbParameter> OleDbParameterArrayToGDictionary(params OleDbParameter[] paras)
{
if (null == paras) throw new ArgumentNullException("paras");
Dictionary<string, OleDbParameter> retval = new Dictionary<string, OleDbParameter>();
foreach (OleDbParameter p in paras) retval.Add(p.ParameterName, p);
return retval;
}
public static List<OleDbParameter> OleDbParameterGDictionaryToGList(Dictionary<string, OleDbParameter> paras)
{
if (null == paras) throw new ArgumentNullException("paras");
List<OleDbParameter> retval = new List<OleDbParameter>();
foreach (string k in paras.Keys) retval.Add(paras[k]);
return retval;
}
public static OleDbParameter[] OleDbParameterGDictionaryToArray(Dictionary<string, OleDbParameter> paras)
{
if (null == paras) throw new ArgumentNullException("paras");
List<OleDbParameter> retval = new List<OleDbParameter>();
foreach (string k in paras.Keys)
retval.Add(paras[k]);
return retval.ToArray();
}
}
}
/// <summary>
/// Copy selected item from DGV.
/// </summary>
/// <param name="sender">A ToolStripDropDownItem</param>
/// <param name="e"></param>
private void copyToolStripMenuItem_Click(object sender, EventArgs e)
{
// The context menu strip called this method, so we need to determine which DGV it was clicked on
{
ToolStripDropDownItem item = sender as ToolStripDropDownItem;
if (item == null) // Error
return;
ContextMenuStrip strip = item.Owner as ContextMenuStrip;
grid = strip.SourceControl as DataGridView;
}
if (grid == null) // Control wasn't a DGV
return;
DataObject data = grid.GetClipboardContent();
Clipboard.SetDataObject(data);
}
=begin
r - Open a file for reading. The file must exist.
w - Create an empty file for writing. If a file with the same name already exists its content is erased and the file is treated as a new empty file.
a - Append to a file. Writing operations append data at the end of the file. The file is created if it does not exist.
r+ - Open a file for update both reading and writing. The file must exist.
w+ - Create an empty file for both reading and writing. If a file with the same name already exists its content is erased and the file is treated as a new empty file.
a+ - Open a file for reading and appending. All writing operations are performed at the end of the file, protecting the previous content to be overwritten. You can reposition (fseek, rewind) the internal pointer to anywhere in the file for reading, but writing operations will move it back to the end of file. The file is created if it does not exist.
=end
File.open(local_filename, 'w') {|f| f.write(doc) }