private void toolStripButtonPrint_Click(object sender, EventArgs e)
        {
            try
            {
                if (VerificaIngreso())
                {
                    //OBJETOS STKINVENTARIO
                    Entities.Tables.STKINVENTARIO        _itemInventario = new Entities.Tables.STKINVENTARIO();
                    List <Entities.Tables.STKINVENTARIO> _itemsInv       = new List <Entities.Tables.STKINVENTARIO>();

                    //OBJETOS STKMOVIMIENTOSITEM
                    Entities.Tables.STKMOVIMIENTOITEM        _itemMov  = new Entities.Tables.STKMOVIMIENTOITEM();
                    List <Entities.Tables.STKMOVIMIENTOITEM> _itemsMov = new List <Entities.Tables.STKMOVIMIENTOITEM>();

                    //VARIABLES STKMOVIMIENTOS
                    Entities.Tables.STKMOVIMIENTO _itemMovimiento = new Entities.Tables.STKMOVIMIENTO();
                    BLL.Tables.STKMOVIMIENTO      _stk            = new BLL.Tables.STKMOVIMIENTO();

                    CultureInfo culture     = new CultureInfo("en-US");
                    Boolean     _selecciono = false;
                    //LA EMPRESA LA RECUPERO DEL DEPOSITO QUE SELECCIONO, CON EL DEPOSITO_ID BUSCO LA EMPRESA DE ESTE DEPOSTIO EN UNA LISTA
                    //int _deposito_id = Convert.ToInt32(comboBoxDeposito.SelectedValue);
                    //string _codEmpresa = _itemsDepositos.Find(x => x.DEPOSITO_ID == _deposito_id).CODEMP.ToString();
                    //FIN RECUPERA DEPOSITO

                    for (int i = 0; i < this.dataGridViewDetalle.Rows.Count; i++)
                    {
                        //SOLO INGRESO LOS ARTICULOS QUE SE RECIBEN
                        if (dataGridViewDetalle.Rows[i].Cells[(int)Col_DetalleOC.CANT_RECIBIDA].Value != null && dataGridViewDetalle.Rows[i].Cells[(int)Col_DetalleOC.CANT_RECIBIDA].Value.ToString() != string.Empty && dataGridViewDetalle.Rows[i].Cells[(int)Col_DetalleOC.CANT_RECIBIDA].Value.ToString() != "0")
                        {
                            _itemInventario             = new Entities.Tables.STKINVENTARIO();
                            _itemInventario.ARTICULO_ID = dataGridViewDetalle.Rows[i].Cells[(int)Col_DetalleOC.CODIGO].Value.ToString();                                    //COD ARTICULO
                            _itemInventario.CANTIDAD    = Convert.ToDecimal(dataGridViewDetalle.Rows[i].Cells[(int)Col_DetalleOC.CANT_RECIBIDA].Value.ToString(), culture); //cantidad
                            _itemInventario.DEPOSITO_ID = Convert.ToInt32(this.comboBoxDeposito.SelectedValue);                                                             //DEPOSITO
                            _itemInventario.SECTOR_ID   = 1;                                                                                                                //SECTOR NO SE UTILIZA... SIEMPRE ENVIO UNO... NO SE LLEVA EL STOCK POR SECTOR
                            _itemInventario.UNIMED      = dataGridViewDetalle.Rows[i].Cells[(int)Col_DetalleOC.UNIMED].Value.ToString();                                    //UNIDAD MEDIDA
                            //VOY AGREGANDO A LA COLECCION
                            _itemsInv.Add(_itemInventario);

                            //AHORA CARGO EL OBJETO STKMOVIMIENTOITEM
                            _itemMov             = new Entities.Tables.STKMOVIMIENTOITEM();
                            _itemMov.ARTICULO_ID = dataGridViewDetalle.Rows[i].Cells[(int)Col_DetalleOC.CODIGO].Value.ToString();                                    //COD ARTICULO
                            _itemMov.CANTIDAD    = Convert.ToDecimal(dataGridViewDetalle.Rows[i].Cells[(int)Col_DetalleOC.CANT_RECIBIDA].Value.ToString(), culture); //cantidad
                            _itemMov.CODEMP      = Clases.Usuario.EmpresaLogeada.EmpresaIngresada.ToString();                                                        //EL MOVIMIENTO SE REGISTRA CON LA EMPRESA INGRESADA
                            _itemMov.UNIMED      = dataGridViewDetalle.Rows[i].Cells[(int)Col_DetalleOC.UNIMED].Value.ToString();                                    //UNIDAD MEDIDA
                            _itemMov.NROITEM     = Convert.ToInt32(dataGridViewDetalle.Rows[i].Cells[(int)Col_DetalleOC.NROITEM].Value.ToString());                  //NRO ITEM DE LA ORDEN DE COMPRA, LO NECESITO PARA LA TABLA STKMOVIOC
                            //VOY AGREGANDO A LA COLECCION
                            _itemsMov.Add(_itemMov);

                            _selecciono = true;
                        }
                    }

                    if (_selecciono)
                    {
                        //CARGO LOS OBJETOS DE STKMOVIMIENTOS
                        _itemMovimiento.CODEMP            = Clases.Usuario.EmpresaLogeada.EmpresaIngresada.ToString(); //EL MOVIMIENTO SE REGISTRA CON LA EMPRESA INGRESADA
                        _itemMovimiento.ANULADO           = 0;
                        _itemMovimiento.FECHAMOV          = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                        _itemMovimiento.TIPOMOV_ID        = 1; //OJO VER ESTO SI SE PUEDE CAMBIAR...... EL 1 ES ENTRADA
                        _itemMovimiento.SUBTIPOMOV_ID     = 4; //ojo ver SI SE PUEDE CAMBIAR...... EL 1 ES INGRESO DE STOCK POR ORDEN DE COMPRA
                        _itemMovimiento.USUARIO           = Clases.Usuario.UsuarioLogeado.usuario_Logeado.ToString();
                        _itemMovimiento.OBS               = "";
                        _itemMovimiento.DEPOSITOORIGEN_ID = Convert.ToInt32(this.comboBoxDeposito.SelectedValue); //DEPOSITO
                        _itemMovimiento.SECTORORIGEN_ID   = 1;                                                    // OJO ***** NO SE LLEVA EL STOCK POR SECTOR.. EL ORIGEN SOLO SE UTILZA PARA ENVIAR MERCADERIA //Convert.ToInt32(this.comboBoxSector.SelectedValue); //SECTOR

                        string _remSucursal    = (this.textBoxSucRemito.Text.ToString() == string.Empty) ? "" : this.textBoxSucRemito.Text.Trim();
                        Int32  _remComprobante = (this.textBoxNroRemito.Text.ToString() == string.Empty) ? 0 : Convert.ToInt32(this.textBoxNroRemito.Text.Trim());

                        if (_stk.IngresoStockDepositoPorOC(_itemsInv, _itemMovimiento, _itemsMov, Convert.ToInt32(dataGridView1.CurrentRow.Cells[(int)Col_OCCabecera.ORDENCOMPRA_ID].Value.ToString()), dataGridView1.CurrentRow.Cells[(int)Col_OCCabecera.CODEMP].Value.ToString(), _remSucursal, _remComprobante, _ArtsVtos))
                        {
                            MessageBox.Show("El ingreso se realizó correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            //IMPRIMO LAS ETIQUETAS QUE HAYA SELECCIONADO

                            ImprimirEtiquetas();
                            //LIMPIO LA GRILLA DE DETALLE
                            dataGridViewDetalle.Rows.Clear();
                            this.comboBoxDeposito.SelectedIndex = 0;
                            //this.comboBoxSector.SelectedIndex = 0;
                            //cargo de nuevo las OC DE este proveedor
                            TraerOrdenCompraDisponibles(this.comboBoxProveed.SelectedValue.ToString());
                        }

                        else
                        {
                            MessageBox.Show("Error al ingresar Stock", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Debe ingresar al menos una cantidad en algún artículo", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void toolStripButtonSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (VerificaIngreso())
                {
                    //OBJETOS STKINVENTARIO
                    Entities.Tables.STKINVENTARIO        _itemInventario = new Entities.Tables.STKINVENTARIO();
                    List <Entities.Tables.STKINVENTARIO> _itemsInv       = new List <Entities.Tables.STKINVENTARIO>();

                    //OBJETOS STKMOVIMIENTOSITEM
                    Entities.Tables.STKMOVIMIENTOITEM        _itemMov  = new Entities.Tables.STKMOVIMIENTOITEM();
                    List <Entities.Tables.STKMOVIMIENTOITEM> _itemsMov = new List <Entities.Tables.STKMOVIMIENTOITEM>();

                    //VARIABLES STKMOVIMIENTOS
                    Entities.Tables.STKMOVIMIENTO _itemMovimiento = new Entities.Tables.STKMOVIMIENTO();
                    BLL.Tables.STKMOVIMIENTO      _stk            = new BLL.Tables.STKMOVIMIENTO();


                    for (int i = 0; i < this.dataGridViewDetalle.Rows.Count; i++)
                    {
                        _itemInventario             = new Entities.Tables.STKINVENTARIO();
                        _itemInventario.ARTICULO_ID = dataGridViewDetalle.Rows[i].Cells[(int)Col_Detalle.CODIGO].Value.ToString().Trim().ToUpper();                   //COD ARTICULO
                        _itemInventario.CANTIDAD    = Convert.ToDecimal(dataGridViewDetalle.Rows[i].Cells[(int)Col_Detalle.CANT_A_ENVIAR].Value.ToString(), culture); //cantidad
                        _itemInventario.DEPOSITO_ID = Convert.ToInt32(this.comboBoxDepositoDelPedido.SelectedValue);                                                  //DEPOSITO DE DONDE SALE LA MERCADERIA QUE ES EL MISMO AL CUAL SE LE HIZO EL PEDIDO *********************////
                        _itemInventario.SECTOR_ID   = 1;                                                                                                              //  *** NO SE USA ... NO SE LLEVA EL STOCK POR SECTOR Convert.ToInt32(this.comboBoxSectorSalida.SelectedValue); //SECTOR DE DONDE SALE LA MERCADERIA
                        _itemInventario.UNIMED      = dataGridViewDetalle.Rows[i].Cells[(int)Col_Detalle.UNIDAD].Value.ToString();                                    //UNIDAD MEDIDA
                        //VOY AGREGANDO A LA COLECCION
                        _itemsInv.Add(_itemInventario);

                        //AHORA CARGO EL OBJETO STKMOVIMIENTOITEM
                        _itemMov             = new Entities.Tables.STKMOVIMIENTOITEM();
                        _itemMov.ARTICULO_ID = dataGridViewDetalle.Rows[i].Cells[(int)Col_Detalle.CODIGO].Value.ToString();                                    //COD ARTICULO
                        _itemMov.CANTIDAD    = Convert.ToDecimal(dataGridViewDetalle.Rows[i].Cells[(int)Col_Detalle.CANT_A_ENVIAR].Value.ToString(), culture); //cantidad
                        _itemMov.CODEMP      = Clases.Usuario.EmpresaLogeada.EmpresaIngresada.ToString();                                                      //CODEMP
                        _itemMov.UNIMED      = dataGridViewDetalle.Rows[i].Cells[(int)Col_Detalle.UNIDAD].Value.ToString();                                    //UNIDAD MEDIDA
                        _itemMov.NROITEM     = Convert.ToInt32(dataGridViewDetalle.Rows[i].Cells[(int)Col_Detalle.NROITEM].Value);                             // NRO ITEM DEL REQUERIMIENTO INTERNO, LO NECESITO PARA LA TABLA STKMOVIREQINTERNO

                        //VOY AGREGANDO A LA COLECCION
                        _itemsMov.Add(_itemMov);
                    }

                    //CARGO LOS OBJETOS DE STKMOVIMIENTOS
                    _itemMovimiento.CODEMP            = Clases.Usuario.EmpresaLogeada.EmpresaIngresada.ToString(); //CODEMP
                    _itemMovimiento.ANULADO           = 0;
                    _itemMovimiento.TIPOMOV_ID        = 2;                                                         //OJO VER ESTO SI SE PUEDE CAMBIAR...... EL 2 ES SALIDA *************************************
                    _itemMovimiento.SUBTIPOMOV_ID     = 2;                                                         //ojo ver SI SE PUEDE CAMBIAR...... EL 2 es CAMBIO DE DEPÓSITOP **************************
                    _itemMovimiento.USUARIO           = Clases.Usuario.UsuarioLogeado.usuario_Logeado.ToString();
                    _itemMovimiento.OBS               = "";
                    _itemMovimiento.FECHAMOV          = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                    _itemMovimiento.DEPOSITOORIGEN_ID = Convert.ToInt32(this.comboBoxDepositoDelPedido.SelectedValue); //DEPOSITO DE DONDE SALE LA MERCADERIA  QUE ES LA MISMA DEL PEDIDO
                    _itemMovimiento.SECTORORIGEN_ID   = 1;                                                             //  OJO NO SE LLEVA EL STOCK POR SECTOR Convert.ToInt32(this.comboBoxSectorSalida.SelectedValue); //SECTOR DE DONDE SALE LA MERCADERIA

                    _itemMovimiento.DEPOSITODESTINO_ID = _depositoEnvioMercaderia;                                     //DEPOSITO AL CUAL VA LA MERCADERIA
                    _itemMovimiento.SECTORDESTINO_ID   = _sectorDepositoEnvioMercaderia;                               // SECTOR DEL DEPOSITO DONDE VA LA MERCADERIA

                    _nroRemitoGenerado = _stk.SalidaMercaderiaPorRequerimientoInterno(_itemsInv, _itemMovimiento, _itemsMov, _codEmpresa, _nroRequerimientoInterno);
                    if (_nroRemitoGenerado > 0)
                    {
                        MessageBox.Show("El egreso se realizó correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        ImprimirRemito();

                        dataGridViewDetalle.Rows.Clear();
                        this.comboBoxDepositoDelPedido.SelectedIndex = 0;
                        this.comboBoxSectorDelPedido.SelectedIndex   = 0;
                    }

                    else
                    {
                        MessageBox.Show("Error al ingresar Stock", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 3
0
        private void toolStripButtonSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (VerificaIngreso())
                {
                    //OBJETOS STKINVENTARIO
                    Entities.Tables.STKINVENTARIO        _itemInventario = new Entities.Tables.STKINVENTARIO();
                    List <Entities.Tables.STKINVENTARIO> _itemsInv       = new List <Entities.Tables.STKINVENTARIO>();

                    //OBJETOS STKMOVIMIENTOSITEM
                    Entities.Tables.STKMOVIMIENTOITEM        _itemMov  = new Entities.Tables.STKMOVIMIENTOITEM();
                    List <Entities.Tables.STKMOVIMIENTOITEM> _itemsMov = new List <Entities.Tables.STKMOVIMIENTOITEM>();

                    //VARIABLES STKMOVIMIENTOS
                    Entities.Tables.STKMOVIMIENTO _itemMovimiento = new Entities.Tables.STKMOVIMIENTO();
                    BLL.Tables.STKMOVIMIENTO      _stk            = new BLL.Tables.STKMOVIMIENTO();

                    CultureInfo culture = new CultureInfo("en-US");



                    for (int i = 0; i < this.dataGridViewDetalleAjusteStock.Rows.Count - 1; i++)
                    {
                        _itemInventario             = new Entities.Tables.STKINVENTARIO();
                        _itemInventario.ARTICULO_ID = dataGridViewDetalleAjusteStock.Rows[i].Cells[(int)Col_Detalle.CODIGO].Value.ToString();                               //COD ARTICULO
                        _itemInventario.CANTIDAD    = Convert.ToDecimal(dataGridViewDetalleAjusteStock.Rows[i].Cells[(int)Col_Detalle.CANTIDAD].Value.ToString(), culture); //cantidad
                        _itemInventario.DEPOSITO_ID = Convert.ToInt32(this.comboBoxDeposito.SelectedValue);                                                                 //DEPOSITO
                        _itemInventario.SECTOR_ID   = 1;                                                                                                                    //SECTOR
                        _itemInventario.UNIMED      = dataGridViewDetalleAjusteStock.Rows[i].Cells[(int)Col_Detalle.UNIDAD].Value.ToString();                               //UNIDAD MEDIDA
                        //VOY AGREGANDO A LA COLECCION
                        _itemsInv.Add(_itemInventario);

                        //AHORA CARGO EL OBJETO STKMOVIMIENTOITEM
                        _itemMov             = new Entities.Tables.STKMOVIMIENTOITEM();
                        _itemMov.ARTICULO_ID = dataGridViewDetalleAjusteStock.Rows[i].Cells[(int)Col_Detalle.CODIGO].Value.ToString();                               //COD ARTICULO
                        _itemMov.CANTIDAD    = Convert.ToDecimal(dataGridViewDetalleAjusteStock.Rows[i].Cells[(int)Col_Detalle.CANTIDAD].Value.ToString(), culture); //cantidad
                        _itemMov.CODEMP      = Clases.Usuario.EmpresaLogeada.EmpresaIngresada.ToString();                                                            //CODEMP
                        _itemMov.UNIMED      = dataGridViewDetalleAjusteStock.Rows[i].Cells[(int)Col_Detalle.UNIDAD].Value.ToString();                               //UNIDAD MEDIDA
                        //VOY AGREGANDO A LA COLECCION
                        _itemsMov.Add(_itemMov);
                    }

                    //CARGO LOS OBJETOS DE STKMOVIMIENTOS
                    _itemMovimiento.CODEMP            = Clases.Usuario.EmpresaLogeada.EmpresaIngresada.ToString(); //CODEMP
                    _itemMovimiento.ANULADO           = 0;
                    _itemMovimiento.FECHAMOV          = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                    _itemMovimiento.TIPOMOV_ID        = (comboBoxTipoMov.SelectedIndex == 0) ? 1:2;           // 1 ENTRADA 2 SALIDA
                    _itemMovimiento.DEPOSITOORIGEN_ID = Convert.ToInt32(this.comboBoxDeposito.SelectedValue); //DEPOSITO
                    _itemMovimiento.SECTORORIGEN_ID   = 1;                                                    // OJO ***** NO SE LLEVA EL STOCK POR SECTOR.. EL ORIGEN SOLO SE UTILZA PARA ENVIAR MERCADERIA //Convert.ToInt32(this.comboBoxSector.SelectedValue); //SECTOR

                    _itemMovimiento.SUBTIPOMOV_ID = 3;                                                        // AJUSTE DE INVENTARIO

                    _itemMovimiento.USUARIO         = Clases.Usuario.UsuarioLogeado.usuario_Logeado.ToString();
                    _itemMovimiento.OBS             = "";
                    _itemMovimiento.MOTIVOAJUSTE_ID = Convert.ToInt32(comboBoxMotivo.SelectedValue);


                    if (_stk.GenerarMovAjuste(_itemsInv, _itemMovimiento, _itemsMov, _ArtsVtos) == 0)
                    {
                        MessageBox.Show("El ingreso se realizó correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        dataGridViewDetalleAjusteStock.Rows.Clear();
                        this.comboBoxDeposito.SelectedIndex = 0;
                        this.comboBoxSector.SelectedIndex   = 0;
                    }

                    else
                    {
                        MessageBox.Show("Error al ingresar Stock", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }