Click here to Skip to main content
15,885,906 members
Articles / Mobile Apps / Windows Mobile

Pocket Personal Health Record

Rate me:
Please Sign up or sign in to vote.
4.75/5 (4 votes)
17 Feb 2009Ms-PL2 min read 28.6K   1.1K   24  
Personal Pocket Health Record (PPHR) application helps to store and track a user's personal details and visits information on Windows powered pocket PC.
//**************************************************************************//
// Copyright (C) Abdul Rasheed. All rights Reserved.                        //
// rasheedat.blogspot.com                                                   //
//**************************************************************************//
using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using PPHR.Common;
using PPHR.DataLogic;
namespace PPHR
{
    /// <summary>
    /// Manages individual visit details
    /// </summary>
    public partial class VisitDetail : Form
    {
        #region Global Variables
        int appAction = Constants.ACTION_VIEW;
        int visitID = -1;
        int prescriptionAction = -1;
        int drVoiceAction = -1;
        int additionalDetailAction = -1;
        CommonDataLogic commonLogic = new CommonDataLogic();
        #endregion Global Variables

        #region Constructor
        /// <summary>
        /// Set the action fo rthis form (New, Edit or delete) and the visit id
        /// </summary>
        /// <param name="action"></param>
        /// <param name="visit"></param>
        public VisitDetail(int action, int visit)
        {
            InitializeComponent();
            appAction = action;
            visitID = visit;
        }
        #endregion Constructor

        #region Other Methods
        /// <summary>
        /// Load default values in form controls
        /// </summary>
        private void LoadDefaultValues()
        {
            //Load Combo Box
            DataTable dtVisitType = commonLogic.GetMasterTable("VISITTYP");

            cboVisitType.DataSource = dtVisitType;
            cboVisitType.ValueMember = dtVisitType.Columns[0].ColumnName;
            cboVisitType.DisplayMember = dtVisitType.Columns[1].ColumnName;
            cboVisitType.SelectedIndex = 0;
        }

        /// <summary>
        /// Set the values in form control on specific action
        /// </summary>
        private void SetValue()
        {
            VisitDataLogic PVLogic = new VisitDataLogic();
            VisitData PV = new VisitData();

            if (appAction == Constants.ACTION_NEW)
            {
                PV.VisitNumber = -1;
                this.Text = this.Text + " - New"; 
            }
            else
            {
                PV.VisitNumber = visitID;
            }
            if (appAction == Constants.ACTION_EDIT)
            {
                this.Text = this.Text + " - Update";
            }
            if (appAction == Constants.ACTION_NEW)
            {
                this.Text = this.Text + " - Delete";
            }
            
            DataTable dtVisitHeader = PVLogic.GetVisitHeader(PV);
            DataTable dtVisitPrescription = PVLogic.GetVisitPrescription(PV);
            DataTable dtDrVoice = PVLogic.GetVisitDrVoice(PV);
            DataTable dtAddInfo = PVLogic.GetVisitAdditionalInfo(PV);
            // Set Header
            if (dtVisitHeader != null && dtVisitHeader.Rows.Count > 0)
            {
                txtVisitNumber.Text = dtVisitHeader.Rows[0][1].ToString();
                dtpVisitDate.Value = DateTime.Parse(dtVisitHeader.Rows[0][2].ToString());
                cboVisitType.Text = commonLogic.GetDescriptionForCode("VISITTYP",dtVisitHeader.Rows[0][3].ToString());
                txtDrName.Text = dtVisitHeader.Rows[0][4].ToString();
                txtHospitalName.Text = dtVisitHeader.Rows[0][5].ToString();
                txtVisitDetail.Text = dtVisitHeader.Rows[0][6].ToString();
            }
            dgPrescription.DataSource = dtVisitPrescription;
            dgDrVoice.DataSource = dtDrVoice;
            dgAdditionalInfo.DataSource = dtAddInfo;
        }

