private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                var senderGrid = (DataGridView)sender;

                if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
                    e.RowIndex >= 0)
                {
                    //Enviar Mail
                    Entities.Tables.COMARTICULOSPROVISORIOS _item = new Entities.Tables.COMARTICULOSPROVISORIOS();
                    BLL.Tables.COMARTICULOSPROVISORIOS      _Actu = new BLL.Tables.COMARTICULOSPROVISORIOS();

                    _item.ID                  = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[(int)Col_Articulos.ID].Value);
                    _item.CODPROVISORIO       = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[(int)Col_Articulos.CODPROVISORIO].Value);
                    _item.CODEMP              = dataGridView1.Rows[e.RowIndex].Cells[(int)Col_Articulos.CODEMP].Value.ToString();
                    _item.REQUERIMIENTO_ID    = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[(int)Col_Articulos.REQUERIMIENTO_ID].Value);
                    _item.NROITEM             = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[(int)Col_Articulos.NROITEM].Value);
                    _item.PENDIENTEENBEJERMAN = 0;
                    _item.DESCRIPCION         = dataGridView1.Rows[e.RowIndex].Cells[(int)Col_Articulos.DESCRIPCION].Value.ToString();
                    _item.PRESENTACION        = dataGridView1.Rows[e.RowIndex].Cells[(int)Col_Articulos.PRESENTACION].Value.ToString();
                    _item.UNIMED              = dataGridView1.Rows[e.RowIndex].Cells[(int)Col_Articulos.UNIMED].Value.ToString();
                    _item.MARCA               = dataGridView1.Rows[e.RowIndex].Cells[(int)Col_Articulos.MARCA].Value.ToString();
                    _item.EMBALAJE            = dataGridView1.Rows[e.RowIndex].Cells[(int)Col_Articulos.EMBALAJE].Value.ToString();
                    _item.CANTIDAD            = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[(int)Col_Articulos.CANTIDAD].Value);
                    _item.USUARIO_ID          = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[(int)Col_Articulos.USUARIO_ID].Value);
                    if (_item.USUARIO_MAIL == null)
                    {
                        _item.USUARIO_MAIL = "";
                    }
                    else
                    {
                        _item.USUARIO_MAIL = dataGridView1.Rows[e.RowIndex].Cells[(int)Col_Articulos.EMAIL].Value.ToString();
                    }


                    _Actu.UpdateItem(_item);

                    string _codEmp = this.comboBoxEmpresa.SelectedValue.ToString();
                    TraerArticulosProvisorios(_codEmp);

                    _articulosBejerman.Clear();
                    CargarArticulosBejerman(_codEmp);
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 2
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);
            }
        }
Esempio n. 3
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);
            }
        }