Пример #1
0
        private bool GuardarCompraSerial(int accion)
        {
            C_Compra objetoCompra = new C_Compra();

            objetoCompra.NumeroDocumento = Txt_I_NroDocumento.Text;
            objetoCompra.CodigoProveedor = Int32.Parse(Cmb_I_Proveedor.SelectedValue.ToString());
            C_SerialProducto objetoSerialProducto = new C_SerialProducto();

            objetoSerialProducto.CodigoCompra = _shalong.CompraCodigo(objetoCompra);
            if (accion == 2)
            {
                objetoSerialProducto.CodigoSerie  = 0;
                objetoSerialProducto.CodigoBarras = 0;
                if (_shalong.CompraSerial(2, objetoSerialProducto))
                {
                    foreach (DataGridViewRow row in dtg_CG_Compras.Rows)
                    {
                        if (row.Cells["Cg_Codigo"].Value != null && row.Cells["Cg_Serial"].Value != null)
                        {
                            objetoSerialProducto.Serial       = row.Cells["Cg_Serial"].Value.ToString();
                            objetoSerialProducto.CodigoBarras = Int32.Parse(row.Cells["Cg_Codigo"].Value.ToString());

                            if (_shalong.CompraSerial(1, objetoSerialProducto))
                            {
                            }
                            else
                            {
                                MessageBox.Show("Error al Guardar el Serial");
                            }
                        }
                    }
                }
            }
            else if (accion == 1)
            {
                foreach (DataGridViewRow row in dtg_CG_Compras.Rows)
                {
                    if (row.Cells["Cg_Codigo"].Value != null && row.Cells["Cg_Serial"].Value != null)
                    {
                        objetoSerialProducto.Serial       = row.Cells["Cg_Serial"].Value.ToString();
                        objetoSerialProducto.CodigoBarras = Int32.Parse(row.Cells["Cg_Codigo"].Value.ToString());
                        if (!_shalong.CompraSerial(1, objetoSerialProducto))
                        {
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }
Пример #2
0
        public void Guardar()
        {
            C_CodigoSerial   objetoCodigoSerial   = new C_CodigoSerial();
            C_SerialProducto objetoSerialProducto = new C_SerialProducto();

            objetoCodigoSerial.Garantia    = _garantia;
            objetoCodigoSerial.CodigoVenta = _codigoVenta;
            bool flag = true;

            foreach (DataGridViewRow row in dtg_Serial.Rows)
            {
                if (row.Cells["Serial"].Value != null)
                {
                    objetoCodigoSerial.CodigoSerial = row.Cells["Serial"].Value.ToString();
                    objetoSerialProducto.Serial     = row.Cells["Serial"].Value.ToString();

                    if (_shalong.CodigoSerieExiste(objetoSerialProducto) == true)
                    {
                        flag = false;
                        if (_shalong.SerialExiste(objetoCodigoSerial) == false)
                        {
                            flag = false;
                            if (!_shalong.CodigoSerial(1, objetoCodigoSerial))
                            {
                                MessageBox.Show("Error al ingresar el serial numero " + (row.Index + 1));
                                _shalong.CodigoSerial(3, objetoCodigoSerial);
                                return;
                            }
                        }
                        else
                        {
                            MessageBox.Show("Codigo existente");
                        }
                    }
                    else
                    {
                        MessageBox.Show("No existe ese codigo");
                    }
                }
                if (flag)
                {
                    MessageBox.Show("Ingreso Correctamente codigo serial", "Gestion Ventas", MessageBoxButtons.OK);
                }
                this.Hide();
            }
        }