        /// <summary>
        /// Validate form controls before submitting in database.
        /// </summary>
        /// <returns>On success return true</returns>
        private bool ValidateForm()
        {
            if (cboVisitType.SelectedIndex.Equals(0))
            {
                MessageBox.Show("Please Choose a visit type from the list.", Constants.MessageBoxCaption);
                cboVisitType.Focus();
                return false;
            }
            if (txtDrName.Text.Trim().Equals(string.Empty))
            {
                MessageBox.Show("Please Enter Doctor Name.", Constants.MessageBoxCaption);
                txtDrName.Focus();
                return false;
            }
            if (txtHospitalName.Text.Trim().Equals(string.Empty))
            {
                MessageBox.Show("Please Enter Hospital/Clinic Name.", Constants.MessageBoxCaption);
                txtHospitalName.Focus();
                return false;
            }
            if (txtVisitDetail.Text.Trim().Equals(string.Empty))
            {
                MessageBox.Show("Please Enter visit detail.", Constants.MessageBoxCaption);
                txtVisitDetail.Focus();
                return false;
            }
            return true;
        }

        /// <summary>
        /// Add new visit details in Data base
        /// </summary>
        private void AddVistDetail()
        {
            VisitData PV = new VisitData();
            VisitDataLogic PVLogic = new VisitDataLogic();
            if (ValidateForm())
            {
                PV.VisitDate = dtpVisitDate.Value;
                PV.VisitType = ((System.Data.DataRowView)(cboVisitType.SelectedItem)).Row.ItemArray[0].ToString();
                PV.ConsultantName = txtDrName.Text;
                PV.FacilityName = txtHospitalName.Text;
                PV.VisitDetail = txtVisitDetail.Text;
                //Prescription
                DataTable dtPrescription = (DataTable)dgPrescription.DataSource;
                for (int row = 0; row < dtPrescription.Rows.Count; row++)
                {
                    Prescription pres = new Prescription();
                    pres.Note = dtPrescription.Rows[row][1].ToString();
                    pres.PrescriptionDocument = dtPrescription.Rows[row][2].ToString();
                    PV.Prescription.Add(pres);
                }
                //Dr. Voice
                DataTable dtVoice = (DataTable)dgDrVoice.DataSource;
                for (int row = 0; row < dtVoice.Rows.Count; row++)
                {
                    DoctorVoice drVoice = new DoctorVoice();
                    drVoice.Note = dtPrescription.Rows[row][1].ToString();
                    drVoice.DoctorVoiceComment = dtPrescription.Rows[row][2].ToString();
                    PV.DrVoice.Add(drVoice);
                }
                //Additional Info.
                DataTable dtAddInfo = (DataTable)dgAdditionalInfo.DataSource;
                for (int row = 0; row < dtAddInfo.Rows.Count; row++)
                {
                    AdditionalInfo addInfo = new AdditionalInfo();
                    addInfo.Note = dtAddInfo.Rows[row][1].ToString();
                    addInfo.AdditionalInformationDocument = dtAddInfo.Rows[row][2].ToString();
                    PV.AdditionalInfo.Add(addInfo);
                }
                PVLogic.AddVisit(PV);
                MessageBox.Show("Visit Details Added Successfully.", Constants.MessageBoxCaption);
                this.Close();
            }
        }

        /// <summary>
        /// Update modified visit details in database
        /// </summary>
        private void UpdateVistDetail()
        {
            VisitData PV = new VisitData();
            VisitDataLogic PVLogic = new VisitDataLogic();
            if (ValidateForm())
            {
                PV.VisitNumber = int.Parse(txtVisitNumber.Text);
                PV.VisitDate = dtpVisitDate.Value;

                PV.VisitType = ((System.Data.DataRowView)(cboVisitType.SelectedItem)).Row.ItemArray[0].ToString();
                PV.ConsultantName = txtDrName.Text;
                PV.FacilityName = txtHospitalName.Text;
                PV.VisitDetail = txtVisitDetail.Text;

                //Prescription
                DataTable dtPrescription = (DataTable)dgPrescription.DataSource;
                for (int row = 0; row < dtPrescription.Rows.Count; row++)
                {
                    Prescription pres = new Prescription();
                    pres.Note = dtPrescription.Rows[row][1].ToString();
                    pres.PrescriptionDocument = dtPrescription.Rows[row][2].ToString();
                    PV.Prescription.Add(pres);
                }

                //Dr. Voice
                DataTable dtVoice = (DataTable)dgDrVoice.DataSource;
                for (int row = 0; row < dtVoice.Rows.Count; row++)
                {
                    DoctorVoice drVoice = new DoctorVoice();
                    drVoice.Note = dtPrescription.Rows[row][1].ToString();
                    drVoice.DoctorVoiceComment = dtPrescription.Rows[row][2].ToString();
                    PV.DrVoice.Add(drVoice);
                }

                //Additional Info.
                DataTable dtAddInfo = (DataTable)dgAdditionalInfo.DataSource;
                for (int row = 0; row < dtAddInfo.Rows.Count; row++)
                {
                    AdditionalInfo addInfo = new AdditionalInfo();
                    addInfo.Note = dtAddInfo.Rows[row][1].ToString();
                    addInfo.AdditionalInformationDocument = dtAddInfo.Rows[row][2].ToString();
                    PV.AdditionalInfo.Add(addInfo);
                }
                PVLogic.UpdateVisitDetail(PV);
                MessageBox.Show("Details Updated Successfully.", Constants.MessageBoxCaption);
                this.Close();
            }
        }

