private void Remision_Load(object sender, EventArgs e)
 {
     cmbTipoIdentificacion.DataSource = _billData.GetIdentificationType();
     cmbTipoIdentificacion.ValueMember = "Id";
     cmbTipoIdentificacion.DisplayMember = "Description";
     _remission = new RemissionModel
     {
         Id = Guid.NewGuid(),
         RemissionNumber = _remissionData.GetRemissionNumber(),
         Total = 0,
         DateEvent = DateTime.Now
     };
     lblNumeroRemision.Text = _remission.RemissionNumber.ToString().PadLeft(8, '0');
     lblGranTotal.Text = "$0,00";
     txtSubTotal.Text = string.Format("{0:0.00}", 0.00);
     txtDescuentoFinal.Text = string.Format("{0:0.00}", 0.00);
     txtDescuentoCliente.Text = string.Format("{0:0.00}", 0.00);
 }
        public RemissionSaveModel GetRemissionData(RemissionModel remission)
        {
            try
            {
                using (FacturandoEntities context = new FacturandoEntities())
                {
                    RemissionSaveModel result = new RemissionSaveModel();
                    result.Remission = remission;
                    result.RemissionDetail = context.RemissionDetail
                        .Where(x => x.IdRemission == result.Remission.Id)
                        .Select(x => new RemissionDetailModel
                        {
                            Id = x.Id,
                            IdRemission = x.IdRemission.Value,
                            IdProduct = x.IdProduct.Value,
                            Product = string.Concat(x.Product.Description, " ", x.Product.UnitMeasure.Description),
                            Quantity = x.Quantity,
                            Total = x.Total,
                            UnitPrice = x.UnitPrice
                        }).ToList();

                    result.Client = context.Client
                        .Where(x => x.Id == result.Remission.IdClient)
                        .Select(x => new ClientModel
                        {
                            Id = x.Id,
                            Adress = x.Address,
                            DateEvent = x.DateEvent != null ? x.DateEvent.Value : DateTime.MinValue,
                            DiscountPercent = x.DisccountPercent,
                            Email = x.Email,
                            IdentificationNumber = x.IdentificationNumber,
                            IdIdentificationType = x.IdIdentificationType.Value,
                            Name = x.Name,
                            Phone = x.Phone
                        }).FirstOrDefault();

                    return result;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        private void ClearControls()
        {
            _billData = new BillData();
            _inventoryData = new InventoryData();
            _client = null;
            _remissionDetail = new List<RemissionDetailModel>();
            _remissionSaveModel = new RemissionSaveModel();

            _remission = new RemissionModel
            {
                Id = Guid.NewGuid(),
                RemissionNumber = _remissionData.GetRemissionNumber(),
                DateEvent = DateTime.Now
            };
            lblNumeroRemision.Text = _remission.RemissionNumber.ToString().PadLeft(8, '0');
            lblGranTotal.Text = "$0,00";
            txtSubTotal.Text = string.Format("{0:0.00}", 0.00);
            txtDescuentoFinal.Text = string.Format("{0:0.00}", 0.00);
            txtDescuentoCliente.Text = string.Format("{0:0.00}", 0.00);
            dtgDetalleRemision.DataSource = new List<RemissionDetailModel>();
            txtIdentificacionCliente.Text = string.Empty;
            txtNombreCliente.Text = string.Empty;
            txtDireccion.Text = string.Empty;
            txtTelefono.Text = string.Empty;
            txtEmail.Text = string.Empty;
            txtCodigoBarras.Text = string.Empty;
            txtNombreProducto.Text = string.Empty;
            lstProducto.DataSource = new List<InventoryModel>();           
            btnRemitir.Enabled = false;
        }