Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Iddocumento,Tipodocumento")] Tdocumento tdocumento)
        {
            if (id != tdocumento.Iddocumento)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tdocumento);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TdocumentoExists(tdocumento.Iddocumento))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tdocumento));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Iddocumento,Tipodocumento")] Tdocumento tdocumento)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tdocumento);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tdocumento));
        }
Exemplo n.º 3
0
        private void btn_guardar_Click(object sender, EventArgs e)
        {
            //validar que el formulario contenga toda la información para guardar
            if (Tdocumento.Text == "")
            {
                P.Mensaje.Advert("Debe indicar el número del documento");
                Tdocumento.Focus();
                return;
            }
            //volvemos a chequear que el documento no exista en la base de datos
            int existe_doc = P.Consultas.ventas.CheckDocName(Tdocumento.Text);

            if (existe_doc > 0)
            {
                P.Mensaje.Advert("Número de documento ya ha sido utilizado");
                Tdocumento.Focus();
                return;
            }
            if (CurrentDetailSource.Count() == 0)
            {
                P.Mensaje.Advert("No ha ingresado información en el detalle de la factura");
                detalle_venta.Focus();
                return;
            }
            foreach (var cDet in CurrentDetailSource)
            {
                if (cDet.PrecioTotal == 0)
                {
                    int index = CurrentDetailSource.IndexOf(cDet);
                    P.Mensaje.Advert("Debe ingresar el precio para la fila " + (index + 1) + " del detalle");
                    detalle_venta.Focus();
                    return;
                }
            }
            //paso la validación, procedemos a guardar
            var res = P.Consultas.ventas.CREATE_SALES_DOC(Tdocumento.Text, _TotalAmount, DTfecha.Value, CurrentDetailSource);

            if (res.CheckError)
            {
                res.mensaje();
            }
            else
            {
                P.Mensaje.Info("Documento de venta ingresado correctamente al sistema");
                this.Close();
            }
        }