Hi Charles,
I have review your code and have couple of suggestions:
- When creating SqlCommand objects, try using the "using" command to speed up your code and allow the .Net garbage collection to dispose the object more efficiently.
public void fillAll()
{
using (SqlCommand oSqlCmd = new SqlCommand())
{
oSqlCmd.CommandText = "SELECT * FROM Customers ORDER BY cust_LastName";
FillDataTable(oSqlCmd);
}
}
- When creating Sql CommandText, take advantage of the String.Format to build your SQL string and use Parameters instead of adding the value to the string, here is a sample of your CustomersBO.fillByLastName method:
public void fillByLastName(string lastName)
{
using (SqlCommand oSqlCmd = new SqlCommand())
{
oSqlCmd.CommandText = String.Format("SELECT * FROM {0} WHERE UPPER(cust_LastName) LIKE '{1}'% ORDER BY cust_LastName", this.TableNameAndSchema, "@LastName");
oSqlCmd.Parameters.AddWithValue("@LastName", lastName.ToUpper()).SqlDbType = SqlDbType.VarChar;
FillDataTable(oSqlCmd);
}
}
Your project is pretty good organized, that is important, as well as your naming convention too. In my case for SF Custom Field Properties I would prefix the property with "cfp_", so when using it in the field builders of DevExpress, I can clearly know this is a Custom Field Property:
[Browsable(false),
BusinessFieldDisplayInEditor,
Description("Customer Last, First and Middle Name"),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public string cfp_cust_LastFirstMiddle
{
get
{
return string.Format("{0}, {1} {2}", this.cust_LastName, this.cust_FirstName, this.cust_MiddleName);
}
}
Also, I would always use a Base Business Object class, to hold common methods and properties like the FillAll() method which it is mostly used by every BO.
Again, those are just suggestions, which means, there is nothing wrong with your original code.
Oh, I almost forgot, in your document to said:
"Alsoanother big thanks to Edhy for ignoring my request to help with regards to mycomplete and total ignorance of using this tool."
Not quite true based on the number of post I have here
I probably missed a post due to a lot of work with my customers, fortunately since last November 2013 I have been pretty busy working on several project and not having too much time to share with my peers.
Now where is your version of the StrataFlix database so I can test your would project?
Let's the fun begin.....
Edhy Rijo