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

namespace LLNet.Tienda.MainForms.Forms
{
    public partial class frmHistoricoFactSocio : LLNet.GUI.FormBases.frmBase
    {
        private string socio;
        private string EsquemaC;
        
        public frmHistoricoFactSocio()
        {
            InitializeComponent();

            GUI.CApp.TraducirForm(this);
        }

        public override void Init(object[] pArgs)
        {
            base.Init(pArgs);
            socio = Utils.Helpers.ObjToStr(pArgs[0]);
            EsquemaC = Utils.Helpers.ObjToStr(GUI.CApp.GetParam("NDEC"));
        }

        private void btnContinuar_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
        }

        private void frmHistoricoFactSocio_Load(object sender, EventArgs e)
        {
            Utils.QueryParams qp = new LLNet.Utils.QueryParams();
            qp.AddReplaceParam("SOCIO", socio);
            dsPDV1.Clear();

            if (EsquemaC != string.Empty)
            {
                try
                {
                    Utils.Helpers.Merge(GUI.CApp.bll.getConnTypedDataSet(dsPDV1.GetType(), dsPDV1.TDA_V_HISTORIAL_FACTURAS_SOCIO.TableName, EsquemaC, qp), dsPDV1);
                }
                catch 
                {
                    Utils.Helpers.Merge(GUI.CApp.bll.getTypedDataSet(dsPDV1.GetType(), dsPDV1.TDA_V_HISTORIAL_FACTURAS_SOCIO.TableName, qp), dsPDV1);
                }
            }
            else
                Utils.Helpers.Merge(GUI.CApp.bll.getTypedDataSet(dsPDV1.GetType(), dsPDV1.TDA_V_HISTORIAL_FACTURAS_SOCIO.TableName, qp), dsPDV1);

            gridView1.BestFitColumns();
        }

        private void frmHistoricoFactSocio_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            { 
                case Keys.Escape:
                case Keys.F12:
                    btnContinuar_Click(null, null);
                    break;
            }
        }
    }
}

