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

namespace LLNet.Tienda.MainForms.Controls
{
    public partial class ctlDatosFactura : UserControl
    {
        public ctlDatosFactura()
        {
            InitializeComponent();

            GUI.CApp.TraducirForm(this);
        }

        private void ctlDatosFactura_Enter(object sender, EventArgs e)
        {
            Vgc.FocusedRow = rowSerie;
            Vgc.Focus();
        }

        private void datFactura_EditValueChanging(object sender, DevExpress.XtraEditors.Controls.ChangingEventArgs e)
        {
        }

        private void Vgc_ValidatingEditor(object sender, DevExpress.XtraEditors.Controls.BaseContainerValidateEditorEventArgs e)
        {

            if (Vgc.FocusedRow.Name == "rowEmision")
            {
                if (e.Value != null && e.Value != DBNull.Value)
                {
                    double difm = Convert.ToDouble(Utils.Helpers.Nvl(GUI.CApp.GetParam("DIFM"), 0));
                    //Convert.ToDateTime(e.Value) <= DateTime.Today.AddDays(-difm) || 
                    if (Convert.ToDateTime(e.Value) > DateTime.Today)
                    {
                        e.ErrorText = "La fecha de emisión de la factura no es vàlida";
                        GUI.CApp.ShowMessage("La fecha de emisión de la factura no es vàlida", "Facturación Manual", true);
                        e.Valid = false;

                    }
                }
            }
        }

        private void Vgc_Click(object sender, EventArgs e)
        {

        }
    }
}