Click here to Skip to main content
16,016,770 members

Comments by Scott A Parker (Top 4 by date)

Scott A Parker 4-Jun-13 10:36am View    
Deleted
No need to serialize the settings... Just save the settings as they would appear in code and have your application substitute them in the place of the code settings.

public Font AdjustFontSettings()
{
// Code to read settings here

string fntFam = "Arial"; // <-- Represented by string stored in settings file
float fntSize = 15; // <-- Represented by string stored in settings file
string fntStyle = "Regular"; // <-- Represented by string stored in settings file
Font myFont = null;

switch (fntStyle)
{
case "Bold":
myFont = new Font(fntFam, fntSize, FontStyle.Bold);
break;

case "Italic":
myFont = new Font(fntFam, fntSize, FontStyle.Italic);
break;

case "Regular":
myFont = new Font(fntFam, fntSize, FontStyle.Regular);
break;

case "Strikeout":
myFont = new Font(fntFam, fntSize, FontStyle.Strikeout);
break;

case "Underline":
myFont = new Font(fntFam, fntSize, FontStyle.Underline);
break;
}

return myFont;

}
Scott A Parker 3-May-13 17:42pm View    
Here is some code from a personal project. I use MySql but the procedures should be fairly consistent across most SQL database systems or should be easy to modify.

<pre lang="c#">//********************************************************************************
//Convert image for storage in database
//********************************************************************************

MemoryStream stream = new MemoryStream();
picID.Image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] pic_data = stream.ToArray();


string q = "Update customer Set Customer_FirstN='" + FName + "', Customer_MiddleN='" + MName + "', Customer_LastN='" + LName +
"', Customer_Add1='" + Add1 + "', Customer_Add2='" + Add2 + "', Customer_City='" + City + "', Customer_State='" + State +
"', Customer_Zip='" + Zip + "', Customer_Phone='" + Phone + "', Customer_Cell='" + Cell + "', Customer_Sex='" + Sex +
"', Customer_Race='" + Race + "', Customer_Height='" + Height + "', Customer_Weight='" + Weight + "', Customer_Eyes='" + Eyes +
"', Customer_Hair='" + Hair + "', Customer_Flag='" + Flag + "', Customer_Notes='" + Note + "', Customer_ID_Num='" + IdNum +
"', Customer_ID_Issue_State='" + IdState + "', Customer_ID_Type='" + IdType + "', Customer_BDate='" + DOB + "', Customer_ID_Exp='" + IdExp +
"', Customer_ID_Issue='" + IdIssue + "', Customer_Class='" + Class + "', Customer_Image=@Pic Where Customer_ID_Num='" + txtIDNum.Text + "'";


string Param = "@Pic";

public void dbWrite(string Query, string Param, Array pic_data )
{

MySqlConnection con = new MySqlConnection(conStr);
MySqlCommand cmd = new MySqlCommand(Query, con);
if (Param != null)
{
cmd.Parameters.AddWithValue(Param, pic_data);
}

con.Open();
cmd.ExecuteNonQuery();
}

//Reading image from database
//*************************************************************************
public MemoryStream dbReadImage(string Query, string Image)
{
MemoryStream stream;

MySqlConnection con = new MySqlConnection(conStr);
MySqlCommand cmd = new MySqlCommand(Query, con);

MySqlDataAdapter dp = new MySqlDataAdapter(cmd);
DataSet ds = new DataSet("MyImages");

byte[] MyData = new byte[0];

dp.Fill(ds, "MyImages");
DataRow myRow;
myRow = ds.Tables["MyImages"].Rows[0];

MyData = (byte[])myRow[Image];

return stream = new MemoryStream(MyData);

}</pre>
Scott A Parker 3-May-13 17:25pm View    
If you are logging into Active Directory then the "Environment.UserName" will be your logged in user ID as well as your userid for the computer. If you are interested in any possible user that may be or may have been logged in you will need to look in WMI.
Scott A Parker 3-May-13 16:52pm View    
You might want to create an XML file and use it for saving your settings.