private void toolStripButtonSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (comboBoxLugarEntrega.SelectedIndex == 0)
                {
                    MessageBox.Show("Debe seleccionar un lugar de Entrega", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                bool _selecciono    = false;
                int  nroReqGenerado = 0;

                // ***cabecera
                Entities.Tables.COMREQUERIMIENTO     _ReqCabecera = new Entities.Tables.COMREQUERIMIENTO();
                BLL.Tables.COMREQUERIMIENTO          _ReqCab      = new BLL.Tables.COMREQUERIMIENTO();
                Entities.Tables.COMREQUERIMIENTOITEM _ReqItem     = new Entities.Tables.COMREQUERIMIENTOITEM();
                // BLL.Tables.COMREQUERIMIENTOITEM _ReqIte = new BLL.Tables.COMREQUERIMIENTOITEM();
                List <Entities.Tables.COMREQUERIMIENTOITEM> _ItemsReq = new List <Entities.Tables.COMREQUERIMIENTOITEM>();

                string _empresa = Clases.Usuario.EmpresaLogeada.EmpresaIngresada.ToString();

                _ReqCabecera.FECHA     = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                _ReqCabecera.ESTADO_ID = 1; //Ojo ver que valor se envia despues
                _ReqCabecera.OBS       = this.textBoxObs.Text.Trim();
                _ReqCabecera.USUARIO   = Clases.Usuario.UsuarioLogeado.usuario_Logeado;
                _ReqCabecera.SECTORREQUERIMIENTO_ID = Clases.Usuario.UsuarioLogeado.Id_Sector; // Ojo ver como se envia Despues
                _ReqCabecera.SECTORENTREGA_ID       = Convert.ToInt32(comboBoxLugarEntrega.SelectedValue);

                // ** fin cabecera
                for (int i = 0; i < dataGridViewConsumos.Rows.Count; i++)
                {
                    DataGridViewCheckBoxCell cellSelecion = dataGridViewConsumos.Rows[i].Cells[(int)Col_Consumo.GENERAR] as DataGridViewCheckBoxCell;
                    if (Convert.ToBoolean(cellSelecion.Value))
                    {
                        _selecciono           = true;
                        _ReqItem              = new Entities.Tables.COMREQUERIMIENTOITEM();
                        _ReqItem.ARTICULO_ID  = dataGridViewConsumos.Rows[i].Cells[(int)Col_Consumo.ARTICULO].Value.ToString();
                        _ReqItem.UNIMED       = dataGridViewConsumos.Rows[i].Cells[(int)Col_Consumo.UNIMED].Value.ToString();
                        _ReqItem.CANTIDAD     = Convert.ToDecimal(dataGridViewConsumos.Rows[i].Cells[(int)Col_Consumo.REPONER].Value.ToString(), culture);
                        _ReqItem.FECHAENTREGA = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                        _ReqItem.MARCA        = dataGridViewConsumos.Rows[i].Cells[(int)Col_Consumo.MARCA].EditedFormattedValue.ToString();
                        _ReqItem.NIVELAUT_ID  = 1; //ojo ver como se envia despues
                                                   //SI LA CANTIDAD ES CERO.. NO LO GRABO.
                        if (_ReqItem.CANTIDAD > 0)
                        {
                            _ItemsReq.Add(_ReqItem); //Meto en la coleccion todos los elementos de la grilla
                        }
                    }
                }
                if (_selecciono)
                {
                    //LO DE ABAJO NO LO USO, PERO LO NECESITA LA FUNCION QUE CREA EL REQ
                    List <Entities.Tables.COMARTICULOSPROVISORIOS> _ItemsProvisorios = new List <Entities.Tables.COMARTICULOSPROVISORIOS>();
                    if (_ReqCab.AddItem(_ReqCabecera, _ItemsReq, _empresa, _ItemsProvisorios, ref nroReqGenerado))
                    {
                        MessageBox.Show("Se generó el Requerimiento Nro: " + nroReqGenerado, "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        dataGridViewConsumos.Rows.Clear();
                        this.textBoxObs.Text = "";
                        comboBoxLugarEntrega.SelectedIndex = 0;
                        comboBoxRubro.SelectedIndex        = 0;
                        comboBoxSubRubro.SelectedIndex     = 0;
                    }
                    else
                    {
                        MessageBox.Show("Error al grabar Requerimiento", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Debe seleccionar al menos un artículo", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        private void toolStripButtonSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (comboBoxLugarEntrega.SelectedIndex == 0)
                {
                    MessageBox.Show("Debe seleccionar un Lugar de Entrega", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                //
                List <Entities.Tables.COMARTICULOSPROVISORIOS> _ItemsProvisorios = new List <Entities.Tables.COMARTICULOSPROVISORIOS>(); //LO DEFINO... PERO NO LO USO, VA EN NULL
                Entities.Tables.COMREQUERIMIENTO     _ReqCabecera = new Entities.Tables.COMREQUERIMIENTO();
                BLL.Tables.COMREQUERIMIENTO          _ReqCab      = new BLL.Tables.COMREQUERIMIENTO();
                Entities.Tables.COMREQUERIMIENTOITEM _ReqItem     = new Entities.Tables.COMREQUERIMIENTOITEM();
                // BLL.Tables.COMREQUERIMIENTOITEM _ReqIte = new BLL.Tables.COMREQUERIMIENTOITEM();
                List <Entities.Tables.COMREQUERIMIENTOITEM> _ItemsReq = new List <Entities.Tables.COMREQUERIMIENTOITEM>();
                //CultureInfo culture = new CultureInfo("en-US");
                string _empresa = Clases.Usuario.EmpresaLogeada.EmpresaIngresada.ToString();


                _ReqCabecera.FECHA     = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                _ReqCabecera.ESTADO_ID = 1; //Ojo ver que valor se envia despues
                _ReqCabecera.OBS       = this.textBoxObs.Text.Trim();
                _ReqCabecera.USUARIO   = Clases.Usuario.UsuarioLogeado.usuario_Logeado;
                _ReqCabecera.SECTORREQUERIMIENTO_ID = Clases.Usuario.UsuarioLogeado.Id_Sector; // Ojo ver como se envia Despues
                _ReqCabecera.SECTORENTREGA_ID       = Convert.ToInt32(comboBoxLugarEntrega.SelectedValue);

                for (int i = 0; i < this.dataGridViewDetalleReqDisponibles.Rows.Count; i++)
                {
                    DataGridViewCheckBoxCell cellSelecion = dataGridViewDetalleReqDisponibles.Rows[i].Cells[(int)Col_Detalle.INCLUIR] as DataGridViewCheckBoxCell;//incluir
                    if (Convert.ToBoolean(cellSelecion.Value))
                    {
                        if (dataGridViewDetalleReqDisponibles.Rows[i].Cells[(int)Col_Detalle.CANTIDAD].Value != string.Empty && dataGridViewDetalleReqDisponibles.Rows[i].Cells[(int)Col_Detalle.CANTIDAD].Value != null)
                        {
                            _ReqItem = new Entities.Tables.COMREQUERIMIENTOITEM();

                            //_ReqItem.COMEMP = Clases.Usuario.EmpresaLogeada.EmpresaIngresada;
                            _ReqItem.ARTICULO_ID = dataGridViewDetalleReqDisponibles.Rows[i].Cells[(int)Col_Detalle.ARTICULO].Value.ToString();
                            _ReqItem.UNIMED      = dataGridViewDetalleReqDisponibles.Rows[i].Cells[(int)Col_Detalle.UNIMED].Value.ToString();
                            _ReqItem.CANTIDAD    = Convert.ToDecimal(dataGridViewDetalleReqDisponibles.Rows[i].Cells[(int)Col_Detalle.CANTIDAD].Value.ToString(), culture);
                            //if (dataGridViewDetalleReqDisponibles.Rows[i].Cells[(int)Col_Detalle.FENTREGA].Value == null)
                            //{
                            _ReqItem.FECHAENTREGA = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                            //}
                            //else
                            //{
                            //    _ReqItem.FECHAENTREGA = Convert.ToDateTime(Convert.ToDateTime(dataGridViewDetalleReqDisponibles.Rows[i].Cells[(int)Col_Detalle.FENTREGA].Value));
                            //}
                            //VERIFICO SI SELECCIONO UNA MARCA
                            if (dataGridViewDetalleReqDisponibles.Rows[i].Cells[(int)Col_Detalle.MARCA].Value != null && dataGridViewDetalleReqDisponibles.Rows[i].Cells[(int)Col_Detalle.MARCA].Value != "")
                            {
                                _ReqItem.MARCA = dataGridViewDetalleReqDisponibles.Rows[i].Cells[(int)Col_Detalle.MARCA].EditedFormattedValue.ToString();
                            }

                            _ReqItem.NIVELAUT_ID = 1; //ojo ver como se envia despues
                            //SI LA CANTIDAD ES CERO.. NO LO GRABO.
                            if (_ReqItem.CANTIDAD > 0)
                            {
                                _ItemsReq.Add(_ReqItem); //Meto en la coleccion todos los elementos de la grilla
                            }
                        }
                    }
                }

                //PUEDE SER QUE SOLO SE CARGUE ARTICULOS PROVISORIOS.... SE ENVIA LA CABECERA DEL REQUERIMIENTO Y LOS ITEMS DE PROVISORIOS
                if (_ItemsReq.Count > 0)
                {
                    int _nroReqGenerado = 0;
                    //LLAMO A LA FUNCION QUE GUARDA CABECERA E ITEMS
                    if (_ReqCab.AddItem(_ReqCabecera, _ItemsReq, _empresa, _ItemsProvisorios, ref _nroReqGenerado))
                    {
                        MessageBox.Show("Se generó el Requerimiento Nro.: " + _nroReqGenerado, "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        dataGridViewDetalleReqDisponibles.Rows.Clear();
                        this.textBoxObs.Text = "";
                        Close();
                    }
                    else
                    {
                        MessageBox.Show("Error al grabar Requerimiento", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Debe seleccionar al menos un artículo", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
        private void toolStripButtonSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidarDatos())
                {
                    if (this.dataGridViewReqItems.Rows.Count < 2 && this.dataGridViewProvisorios.Rows.Count < 2)
                    {
                        MessageBox.Show("No esta permitido eliminar todos los Items de un requerimiento", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    BLL.Tables.COMREQUERIMIENTOITEM             _ReqItems        = new BLL.Tables.COMREQUERIMIENTOITEM();
                    Entities.Tables.COMREQUERIMIENTOITEM        _ReqItem         = new Entities.Tables.COMREQUERIMIENTOITEM();
                    List <Entities.Tables.COMREQUERIMIENTOITEM> _reqItemsListAdd = new List <Entities.Tables.COMREQUERIMIENTOITEM>();

                    _Grabo = 0;

                    int _nroItem = 1;
                    //POR SI MODIFICO LA DIRECCION DE ENTREGA
                    int _entrega_id = Convert.ToInt32(dataGridViewReqCab.Rows[dataGridViewReqCab.CurrentRow.Index].Cells[(int)Col_ReqCab.ENTREGA_ID].Value.ToString());


                    for (int i = 0; i < this.dataGridViewReqItems.Rows.Count - 1; i++)
                    {
                        _ReqItem                  = new Entities.Tables.COMREQUERIMIENTOITEM();
                        _ReqItem.CODEMP           = _codemp;
                        _ReqItem.REQUERIMIENTO_ID = REQ_ID;
                        _ReqItem.NROITEM          = _nroItem;
                        _ReqItem.ARTICULO_ID      = dataGridViewReqItems.Rows[i].Cells[(int)Col_ReqItem.CODIGO].Value.ToString();
                        _ReqItem.UNIMED           = dataGridViewReqItems.Rows[i].Cells[(int)Col_ReqItem.UNIDAD].Value.ToString();
                        _ReqItem.CANTIDAD         = Convert.ToDecimal(dataGridViewReqItems.Rows[i].Cells[(int)Col_ReqItem.CANTIDAD].Value.ToString(), culture);
                        _ReqItem.NIVELAUT_ID      = 1;
                        _ReqItem.FECHAENTREGA     = Convert.ToDateTime(dataGridViewReqItems.Rows[i].Cells[(int)Col_ReqItem.FENTREGA].Value);
                        _reqItemsListAdd.Add(_ReqItem);
                        _nroItem++;
                        _Grabo = 1;
                    }

                    string _obs = this.textBoxObs.Text;

                    //AHORA VERIFICO SI EXISTEN ARTICULOS PROVISORIOS
                    List <Entities.Tables.COMARTICULOSPROVISORIOS> _ItemsProvisorios = new List <Entities.Tables.COMARTICULOSPROVISORIOS>();
                    Entities.Tables.COMARTICULOSPROVISORIOS        _ItemProvis       = new Entities.Tables.COMARTICULOSPROVISORIOS();
                    for (int i = 0; i < this.dataGridViewProvisorios.Rows.Count - 1; i++)
                    {
                        if (dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.DESCRIPCION].Value != null && dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.DESCRIPCION].Value != string.Empty && dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.CANTIDAD].Value != null && dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.CANTIDAD].Value != string.Empty)
                        {
                            if (dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.UNIDAD].Value == string.Empty || dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.UNIDAD].Value == null)
                            {
                                MessageBox.Show("Debe ingresar unidad de medida, para los artículos que no estén en Bejerman", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return; //SALGO DEL PROCESO.......
                            }
                            else
                            {
                                _ItemProvis              = new Entities.Tables.COMARTICULOSPROVISORIOS();
                                _ItemProvis.DESCRIPCION  = dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.DESCRIPCION].Value.ToString();
                                _ItemProvis.PRESENTACION = (dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.PRESENTACION].Value == string.Empty || dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.PRESENTACION].Value == null) ? string.Empty : dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.PRESENTACION].Value.ToString();
                                _ItemProvis.UNIMED       = dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.UNIDAD].Value.ToString();
                                _ItemProvis.MARCA        = (dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.MARCA].Value == string.Empty || dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.MARCA].Value == null) ? string.Empty : dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.MARCA].Value.ToString();
                                _ItemProvis.EMBALAJE     = (dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.EMBALAJE].Value == string.Empty || dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.EMBALAJE].Value == null) ? string.Empty : dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.EMBALAJE].Value.ToString();
                                _ItemProvis.CANTIDAD     = Convert.ToDecimal(dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.CANTIDAD].Value.ToString(), culture);

                                _ItemsProvisorios.Add(_ItemProvis);
                            }
                        }
                    }
                    //FIN ARTICULOS PROVISORIOS

                    _ReqItems.RemoveItem(_codemp, REQ_ID, _reqItemsListAdd, _ItemsProvisorios, _obs, _entrega_id);
                    MessageBox.Show("Los cambios se realizaron correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    dataGridViewReqItems.Rows.Clear();
                    this.textBoxObs.Text = string.Empty;
                    dataGridViewProvisorios.Rows.Clear();
                    TraeItemsPendientes();
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 4
0
        private void toolStripButtonSave_Click(object sender, EventArgs e)
        {
            try
            {
                //VERIFICO SI SOLAMENTE ESTA CARGANDO ARTICULOS PROVISORRIOS, DE SER ASÍ OBLIGO A SELECCIONAR UN RUBRO O SUBRUBRO ****
                if (comboBoxrubro.SelectedIndex == 0 && comboBoxRubro2.SelectedIndex == 0)
                {
                    MessageBox.Show("Si está creando un requerimiento, solo con artículos provisorios, debe seleccionar un Rubro o un Subrubro ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                // FIN CONTROL ARTICULOS PROVISORIOS
                //TAMBIÉN OBLIGO A SELECCIONAR UN LUGAR DE ENTREGA //
                if (comboBoxLugarEntrega.SelectedIndex == 0)
                {
                    MessageBox.Show("Debe seleccionar un Lugar de Entrega", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                //

                Entities.Tables.COMREQUERIMIENTO     _ReqCabecera = new Entities.Tables.COMREQUERIMIENTO();
                BLL.Tables.COMREQUERIMIENTO          _ReqCab      = new BLL.Tables.COMREQUERIMIENTO();
                Entities.Tables.COMREQUERIMIENTOITEM _ReqItem     = new Entities.Tables.COMREQUERIMIENTOITEM();
                // BLL.Tables.COMREQUERIMIENTOITEM _ReqIte = new BLL.Tables.COMREQUERIMIENTOITEM();
                List <Entities.Tables.COMREQUERIMIENTOITEM> _ItemsReq = new List <Entities.Tables.COMREQUERIMIENTOITEM>();
                //CultureInfo culture = new CultureInfo("en-US");
                string _empresa = this.comboBoxEmpresa.SelectedValue.ToString();

                _ReqCabecera.FECHA     = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                _ReqCabecera.ESTADO_ID = 1;     //Ojo ver que valor se envia despues
                _ReqCabecera.OBS       = this.textBoxObs.Text.Trim();
                _ReqCabecera.USUARIO   = Clases.Usuario.UsuarioLogeado.usuario_Logeado;
                _ReqCabecera.SECTORREQUERIMIENTO_ID = Clases.Usuario.UsuarioLogeado.Id_Sector;      // Ojo ver como se envia Despues
                _ReqCabecera.SECTORENTREGA_ID       = Convert.ToInt32(comboBoxLugarEntrega.SelectedValue);

                for (int i = 0; i < this.dataGridViewReq.Rows.Count; i++)
                {
                    if (dataGridViewReq.Rows[i].Cells[(int)Col_Detalle.CANTIDAD].Value != string.Empty && dataGridViewReq.Rows[i].Cells[(int)Col_Detalle.CANTIDAD].Value != null)
                    {
                        _ReqItem = new Entities.Tables.COMREQUERIMIENTOITEM();

                        //_ReqItem.COMEMP = Clases.Usuario.EmpresaLogeada.EmpresaIngresada;
                        _ReqItem.ARTICULO_ID = dataGridViewReq.Rows[i].Cells[(int)Col_Detalle.CODIGO].Value.ToString();
                        _ReqItem.UNIMED      = dataGridViewReq.Rows[i].Cells[(int)Col_Detalle.UNIDAD].Value.ToString();
                        _ReqItem.CANTIDAD    = Convert.ToDecimal(dataGridViewReq.Rows[i].Cells[(int)Col_Detalle.CANTIDAD].Value.ToString(), culture);
                        if (dataGridViewReq.Rows[i].Cells[(int)Col_Detalle.FENTREGA].Value == null)
                        {
                            _ReqItem.FECHAENTREGA = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                        }
                        else
                        {
                            _ReqItem.FECHAENTREGA = Convert.ToDateTime(Convert.ToDateTime(dataGridViewReq.Rows[i].Cells[(int)Col_Detalle.FENTREGA].Value));
                        }
                        //VERIFICO SI SELECCIONO UNA MARCA
                        if (dataGridViewReq.Rows[i].Cells[(int)Col_Detalle.MARCA].EditedFormattedValue != null && dataGridViewReq.Rows[i].Cells[(int)Col_Detalle.MARCA].Value != "0" && dataGridViewReq.Rows[i].Cells[(int)Col_Detalle.MARCA].Value != "<Sin Definir>")
                        {
                            _ReqItem.MARCA = dataGridViewReq.Rows[i].Cells[(int)Col_Detalle.MARCA].EditedFormattedValue.ToString();
                        }

                        _ReqItem.NIVELAUT_ID = 1;     //ojo ver como se envia despues
                        //SI LA CANTIDAD ES CERO.. NO LO GRABO.
                        if (_ReqItem.CANTIDAD > 0)
                        {
                            _ItemsReq.Add(_ReqItem);     //Meto en la coleccion todos los elementos de la grilla
                        }
                    }
                }
                //AHORA VERIFICO SI EXISTEN ARTICULOS PROVISORIOS
                List <Entities.Tables.COMARTICULOSPROVISORIOS> _ItemsProvisorios = new List <Entities.Tables.COMARTICULOSPROVISORIOS>();
                Entities.Tables.COMARTICULOSPROVISORIOS        _ItemProvis       = new Entities.Tables.COMARTICULOSPROVISORIOS();
                for (int i = 0; i < this.dataGridViewProvisorios.Rows.Count - 1; i++)
                {
                    if (dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.DESCRIPCION].Value != null && dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.DESCRIPCION].Value != string.Empty && dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.CANTIDAD].Value != null && dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.CANTIDAD].Value != string.Empty)
                    {
                        if (dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.UNIDAD].Value == string.Empty || dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.UNIDAD].Value == null)
                        {
                            MessageBox.Show("Debe ingresar unidad de medida, para los artículos que no estén en Bejerman", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;     //SALGO DEL PROCESO.......
                        }
                        else
                        {
                            _ItemProvis              = new Entities.Tables.COMARTICULOSPROVISORIOS();
                            _ItemProvis.DESCRIPCION  = dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.DESCRIPCION].Value.ToString();
                            _ItemProvis.PRESENTACION = (dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.PRESENTACION].Value == string.Empty || dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.PRESENTACION].Value == null) ? string.Empty : dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.PRESENTACION].Value.ToString();
                            _ItemProvis.UNIMED       = dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.UNIDAD].Value.ToString().ToUpper();
                            _ItemProvis.MARCA        = (dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.MARCA].Value == string.Empty || dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.MARCA].Value == null) ? string.Empty : dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.MARCA].Value.ToString();
                            _ItemProvis.EMBALAJE     = (dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.EMBALAJE].Value == string.Empty || dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.EMBALAJE].Value == null) ? string.Empty : dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.EMBALAJE].Value.ToString();
                            _ItemProvis.CANTIDAD     = Convert.ToDecimal(dataGridViewProvisorios.Rows[i].Cells[(int)col_Provisorios.CANTIDAD].Value.ToString(), culture);
                            _ItemProvis.USUARIO_ID   = Clases.Usuario.UsuarioLogeado.id_usuario_Logeado;
                            _ItemProvis.USUARIO_MAIL = Clases.Usuario.UsuarioLogeado.Email;
                            if (this.comboBoxrubro.SelectedIndex == 0)    // subrubro
                            {
                                _ItemProvis.SUB_RUBRO = this.comboBoxRubro2.Text;
                            }
                            else
                            {
                                _ItemProvis.SUB_RUBRO = this.comboBoxrubro.Text;
                            }
                            if (_ItemProvis.CANTIDAD > 0)
                            {
                                _ItemsProvisorios.Add(_ItemProvis);
                            }
                        }
                    }
                }
                //FIN ARTICULOS PROVISORIOS

                //PUEDE SER QUE SOLO SE CARGUE ARTICULOS PROVISORIOS.... SE ENVIA LA CABECERA DEL REQUERIMIENTO Y LOS ITEMS DE PROVISORIOS
                if (_ItemsReq.Count > 0 || _ItemsProvisorios.Count > 0)
                {
                    int _nroReqGenerado = 0;
                    //LLAMO A LA FUNCION QUE GUARDA CABECERA E ITEMS
                    if (_ReqCab.AddItem(_ReqCabecera, _ItemsReq, _empresa, _ItemsProvisorios, ref _nroReqGenerado))
                    {
                        if (_ItemsProvisorios.Count > 0)
                        {
                            this.labelEnviandomail.Visible = true;
                            this.progressBar1.Visible      = true;
                            EnviarMail();
                        }

                        MessageBox.Show("Se generó el Requerimiento Nro.: " + _nroReqGenerado, "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        dataGridViewReq.Rows.Clear();
                        this.textBoxObs.Text = "";
                        dataGridViewProvisorios.Rows.Clear();
                    }
                    else
                    {
                        MessageBox.Show("Error al grabar Requerimiento", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Debe ingresar al menos una cantidad", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 5
0
        private void toolStripButtonSave_Click(object sender, EventArgs e)
        {
            try
            {
                Entities.Tables.COMREQUERIMIENTOITEM        _itemRequerimiento = new Entities.Tables.COMREQUERIMIENTOITEM();
                List <Entities.Tables.COMREQUERIMIENTOITEM> _items             = new List <Entities.Tables.COMREQUERIMIENTOITEM>();
                Entities.Tables.COMREQUERIMIENTO            _itemCab           = new Entities.Tables.COMREQUERIMIENTO();
                BLL.Tables.COMREQUERIMIENTO _auto = new BLL.Tables.COMREQUERIMIENTO();

                Boolean _selecciono = false;
                for (int i = 0; i < this.dataGridViewReqItem.Rows.Count; i++)
                {
                    _itemRequerimiento = new Entities.Tables.COMREQUERIMIENTOITEM();

                    DataGridViewCheckBoxCell cellSelecion       = dataGridViewReqItem.Rows[i].Cells[(int)Col_RequerimientoItem.AUTORIZA] as DataGridViewCheckBoxCell;
                    DataGridViewCheckBoxCell cellSelecionNoAuto = dataGridViewReqItem.Rows[i].Cells[(int)Col_RequerimientoItem.NO_AUTORIZA] as DataGridViewCheckBoxCell;
                    if (Convert.ToBoolean(cellSelecion.Value) || Convert.ToBoolean(cellSelecionNoAuto.Value))
                    {
                        _itemRequerimiento.CODEMP           = dataGridViewReqItem.Rows[i].Cells[(int)Col_RequerimientoItem.CODEMPRESA].Value.ToString(); //Clases.Usuario.EmpresaLogeada.EmpresaIngresada;
                        _itemRequerimiento.REQUERIMIENTO_ID = Convert.ToInt32(dataGridViewReqItem.Rows[i].Cells[(int)Col_RequerimientoItem.NRO_REQUERIMIENTO].Value);
                        _itemRequerimiento.NROITEM          = Convert.ToInt32(dataGridViewReqItem.Rows[i].Cells[(int)Col_RequerimientoItem.NRO_ITEM].Value);
                        _itemRequerimiento.ARTICULO_ID      = dataGridViewReqItem.Rows[i].Cells[(int)Col_RequerimientoItem.ARTICULO_ID].Value.ToString();
                        _itemRequerimiento.UNIMED           = dataGridViewReqItem.Rows[i].Cells[(int)Col_RequerimientoItem.UNIDAD_DE_MEDIDA].Value.ToString();
                        _itemRequerimiento.CANTIDAD         = Convert.ToDecimal(dataGridViewReqItem.Rows[i].Cells[(int)Col_RequerimientoItem.CANTIDAD].Value.ToString(), culture);
                        _itemRequerimiento.FECHAENTREGA     = Convert.ToDateTime(dataGridViewReqItem.Rows[i].Cells[(int)Col_RequerimientoItem.FECHA_DE_ENTREGA].Value.ToString());
                        _itemRequerimiento.MARCA            = (dataGridViewReqItem.Rows[i].Cells[(int)Col_RequerimientoItem.MARCA].Value == null) ? string.Empty: dataGridViewReqItem.Rows[i].Cells[(int)Col_RequerimientoItem.MARCA].Value.ToString();
                        //DATOS PARA LA CABECERA
                        _itemCab.REQUERIMIENTO_ID = Convert.ToInt32(dataGridViewReqItem.Rows[i].Cells[(int)Col_RequerimientoItem.NRO_REQUERIMIENTO].Value);
                        _itemCab.CODEMP           = dataGridViewReqItem.Rows[i].Cells[(int)Col_RequerimientoItem.CODEMPRESA].Value.ToString();
                        _itemCab.PEDIDODIARIO     = (this.checkBoxDiario.Checked) ? true : false; //ME INDICA SI EL REQUERIMIENTO ES DIARIO

                        //VERIFICA SI ESTA AUTORIZADO
                        if (Convert.ToBoolean(cellSelecion.Value))
                        {
                            _selecciono = true;
                            _itemRequerimiento.NIVELAUT_ID = 2;
                        }
                        //VERIFICA SI LO ESTA RECHAZANDO
                        if (Convert.ToBoolean(cellSelecionNoAuto.Value))
                        {
                            _selecciono = true;
                            _itemRequerimiento.NIVELAUT_ID = 3;
                        }

                        _items.Add(_itemRequerimiento);
                    }
                }
                //PASO EL USAURIO LOGEADO
                _itemCab.USUARIOAUTORIZA = Clases.Usuario.UsuarioLogeado.usuario_Logeado.ToString();
                if (_selecciono)
                {
                    _auto.AutorizaRequerimiento(_items, _itemCab);

                    MessageBox.Show("Se Guardo correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    TraeRequerimientosPendientes();
                    dataGridViewReqItem.Rows.Clear();
                }
                else
                {
                    MessageBox.Show("Debe seleccionar al menos un Articulo", "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
            {
                int _cantidaditems = this.dataGridViewOCItem.Rows.Count - 1;
                int _cantExcluidos = 0;
                Entities.Tables.COMREQUERIMIENTOITEM        _item  = new Entities.Tables.COMREQUERIMIENTOITEM();
                List <Entities.Tables.COMREQUERIMIENTOITEM> _Items = new List <Entities.Tables.COMREQUERIMIENTOITEM>();
                BLL.Procedures.EXCLUYEITEMSREQ _excluye            = new BLL.Procedures.EXCLUYEITEMSREQ();

                for (int i = 0; i < this.dataGridViewOCItem.Rows.Count; i++)
                {
                    DataGridViewCheckBoxCell cellSelecion = dataGridViewOCItem.Rows[i].Cells[(int)Col_ReqItem.EXCLUIDO] as DataGridViewCheckBoxCell;


                    _item                  = new Entities.Tables.COMREQUERIMIENTOITEM();
                    _item.CODEMP           = _codEmp;
                    _item.REQUERIMIENTO_ID = REQ_ID;
                    _item.NROITEM          = Convert.ToInt32(dataGridViewOCItem.Rows[i].Cells[(int)Col_ReqItem.NROITEM].Value);
                    if (dataGridViewOCItem.Rows[i].Cells[(int)Col_ReqItem.MOTIVO].Value == null)
                    {
                        _item.MOTIVOEXCLUSION = "";
                    }
                    else
                    {
                        _item.MOTIVOEXCLUSION = dataGridViewOCItem.Rows[i].Cells[(int)Col_ReqItem.MOTIVO].Value.ToString().ToUpper();
                    }
                    _item.USUARIOEXCLUYE = Clases.Usuario.UsuarioLogeado.usuario_Logeado.ToString();

                    if (Convert.ToBoolean(cellSelecion.Value))
                    {
                        _item.EXCLUIDO = 1;
                        _cantExcluidos++;
                        _Items.Add(_item);
                    }
                    else  //ESTO PORQUE PUEDE VOLVER A TRAS UN ARTICULO EXLUIDO... ES DECIR LO PUEDO INCLUR DE NUEVO
                    {
                        _item.EXCLUIDO        = 0;
                        _item.MOTIVOEXCLUSION = "";
                        _item.USUARIOEXCLUYE  = "";
                        _Items.Add(_item);
                    }
                }
                _excluye.ExcluyeItem(_Items);

                if (_Items.Count > 0)
                {
                    if (_cantExcluidos == _cantidaditems)
                    {
                        MessageBox.Show("No se puede excluir la totalidad de Items de la O.C.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    else
                    {
                        MessageBox.Show("Items excluidos correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        REQ_ID  = 0;
                        _codEmp = string.Empty;
                        dataGridViewOCItem.Rows.Clear();
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }