Ejemplo n.º 1
0
        private void frmTienda_Load(object sender, EventArgs e)
        {
            _dbCosolemEntities = new dbCosolemEntities();

            _tbTienda = new tbTienda {
                estadoRegistro = true
            };
            _dbCosolemEntities.ObjectStateManager.ChangeObjectState(_tbTienda, EntityState.Detached);

            List <Empresa> _tbEmpresa = (from E in _dbCosolemEntities.tbEmpresa select new Empresa {
                idEmpresa = E.idEmpresa, razonSocial = E.ruc + " - " + E.razonSocial
            }).ToList();

            _tbEmpresa.Insert(0, new Empresa {
                idEmpresa = 0, razonSocial = "Seleccione"
            });
            cmbEmpresa.DataSource    = _tbEmpresa;
            cmbEmpresa.ValueMember   = "idEmpresa";
            cmbEmpresa.DisplayMember = "razonSocial";

            var _tbProvincia = (from P in _dbCosolemEntities.tbProvincia select new { idProvincia = P.idProvincia, descripcion = P.descripcion, tbCanton = (from C in P.tbCanton select new { idCanton = C.idCanton, descripcion = C.descripcion }) }).ToList();

            cmbProvincia.DataSource    = _tbProvincia;
            cmbProvincia.ValueMember   = "idProvincia";
            cmbProvincia.DisplayMember = "descripcion";
            if (_tbTienda.tbCanton != null)
            {
                cmbProvincia.SelectedValue = _tbTienda.tbCanton.idProvincia;
            }

            var _tbCanton = ((dynamic)cmbProvincia.SelectedItem).tbCanton;

            cmbCanton.DataSource    = _tbCanton;
            cmbCanton.ValueMember   = "idCanton";
            cmbCanton.DisplayMember = "descripcion";
            if (_tbTienda.idCanton > 0)
            {
                cmbProvincia.SelectedValue = _tbTienda.idCanton;
            }

            txtCodigo.Clear();
            txtDescripcion.Clear();
            txtDireccion.Clear();
            txtTelefono.Clear();
            txtCorreoElectronico.Clear();
            txtPorcentajeIVA.Text = Convert.ToDecimal(0).ToString("n2");

            txtDescripcion.Select();
        }
Ejemplo n.º 2
0
 private void SetearTienda(tbTienda _tbTienda)
 {
     try
     {
         this._tbTienda             = _tbTienda;
         cmbEmpresa.SelectedValue   = this._tbTienda.idEmpresa;
         txtCodigo.Text             = this._tbTienda.idTienda.ToString();
         txtDescripcion.Text        = this._tbTienda.descripcion;
         cmbProvincia.SelectedValue = this._tbTienda.tbCanton.idProvincia;
         cmbProvincia_SelectionChangeCommitted(null, null);
         cmbCanton.SelectedValue   = this._tbTienda.idCanton;
         txtDireccion.Text         = this._tbTienda.direccion;
         txtTelefono.Text          = this._tbTienda.telefono;
         txtCorreoElectronico.Text = this._tbTienda.correoElectronico;
         txtPorcentajeIVA.Text     = this._tbTienda.porcentajeIVA.ToString("n2");
     }
     catch (Exception ex)
     {
         Util.MostrarException(this.Text, ex);
     }
 }