        /// <summary>
        /// Delete selected visit details
        /// </summary>
        private void DeleteVisitDetail()
        {
            VisitData PV = new VisitData();
            VisitDataLogic PVLogic = new VisitDataLogic();
            PV.VisitNumber = int.Parse(txtVisitNumber.Text);
            PVLogic.DeleteVisit(PV);
            MessageBox.Show("Visit Details Deleted Successfully.", Constants.MessageBoxCaption);
            this.Close();
        }

        #region Prescription Tab
        /// <summary>
        /// Enable or Disable prescription tab controls
        /// </summary>
        /// <param name="value">Enable or Disable</param>
        private void EnablePrescriptionTab(bool value)
        {
            txtPrescriptionNote.Enabled = value;
            btnBrowsePrescription.Enabled = value;
            btnPrescriptionOK.Enabled = value;
        }

        /// <summary>
        /// Clear values in prescription tab controls
        /// </summary>
        private void ClearPrescriptionTab()
        {
            txtPrescriptionImage.Text = string.Empty;
            txtPrescriptionNote.Text = string.Empty;
        }

        /// <summary>
        /// Set the values in controls
        /// </summary>
        /// <param name="dr"></param>
        private void LoadPrescriptionTabValue(DataRow dr)
        {
            txtPrescriptionNote.Text = dr[1].ToString();
            txtPrescriptionImage.Text = dr[2].ToString();
        }

        /// <summary>
        /// Validate prescription tab control values before adding to Data Grid 
        /// </summary>
        /// <returns>true or false</returns>
        private bool ValidatePrescriptionTab()
        {
            if (txtPrescriptionImage.Text.Trim().Equals(string.Empty))
            {
                MessageBox.Show("Please Select Valid file path.", Constants.MessageBoxCaption);
                txtPrescriptionImage.Focus();
                return false;
            }
            return true;
        }
        #endregion Prescription Tab

        #region Dr. Voice Tab
        private void EnableDrVoiceTab(bool value)
        {
            txtDrVoiceNote.Enabled = value;
            btnBrowseDictation.Enabled = value;
            btnDictationVoice.Enabled = value;
        }

        private void ClearDrVoiceTab()
        {
            txtDictation.Text = string.Empty;
            txtDrVoiceNote.Text = string.Empty;
        }

        private void LoadDrVoiceTabValue(DataRow dr)
        {
            txtDictation.Text = dr[2].ToString();
            txtDrVoiceNote.Text = dr[1].ToString();
        }

        /// <summary>
        /// Validate Drs dictation tab control values before adding to Data Grid 
        /// </summary>
        /// <returns>true or false</returns>
        private bool ValidateDrVoiceTab()
        {
            if (txtDictation.Text.Trim().Equals(string.Empty))
            {
                MessageBox.Show("Please Select Valid file path.", Constants.MessageBoxCaption);
                txtDictation.Focus();
                return false;
            }
            return true;
        }
        #endregion Dr. Voice Tab

        #region Addtitional Tab
        private void EnableAdditionalTab(bool value)
        {
            txtAdditionalImageNote.Enabled = value;
            btnAdditionalBrowse.Enabled = value;
            btnAdditionalImageOK.Enabled = value;
        }

        private void ClearAdditionalTab()
        {
            txtAdditionalImage.Text = string.Empty;
            txtAdditionalImageNote.Text = string.Empty;
        }

