using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace LLNet.GUI.FormBases
{
    public partial class frmBase : Form
    {
        public frmBase()
        {
            InitializeComponent();
        }

        #region User Declarations

        private string columnCaption;
        private string moduleName;

        public DataRowView currentRow;

        #endregion

        #region Properties

        protected string ColumnCaption
        {
            get { return columnCaption; }
            set { columnCaption = value; }
        }

        public string ModuleName
        {
            get { return moduleName; }
            set { moduleName = value; }
        }

        #endregion

        #region Virtual Methods

        public virtual void Init(object[] pArgs)
        {
            moduleName = this.Name.Substring(3, this.Name.Length - 3);
            SetCaption();
        }

        protected virtual void SetCaption()
        {
        }

        virtual public void ShowHelp()
        {
            try
            {
                frmBase_HelpRequested(null, null);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }

        public virtual DataRow firstRow(DataSet ds)
        {
            return ds.Tables[0].Rows[0];
        }

        #endregion

        private void frmBase_HelpRequested(object sender, HelpEventArgs hlpevent)
        {
            string hpFileName = "ayuda\\ayuda.chm";
            string hpKeyWord = "Bienvenidos.htm";
            try
            {
                //using (Model.DsPDVTableAdapters.CG_MODULESTableAdapter mta = new LLNet.Model.DsPDVTableAdapters.CG_MODULESTableAdapter())
                //{
                //    Model.DsPDV.CG_MODULESDataTable dt = mta.GetData(GUI.CApp.ModulePrefix + moduleName);

                //    hpFileName = dt[0].HELP_FILENAME;
                //    hpKeyWord = dt[0].HELP_KEYWORD;
                //}

                Help.ShowHelp(this, CApp.ExeDir + hpFileName, hpKeyWord);
            }
            catch (Exception ex)
            {
                CApp.EventLog.WriteLog(ex);
            }
 
            Help.ShowHelp(this, CApp.ExeDir + hpFileName, hpKeyWord);
            hlpevent.Handled = true;

        }
   }
}