Click here to Skip to main content
15,918,003 members
Home / Discussions / C#
   

C#

 
GeneralRe: Generic C# operator Pin
Daniel Turini23-Jun-04 9:12
Daniel Turini23-Jun-04 9:12 
GeneralRe: Generic C# operator Pin
Heath Stewart23-Jun-04 10:34
protectorHeath Stewart23-Jun-04 10:34 
GeneralLoosing focus Pin
Anonymous23-Jun-04 8:17
Anonymous23-Jun-04 8:17 
QuestionWhere is the rest of my Datagrid? Pin
kornstyle23-Jun-04 8:05
kornstyle23-Jun-04 8:05 
AnswerRe: Where is the rest of my Datagrid? Pin
Heath Stewart23-Jun-04 9:02
protectorHeath Stewart23-Jun-04 9:02 
GeneralRe: Where is the rest of my Datagrid? Pin
kornstyle23-Jun-04 9:17
kornstyle23-Jun-04 9:17 
GeneralRe: Where is the rest of my Datagrid? Pin
Heath Stewart23-Jun-04 10:32
protectorHeath Stewart23-Jun-04 10:32 
GeneralCode Critique Requested Pin
mealnumberone23-Jun-04 7:49
mealnumberone23-Jun-04 7:49 
I am re-writing an old financial application of mine using ASP.NET. At the same time, I am trying to break into programming using OOP. Below is a segment of my application that I wanted to be critiqued by more experienced developers. Did I implement OOP concepts correctly? Am I wasteful with resources? Any other suggestions? Thank you. Smile | :)

The underlying database table looks like this:
create table Positions
(
SystemId int primary key identity(1,1) not null,
Name varchar(25) not null ,
)

There are two classes:
- Portfolio class which right now only contains properties for my business object;
- PositionsDb class which is responsible for database operations of the application.

namespace Positions
{
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections;

// Portfolio class.
public class Portfolio
{
private int systemId;
private string name;

public Portfolio() { ; }

public int SystemId
{
get { return systemId; }
set { systemId = value; }
}

public string Name
{
get { return name; }
set { name = value; }
}
}

// PositionsDb class. Handles database operations of the application.
public class PositionsDb
{
private SqlConnection connection;

public PositionsDb()
{
;
}

~PositionsDb()
{
connection.Close();
}

public void ConnectToDb()
{
connection = new SqlConnection("Data Source=localhost;Initial Catalog=Positions;User Id=PositionsUser;Password=whatever");
connection.Open();
}

public void AddPortfolio(Portfolio portfolio)
{
// Adds a new portfolio to the database
SqlCommand myCommand;
myCommand = new SqlCommand("AddPortfolio", connection);
myCommand.CommandType = CommandType.StoredProcedure;

myCommand.Parameters.Add(new SqlParameter("@Name", SqlDbType.VarChar, 25));

myCommand.Parameters["@Name"].Value = portfolio.Name;
myCommand.ExecuteNonQuery();
}

public ArrayList GetAllPortfolios()
{
// Gets all portfolios from the database
ArrayList myArrayList = new ArrayList();
Portfolio tempPortfolio;

SqlCommand myCommand;
myCommand = new SqlCommand("GetAllPortfolios", connection);
myCommand.CommandType = CommandType.StoredProcedure;

SqlDataReader myReader;

myReader = myCommand.ExecuteReader();

while (myReader.Read())
{
tempPortfolio = new Portfolio();
tempPortfolio.SystemId = myReader.GetInt32(0);
tempPortfolio.Name = myReader.GetString(1);
myArrayList.Add(tempPortfolio);
}

myReader.Close();
return myArrayList;
}
}
}

GeneralRe: Code Critique Requested Pin
Daniel Turini23-Jun-04 8:38
Daniel Turini23-Jun-04 8:38 
GeneralRe: Code Critique Requested Pin
Heath Stewart23-Jun-04 8:50
protectorHeath Stewart23-Jun-04 8:50 
GeneralRe: Code Critique Requested Pin
Daniel Turini23-Jun-04 9:00
Daniel Turini23-Jun-04 9:00 
GeneralRe: Code Critique Requested Pin
Heath Stewart23-Jun-04 9:06
protectorHeath Stewart23-Jun-04 9:06 
GeneralRe: Code Critique Requested Pin
mealnumberone23-Jun-04 9:11
mealnumberone23-Jun-04 9:11 
GeneralRe: Code Critique Requested Pin
Daniel Turini23-Jun-04 10:25
Daniel Turini23-Jun-04 10:25 
GeneralRe: Code Critique Requested Pin
Steven Campbell23-Jun-04 9:42
Steven Campbell23-Jun-04 9:42 
GeneralDataGrid and end edit Pin
cje23-Jun-04 6:44
cje23-Jun-04 6:44 
GeneralRe: DataGrid and end edit Pin
Heath Stewart23-Jun-04 8:40
protectorHeath Stewart23-Jun-04 8:40 
GeneralRe: DataGrid and end edit Pin
cje23-Jun-04 8:49
cje23-Jun-04 8:49 
GeneralRe: DataGrid and end edit Pin
Heath Stewart23-Jun-04 9:00
protectorHeath Stewart23-Jun-04 9:00 
GeneralRe: DataGrid and end edit Pin
cje23-Jun-04 9:04
cje23-Jun-04 9:04 
QuestionHow-to? Connect to remote pc over LAN connection ? Pin
Adel83k23-Jun-04 5:57
Adel83k23-Jun-04 5:57 
AnswerRe: How-to? Connect to remote pc over LAN connection ? Pin
eggie523-Jun-04 6:44
eggie523-Jun-04 6:44 
GeneralRe: How-to? Connect to remote pc over LAN connection ? Pin
Adel83k24-Jun-04 1:09
Adel83k24-Jun-04 1:09 
AnswerRe: How-to? Connect to remote pc over LAN connection ? Pin
Steven Campbell23-Jun-04 7:19
Steven Campbell23-Jun-04 7:19 
AnswerRe: How-to? Connect to remote pc over LAN connection ? Pin
sides_dale23-Jun-04 15:44
sides_dale23-Jun-04 15:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.