Meditech NPR Reports / NPR Report Writing / NPR Report Writer / Meditech NPR / Non-Procedural Report / Meditech Consulting / Meditech Reports .NET 2.0

Saturday, November 03, 2007

MDI Interface to Child Form (VS 2005 C#)

To control the child form from the parent form; you need to implement an interface to the child form. The interface will have publicly available methods which are accessible via the interface.

1) For your application's namespace, implement a public interface.

:public interface IChildForm;
:{
: // All methods to be accessed via the MDI parent must be here.
: void OpenFile();
: void SaveFile();
:}

2) Your child form implements the IChildForm interface by adding it to the list of implemented interfaces. The public methods listed in the IChildForm interface must be implemented in the form class.

:public partial class frmViewer :Form,IChildForm
:{
: public frmViewer()
: {
: InitializeComponent();
: }
:
: // You can call this from the IChildForm interface reference.
: public void SaveFile()
: {
: SaveFileDialog saveFileDialog = new SaveFileDialog();
: saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
: saveFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
: if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
: {
: string FileName = saveFileDialog.FileName;
: // TODO:Add code here to save the current contents of the form to a file.
: }
:
: }
:
: // You can call this from the IChildForm interface reference.
: public void OpenFile()
: {
: // TODO:Add code here to open the file.
:
; }
:
:}

3) Access the active MDI child.

:private IChildForm GetActiveChild()
:{
: // Get the active MDI child.
: Form ChildForm = this.ActiveMdiChild;
: // Access the save method via the interface.
: IChildForm iForm = ChildForm as IChildForm;
: return iForm;
:}

4) Call the Active MDI Child's interface methods.

:private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e)
:{
: IChildForm iForm = GetActiveChild();
: iForm.SaveFile();
:}
:
:private void OpenFile(object sender, EventArgs e)
:{
: IChildForm iForm = GetActiveChild();
: iForm.OpenFile();
:}

Wednesday, October 17, 2007

Gridview / Data Table Sorting

DataView dv = new DataView(dtMeditechKeyCodes);
dv.Sort = "key";
grdView.DataSource = dv;
grdView.DataBind();

Saturday, August 25, 2007

Sql Server 2005 Developer Install Fails

Remove MS 2003 OWC using appwiz.cpl (control panel / add remove programs).

Friday, August 24, 2007

Form Based Authentication in ASP.NET 2.0

Present user with a form that populates database with their credentials. All their information is stored with these credentials. Store all account information on an internal user id; but only allow unique email addresses. A user can have an unlimited number of accounts.

ASP.NET 2.0 Global Layout

Master pages allow you to manage look and feel of your web application from a single file.

Themes use Cascading Style Sheets and Control Skins to affect the global look and feel of your web application.

SQL Injection Attacks in ASP.NET

SQL injection attacks are often accomplished with the ' single quote or -- double dash as a comment.

Use parameterized queries as placeholders for the values in your SQL statements.

Configuration Guidelines

- Don't hardcode any connectivity information in your code.
- Put database connection information in section of Web.Config.
- Put application strings in section of Web.Config.
- Application settings can be drive mappings, IP address, file path, etc.
- Limit the number of Web.Config settings to a small number like 10.
- You shouldn't be changing your Web.Config every day.
- If an application setting will be changed often store it in the database.

+ Use the System.Configuration.ConfigurationManager class.
+ Define your settings in Private Shared variables.
+ Expose your settings as properties from your section.
+ Settings that need to change with users logged in should be tracked in a database.

Reference: Pro Asp.NET 2.0 Website Programming by Damon Armstrong

Monday, May 28, 2007

VS 2005 F8

F11 is the VB6 F8

Tuesday, March 27, 2007

C# Get HashTable Value by Key

htSegmentFields.Add("MSH","23");

string strSegmentName = "MSH";
int intSegmentFieldsMax = 0;
intSegmentFieldsMax = Convert.ToInt16(htSegmentFields[strSegmentName].ToString());

intSegmentFieldsMax would equal 23 using the command above to access the value by the key "MSH".

Saturday, March 24, 2007

C# Char for CR/LF in ASCII Hex / Decimal

"\r" = chr(13) also CR ASCII Dec 13 / Hex 0D.
"\n" = chr(10) also LF ASCII Dec 10 / Hex 0A.

Meditech NPR Reports / NPR Report Writing / NPR Report Writer / Meditech NPR / Non-Procedural Report / Meditech Consulting / Meditech Reports