        private void LoadAdditionalTabValue(DataRow dr)
        {
            txtAdditionalImage.Text = dr[2].ToString();
            txtAdditionalImageNote.Text = dr[1].ToString();
        }

        /// <summary>
        /// Validate Additional image tab control values before adding to Data Grid 
        /// </summary>
        /// <returns>true or false</returns>
        private bool ValidateAdditionalInfoTab()
        {
            if (txtAdditionalImage.Text.Trim().Equals(string.Empty))
            {
                MessageBox.Show("Please Select Valid file path.", Constants.MessageBoxCaption);
                txtAdditionalImage.Focus();
                return false;
            }
            return true;
        }
        #endregion Addtitional Tab

        #endregion Other Methods

        #region Events
        /// <summary>
        /// On form load load default values and set the values based on the Action
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void VisitDetail_Load(object sender, EventArgs e)
        {
            try
            {
                LoadDefaultValues();
                SetValue();
                EnablePrescriptionTab(false);
                EnableDrVoiceTab(false);
                EnableAdditionalTab(false);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption);
            }
        }

        /// <summary>
        /// On click Create or update or delete data from the database
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuItemOK_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                if (appAction == Constants.ACTION_NEW)
                {
                    AddVistDetail();
                }
                else if (appAction == Constants.ACTION_EDIT)
                {
                    UpdateVistDetail();
                }
                else if (appAction == Constants.ACTION_DELETE)
                {
                    if (MessageBox.Show("Are your sure, You want to delete this detail?", Constants.MessageBoxCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.No)
                    {
                        DeleteVisitDetail();
                    }
                }
                else
                {
                    Cursor.Current = Cursors.Default;
                    this.Close();
                }
                Cursor.Current = Cursors.Default;
            }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption);
            }
        }

        /// <summary>
        /// Close the form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuItemCancel_Click(object sender, EventArgs e)
        {
            try
            {
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption);
            }
        }

        /// <summary>
        /// Hide the Visit detail form and show the Visit list form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuItemVisitList_Click(object sender, EventArgs e)
        {
            try
            {
                this.Hide();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption);
            }
        }

        /// <summary>
        /// If there is no records in grid then disable edit and delete menu
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void contextMenuPrescription_Popup(object sender, EventArgs e)
        {
            try
            {
                DataTable dt = (DataTable)dgPrescription.DataSource;
                if (dt.Rows.Count <= 0)
                {
                    contextMenuPrescription.MenuItems[1].Enabled = false;
                    contextMenuPrescription.MenuItems[2].Enabled = false;
                }
                else
                {
                    contextMenuPrescription.MenuItems[1].Enabled = true;
                    contextMenuPrescription.MenuItems[2].Enabled = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
            }
        }

        /// <summary>
        /// If there is no records in grid then disable edit and delete menu
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void contextMenuDrVoice_Popup(object sender, EventArgs e)
        {
            try
            {
                DataTable dt = (DataTable)dgDrVoice.DataSource;
                if (dt.Rows.Count <= 0)
                {
                    contextMenuDrVoice.MenuItems[1].Enabled = false;
                    contextMenuDrVoice.MenuItems[2].Enabled = false;
                }
                else
                {
                    contextMenuDrVoice.MenuItems[1].Enabled = true;
                    contextMenuDrVoice.MenuItems[2].Enabled = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
            }
        }

        /// <summary>
        /// If there is no records in grid then disable edit and delete menu
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void contextMenuAddInfo_Popup(object sender, EventArgs e)
        {
            try
            {
                DataTable dt = (DataTable)dgAdditionalInfo.DataSource;
                if (dt.Rows.Count <= 0)
                {
                    contextMenuAddInfo.MenuItems[1].Enabled = false;
                    contextMenuAddInfo.MenuItems[2].Enabled = false;
                }
                else
                {
                    contextMenuAddInfo.MenuItems[1].Enabled = true;
                    contextMenuAddInfo.MenuItems[2].Enabled = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
            }
        }

        #region Prescription tab

        private void menuItemPresNew_Click(object sender, EventArgs e)
        {
            try
            {
                prescriptionAction = Constants.ACTION_NEW;
                EnablePrescriptionTab(true);
                ClearPrescriptionTab();
                btnPrescriptionOK.Text = "Add";
                btnBrowsePrescription.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption);
            }
        }

        private void menuItemPresEdit_Click(object sender, EventArgs e)
        {
            try
            {
                prescriptionAction = Constants.ACTION_EDIT;
                int index = dgPrescription.CurrentRowIndex;
                DataTable dtPrescription = (DataTable)dgPrescription.DataSource;
                DataRow dr = dtPrescription.Rows[index];

                LoadPrescriptionTabValue(dr);
                EnablePrescriptionTab(true);
                btnBrowsePrescription.Focus();
                btnPrescriptionOK.Text = "Update";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption);
            }
        }

        private void menuItemPresDelete_Click(object sender, EventArgs e)
        {
            try
            {
                prescriptionAction = Constants.ACTION_DELETE;
                int index = dgPrescription.CurrentRowIndex;
                DataTable dtPrescription = (DataTable)dgPrescription.DataSource;
                DataRow dr = dtPrescription.Rows[index];
                LoadPrescriptionTabValue(dr);
                EnablePrescriptionTab(false);
                btnPrescriptionOK.Text = "Delete";
                btnPrescriptionOK.Enabled = true;
                btnPrescriptionOK.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption);
            }
        }

        private void btnPrescriptionOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidatePrescriptionTab())
                {
                    DataTable dtPrescription = (DataTable)dgPrescription.DataSource;
                    if (prescriptionAction == Constants.ACTION_NEW)
                    {
                        DataRow dr = dtPrescription.NewRow();
                        dr[2] = txtPrescriptionImage.Text;
                        dr[1] = txtPrescriptionNote.Text;
                        dtPrescription.Rows.Add(dr);
                    }
                    if (prescriptionAction == Constants.ACTION_EDIT)
                    {
                        int index = dgPrescription.CurrentRowIndex;
                        DataRow dr = dtPrescription.Rows[index];
                        dr[2] = txtPrescriptionImage.Text;
                        dr[1] = txtPrescriptionNote.Text;
                    }
                    if (prescriptionAction == Constants.ACTION_DELETE)
                    {
                        int index = dgPrescription.CurrentRowIndex;
                        dtPrescription.Rows.RemoveAt(index);
                    }
                    dgPrescription.DataSource = dtPrescription;
                    ClearPrescriptionTab();
                    EnablePrescriptionTab(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption);
            }
        }

        private void btnBrowsePrescription_Click(object sender, EventArgs e)
        {
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                txtPrescriptionImage.Text = openFileDialog.FileName;
            }
        }
        #endregion Prescription tab

        #region Dr. voice tab
        private void menuItemDrNew_Click(object sender, EventArgs e)
        {
            try
            {
                drVoiceAction = Constants.ACTION_NEW;
                EnableDrVoiceTab(true);
                ClearDrVoiceTab();
                btnDictationVoice.Text = "Add";
                btnBrowseDictation.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption);
            }
        }

        private void menuItemDrEdit_Click(object sender, EventArgs e)
        {
            try
            {
                drVoiceAction = Constants.ACTION_EDIT;
                int index = dgDrVoice.CurrentRowIndex;
                DataTable dtDrVoice = (DataTable)dgDrVoice.DataSource;
                DataRow dr = dtDrVoice.Rows[index];

                LoadDrVoiceTabValue(dr);
                EnableDrVoiceTab(true);
                btnDictationVoice.Text = "Update";
                btnBrowseDictation.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption);
            }
        }

        private void menuItemDrDelete_Click(object sender, EventArgs e)
        {
            try
            {
                drVoiceAction = Constants.ACTION_DELETE;
                int index = dgDrVoice.CurrentRowIndex;
                DataTable dtDrVoice = (DataTable)dgDrVoice.DataSource;
                DataRow dr = dtDrVoice.Rows[index];
                LoadDrVoiceTabValue(dr);
                EnableDrVoiceTab(false);
                btnDictationVoice.Text = "Delete";
                btnDictationVoice.Enabled = true;
                btnDictationVoice.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption);
            }
        }

        private void btnDictationVoice_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidateDrVoiceTab())
                {
                    DataTable dtDrVoice = (DataTable)dgDrVoice.DataSource;
                    if (drVoiceAction == Constants.ACTION_NEW)
                    {
                        DataRow dr = dtDrVoice.NewRow();
                        dr["DoctorVoiceComment"] = txtDictation.Text;
                        dr["Note"] = txtDrVoiceNote.Text;
                        dtDrVoice.Rows.Add(dr);
                    }
                    if (drVoiceAction == Constants.ACTION_EDIT)
                    {
                        int index = dgDrVoice.CurrentRowIndex;
                        DataRow dr = dtDrVoice.Rows[index];
                        dr["DoctorVoiceComment"] = txtDictation.Text;
                        dr["Note"] = txtDrVoiceNote.Text;
                    }
                    if (drVoiceAction == Constants.ACTION_DELETE)
                    {
                        int index = dgDrVoice.CurrentRowIndex;
                        dtDrVoice.Rows.RemoveAt(index);
                    }
                    dgDrVoice.DataSource = dtDrVoice;
                    ClearDrVoiceTab();
                    EnableDrVoiceTab(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption);
            }
        }

        private void btnBrowseDictation_Click(object sender, EventArgs e)
        {
            try
            {
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    txtDictation.Text = openFileDialog.FileName;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption);
            }
        }
        #endregion Dr. voice tab

        #region Additional Information Tab

        private void menuItemAddInfoNew_Click(object sender, EventArgs e)
        {
            try
            {
                additionalDetailAction = Constants.ACTION_NEW;
                EnableAdditionalTab(true);
                ClearAdditionalTab();
                btnAdditionalImageOK.Text = "Add";
                btnAdditionalBrowse.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption);
            }
        }

        private void menuItemAddInfoEdit_Click(object sender, EventArgs e)
        {
            try
            {
                additionalDetailAction = Constants.ACTION_EDIT;
                int index = dgAdditionalInfo.CurrentRowIndex;
                DataTable dtAddInfo = (DataTable)dgAdditionalInfo.DataSource;
                DataRow dr = dtAddInfo.Rows[index];

                LoadAdditionalTabValue(dr);
                EnableAdditionalTab(true);
                btnAdditionalImageOK.Text = "Update";
                btnAdditionalBrowse.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption);
            }
        }

        private void menuItemAddInfoDelete_Click(object sender, EventArgs e)
        {
            try
            {
                additionalDetailAction = Constants.ACTION_DELETE;
                int index = dgAdditionalInfo.CurrentRowIndex;
                DataTable dtAddInfo = (DataTable)dgAdditionalInfo.DataSource;
                DataRow dr = dtAddInfo.Rows[index];
                LoadAdditionalTabValue(dr);
                EnableAdditionalTab(false);
                btnAdditionalImageOK.Text = "Delete";
                btnAdditionalImageOK.Enabled = true;
                btnAdditionalImageOK.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption);
            }
        }

        private void btnAdditionalImageOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidateAdditionalInfoTab())
                {
                    DataTable dtAddInfo = (DataTable)dgAdditionalInfo.DataSource;
                    if (additionalDetailAction == Constants.ACTION_NEW)
                    {
                        DataRow dr = dtAddInfo.NewRow();
                        dr["AdditionalInformationDocument"] = txtAdditionalImage.Text;
                        dr["Note"] = txtAdditionalImageNote.Text;
                        dtAddInfo.Rows.Add(dr);
                    }
                    if (additionalDetailAction == Constants.ACTION_EDIT)
                    {
                        int index = dgAdditionalInfo.CurrentRowIndex;
                        DataRow dr = dtAddInfo.Rows[index];
                        dr["AdditionalInformationDocument"] = txtAdditionalImage.Text;
                        dr["Note"] = txtAdditionalImageNote.Text;
                    }
                    if (additionalDetailAction == Constants.ACTION_DELETE)
                    {
                        int index = dgAdditionalInfo.CurrentRowIndex;
                        dtAddInfo.Rows.RemoveAt(index);
                    }
                    dgAdditionalInfo.DataSource = dtAddInfo;
                    ClearAdditionalTab();
                    EnableAdditionalTab(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption);
            }
        }

        private void btnAdditionalBrowse_Click(object sender, EventArgs e)
        {
            try
            {
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    txtAdditionalImage.Text = openFileDialog.FileName;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Constants.MessageBoxCaption);
            }
        }
        #endregion Additional Information Tab

        
        #endregion Events
        
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
India India
Called as Rasheed. Completed Master of Computer science. Working as Senior Consultant in Chennai, India.

Try to achive in different stream

Comments and Discussions