Wednesday, May 23, 2012

ASP.NET...writing my first blog

Having read Scott Mitchell's readings, I wrote a blog, which is based on a simplistic style.  Here's the .aspx page for About.aspx.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="About.aspx.cs" Inherits="About" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head id="Head1" runat="server">
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
 <h1>@Jon's <img src="images/sofa.jpg" alt="logo"/> </h1>
 <div style="float:left;width:122px">
        <p style="width: 122px; height: 663px; margin-top: 0px; margin-right: 0px;">
        <a href="About.aspx">About me</a> <br />
        <a href="Diary.aspx">My diary</a> <br />
        <a href="Articles.aspx">Articles</a> <br />
        <a href="Bookmarks.aspx">My bookmarks</a> <br />
        <a href="Promotions.aspx">Promotions</a> <br />
        <a href="Resume.aspx">My resume</a> <br />
        <a href="Warez.aspx">Filesharing</a> <br />
<p><img src="images/jon.jpg" alt="Jon" align="left"/> Name's Jon, I was born on 15th January 1980.  I was raised in a <a target="_top" href="">family of 4</a> and still live with my parents and a younger sister. in <a target="_top" href=",14.4625&sspn=0.037615,0.077162&ie=UTF8&geocode=FVu9IwIdJK7cAA&split=0">Birkirkara </a>, <a target="_top" href="">Malta</a>.
I've always enjoyed freedom and fun throughout most of my youth, with the exception of a 2 year relationship, and I still consider myself young at heart... </body></p>
<p>Since I was focused on a career, I did not really bother about relationships as much, because business is a jungle, and, I was trained to think that you're either gonna live on the edge or you will get surpassed by competition.  Unfortunately this happened following a <a target="_top" href="">global recession</a>. </p>
<p>When it comes to fun, I daresay that I'm pretty cool and spontaneous, my friends would say I'm like Dean Martin, or Steve Mc Queen I guess :)  I'm simplistic, an extrovert (speak my mind), easy going, and, take life with a pinch of salt.</p>
<p>When it comes to working I'm detail oriented, procedural and, a hell of a perfectionist, although tend to delegate, prioritize and sometimes delay what I perceive as "low priority items".  Who doesn't honest? :) </p>
<p>I enjoy listening to a variety of music including Goa Trance, Psychadelic Trance, Rock, Metal (80s/90s...); currently I listen to stuff on <a target="_top" href="">MTV</a> and <a target="_top" href="">my favorite radio station</a>.  In addition to my interest in music, I am a bit of a bookworm, although I seldom read fiction.  I'm more fascinated by technical, scientific, and, academic topics, business news and current affairs. I go to gym to keep fit as well, although I tend to procrastinate because physical activities are not my favourite hobbies. I enjoy watching scientific <a target="_top" href="">documentaries</a> and music videos on TV.</p>
<p>More about my professional life <a target="_top" href=""> here</a>.  Up to a few years ago I was more focused on building a career, however since my career seemed to have taken a wrong turn, I've seen my salary go down by 1.6 times (2008), and, that was a bad shot to my personal lifestyle. </p>
<p>How can you contact me?
   You can peep my profile at <a target="_top" href="">facebook</a> :)  We can also chat with <a target="_top" href="msnim:chat? ">MSN</a>.  Scammers and spammers will be, of course reported to <a target="_top" href="">the authorities</a>.</p>

public class Invoice { public int InvoiceNumber { get { return 2; } set { } } } Other code behind form that sits behind desktop applications, this time for keeping membership details, although I have a slight technical problem figuring out how to bind an image to an SQL Server native type this far: using System; using System.IO; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Reflection; using System.Data.SqlClient; using System.Diagnostics; namespace TestUI { public partial class frmUserDetails : Form { public frmUserDetails() { InitializeComponent(); } private void label1_Click(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { } private void btnSave_Click(object sender, EventArgs e) { try { string connectionString = TestUI.Properties.Settings.Default.UserStoreConnectionString; using (SqlConnection con = new SqlConnection(connectionString)) { bool userExists = false; con.Open(); if (userExists) { string commandText = "UPDATE [UserStore].[dbo].[user] SET Name = @Name, Surname = @Surname, @Userimage WHERE UserID = @UserID;"; SqlCommand command = new SqlCommand(commandText, con); command.Parameters.AddWithValue("@UserId", 0); MemoryStream _stream = new MemoryStream(); pcbMember.Image.Save(_stream, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] _pic = _stream.ToArray(); command.Parameters.AddWithValue("@UserImage", _pic); if (txtName.Text != null) { command.Parameters.AddWithValue("@Name", txtName.Text); } if (txtSurname.Text != null) { command.Parameters.AddWithValue("@Surname", txtSurname.Text); } command.ExecuteNonQuery(); Debug.WriteLine("Existing user saved."); } else if (!userExists) { int _count = 0; string commandText = "INSERT INTO [UserStore].[dbo].[user] VALUES (Name = @Name, Surname = @Surname, UserPicture = @UserPicture, UserID = @UserID);"; SqlCommand command = new SqlCommand(commandText, con); command.Parameters.AddWithValue("@UserID", _count++); command.Parameters.AddWithValue("@Name", txtName.Text); command.Parameters.AddWithValue("@Surname", txtSurname.Text); command.Parameters.AddWithValue("@UserPicture", pcbMember.Image); command.ExecuteNonQuery(); Debug.WriteLine("New user saved."); con.Close(); } } } catch (Exception ex) { Debug.WriteLine(ex.Message); Debug.WriteLine(ex.Source); Debug.WriteLine(ex.StackTrace); } finally { } } private void createFields() { } public object DataSource; private void pcbMember_MouseDoubleClick(object sender, MouseEventArgs e) { OpenFileDialog op = new OpenFileDialog(); DialogResult result = op.ShowDialog(); } private void pcbMember_Click(object sender, EventArgs e) { } } }

1 comment: