Example #1
0
        private void AgregaBienUso()
        {
            var dBienUso = new DBienUso();

            StockComboBox.DataSource    = null;
            StockComboBox.DataSource    = dBienUso.SelectBienesUsoSinProveedoresAsociados((int)DgvProveedores.SelectedRows[0].Cells[0].Value);
            StockComboBox.DisplayMember = "Nombre";
            StockComboBox.ValueMember   = "CodBienUso";
        }
Example #2
0
 private void CargarGrid()
 {
     dBienUso = new DBienUso();
     DgvBienesUso.DataSource = dBienUso.SelectBienesUso();
     DgvBienesUso.Refresh();
 }
        private void CotizarProductoButton_Click(object sender, EventArgs e)
        {
            int codProducto = (int)DgvProductosPorCotizar.SelectedRows[0].Cells[0].Value;

            if (isPedido)
            {
                var stock = new DStock();
                if (!stock.StockTieneProveedorAsociado(codProducto))
                {
                    MessageBox.Show("El producto no tiene un proveedor asociado. Asígnele uno para seguir cotizando",
                                    "Mensaje",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                var bienUso = new DBienUso();
                if (!bienUso.BienUsoTieneProveedorAsociado(codProducto))
                {
                    MessageBox.Show("El bien de uso no tiene un proveedor asociado. Asígnele uno para seguir cotizando",
                                    "Mensaje",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }



            var rta = MessageBox.Show("¿Está seguro de cotizar el producto?", "Confirmación",
                                      MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

            if (rta == DialogResult.No)
            {
                return;
            }

            int codCotizacion;

            try
            {
                if (isPedido)
                {
                    codCotizacion = dCotizacionPR.InsertCotizacionPR(codProducto,
                                                                     (int)DgvPedidos.SelectedRows[0].Cells[0].Value, "1 Semana", DateTime.Now, 0);

                    //dCotizacionPR.InsertCotizacionPRProveedor(codCotizacion, (int)ProveedorComboBox.SelectedValue);
                }
                else
                {
                    codCotizacion = dCotizacionSC.InsertCotizacionSC(codProducto,
                                                                     (int)DgvSolicitudes.SelectedRows[0].Cells[0].Value, "1 Semana", DateTime.Now, 0);

                    //dCotizacionSC.InsertCotizacionSCProveedor(codCotizacion, (int)ProveedorComboBox.SelectedValue);
                }


                MessageBox.Show("Cotización realizada con éxito", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Error al insertar la cotización: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //DeshabilitarCampos();

            DgvProductosPorCotizar.Rows.RemoveAt(DgvProductosPorCotizar.CurrentRow.Index);
            if (DgvProductosPorCotizar.RowCount == 0)
            {
                if (isPedido)
                {
                    CargarPedidos();
                    CargarCotizacionesPedido();
                }
                else
                {
                    CargarSolicitudes();
                    CargarCotizacionesSolicitud();
                }

                DeshabilitarCampos();
            }
        }