예제 #1
0
        private void textBoxOC_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter && textBoxOC.Text != string.Empty)
            {
                StaCatalinaEntities _Mod = new StaCatalinaEntities();
                var _varObj = (from L in _Mod.ORDENCOMPRA_PARA_MODIFICAR_FECHA_BUSCADOR(Clases.Usuario.EmpresaLogeada.EmpresaIngresada.ToString().Trim(), Convert.ToInt32(textBoxOC.Text))
                               select L).SingleOrDefault();

                this.dataGridViewOCCab.Rows.Clear();
                int indice = 0;

                if (_varObj == null)
                {
                    MessageBox.Show("Orden de Compra no disponible para Excluir", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                else
                {
                    indice = dataGridViewOCCab.Rows.Add();
                    dataGridViewOCCab.Rows[indice].Cells[(int)Col_OCCab.CODEMP].Value           = _varObj.codEmp;                    //CODIGO DE EMPRESA
                    dataGridViewOCCab.Rows[indice].Cells[(int)Col_OCCab.EMPRESA].Value          = _varObj.codEmp;                    //EMPRESA
                    dataGridViewOCCab.Rows[indice].Cells[(int)Col_OCCab.NRO_OC].Value           = _varObj.ordenCompra_id;            //NRO OC
                    dataGridViewOCCab.Rows[indice].Cells[(int)Col_OCCab.FECHA].Value            = _varObj.fecha.ToShortDateString(); //FECHA
                    dataGridViewOCCab.Rows[indice].Cells[(int)Col_OCCab.PROVEEDOR].Value        = _varObj.RazonSocial;               //PROVEEDOR
                    dataGridViewOCCab.Rows[indice].Cells[(int)Col_OCCab.OBSERVACIONES].Value    = _varObj.obs;                       //PROVEEDOR
                    dataGridViewOCCab.Rows[indice].Cells[(int)Col_OCCab.USUARIO_AUTORIZO].Value = _varObj.usuarioAutoriza;           //USUARIO QUE AUTORIZO
                    dataGridViewOCCab.Rows[indice].DefaultCellStyle.BackColor = (Convert.ToBoolean(_varObj.pedidoDiario)) ? Color.YellowGreen : Color.White;
                }
            }
        }
        private void TraeItemsPendientes()
        {
            try
            {
                // stored REQUERIMIENTOS_INTERNO_PARA_MODIFICAR
                StaCatalinaEntities _mod = new StaCatalinaEntities();

                var _listObj = (_mod.REQUERIMIENTOS_INTERNO_PARA_MODIFICAR(Clases.Usuario.UsuarioLogeado.Id_Sector, Clases.Usuario.UsuarioLogeado.id_usuario_Logeado)).ToList();


                this.dataGridViewReqInternoCab.Rows.Clear();
                int indice;


                foreach (REQUERIMIENTOS_INTERNO_PARA_MODIFICAR_Result item in _listObj)
                {
                    indice = dataGridViewReqInternoCab.Rows.Add();
                    dataGridViewReqInternoCab.Rows[indice].Cells[(int)Col_ReqCab.CODEMP].Value                  = item.codEmp;                        //CODIGO DE EMPRESA
                    dataGridViewReqInternoCab.Rows[indice].Cells[(int)Col_ReqCab.REQ_ID].Value                  = item.requerimiento_id;              //NRO req
                    dataGridViewReqInternoCab.Rows[indice].Cells[(int)Col_ReqCab.FECHA].Value                   = item.fecha.ToShortDateString();     //FECHA
                    dataGridViewReqInternoCab.Rows[indice].Cells[(int)Col_ReqCab.SECTOR_ID].Value               = item.sectorRequerimiento_id;        // sector al cual pertenece el usuarioque hizo el requerimiento
                    dataGridViewReqInternoCab.Rows[indice].Cells[(int)Col_ReqCab.DEPOSITO_ORIGEN].Value         = item.depositoOrigen_id;             // DEPOSITO DEL CUAL HICE EL PEDIDO. ES EL LUGAR DE ENTREGA
                    dataGridViewReqInternoCab.Rows[indice].Cells[(int)Col_ReqCab.SECTOR_DEPOSITO_ORIGEN].Value  = item.sectorDepositoOrigen_id;       //SECTOR DEL DEPOSITO DEL CUAL HICE EL PEDIDO
                    dataGridViewReqInternoCab.Rows[indice].Cells[(int)Col_ReqCab.DEPOSITO_DESTINO].Value        = item.depositoDestino_id;            // DEPOSITO DEL CUAL HICE EL PEDIDO. ES EL LUGAR DE ENTREGA
                    dataGridViewReqInternoCab.Rows[indice].Cells[(int)Col_ReqCab.SECTOR_DEPÒSITO_DESTINO].Value = item.sectorDepositoDestino_id;      //SECTOR DEL DEPOSITO DEL CUAL HICE EL PEDIDO

                    dataGridViewReqInternoCab.Rows[indice].Cells[(int)Col_ReqCab.OBSERVACIONES].Value    = (item.OBS == string.Empty) ? "": item.OBS; // obs
                    dataGridViewReqInternoCab.Rows[indice].Cells[(int)Col_ReqCab.USUARIO_AUTORIZA].Value = item.usuarioAutoriza;                      //USUARIO AUTORIZA
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #3
0
        public static void CargarEmpresas(ComboBox _combo)
        {
            try
            {
                StaCatalinaEntities _mod = new StaCatalinaEntities();

                var _listObj = (_mod.varEmpresa).ToList();

                varEmpresa _itemSeleccion = new varEmpresa();

                //Limpia el combo
                _combo.SuspendLayout();
                _combo.DataSource = null;
                _combo.Items.Clear();
                //Carga el item de Seleccion
                _itemSeleccion.Descripcion = "<Seleccione una Empresa>";
                _itemSeleccion.codEmp      = "0";
                _listObj.Insert(0, _itemSeleccion);
                //Carga el combo
                _combo.DisplayMember = "Descripcion";
                _combo.ValueMember   = "codEmp";
                _combo.DataSource    = _listObj;
                _combo.ResumeLayout();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void CargarItemsRequerimiento(int _index, int _nivelAutorizazion)
        {
            try
            {
                //TraeRequerimientoInternoItem_Result _item = new TraeRequerimientoInternoItem_Result();
                StaCatalinaEntities _mod = new StaCatalinaEntities();

                this.dataGridViewReqItemsInterno.Rows.Clear();
                int indice;
                foreach (TraeRequerimientoInternoItem_Result item in _mod.TraeRequerimientoInternoItem(dataGridViewReqInternoCab.Rows[_index].Cells[(int)Col_ReqCab.CODEMP].Value.ToString(), Convert.ToInt32(dataGridViewReqInternoCab.Rows[_index].Cells[(int)Col_ReqCab.REQ_ID].Value), _nivelAutorizazion))
                {
                    indice = dataGridViewReqItemsInterno.Rows.Add();
                    dataGridViewReqItemsInterno.Rows[indice].Cells[(int)Col_ReqItem.CODEMP].Value      = item.codEmp;                                //CODIGO EMPRESA
                    dataGridViewReqItemsInterno.Rows[indice].Cells[(int)Col_ReqItem.CODIGO].Value      = item.articulo_id;                           //ARTICULO
                    dataGridViewReqItemsInterno.Rows[indice].Cells[(int)Col_ReqItem.NROREQ].Value      = item.requerimiento_id;                      //OC
                    dataGridViewReqItemsInterno.Rows[indice].Cells[(int)Col_ReqItem.NROITEM].Value     = item.nroItem;                               //NRO ITEM
                    dataGridViewReqItemsInterno.Rows[indice].Cells[(int)Col_ReqItem.DESCRIPCION].Value = item.art_DescGen.ToString();                //DESCRIP ARTICULO
                    dataGridViewReqItemsInterno.Rows[indice].Cells[(int)Col_ReqItem.UNIDAD].Value      = item.uniMed;                                //TRAE UNIMED
                    dataGridViewReqItemsInterno.Rows[indice].Cells[(int)Col_ReqItem.CANTIDAD].Value    = item.cantidad.ToString().Replace(",", "."); //CANTIDAD
                }
                REQ_ID  = Convert.ToInt32(dataGridViewReqInternoCab.Rows[_index].Cells[(int)Col_ReqCab.REQ_ID].Value);                               // Salvo el NRO REQ
                _codemp = dataGridViewReqInternoCab.Rows[_index].Cells[(int)Col_ReqCab.CODEMP].Value.ToString();                                     // Salvo el CODEMP


                //TRAIGO LAS OBSERVACIOENS EN EL TEXT.. POR SI LA QUIERE MODIFICAR
                this.textBoxObs.Text = dataGridViewReqInternoCab.Rows[_index].Cells[(int)Col_ReqCab.OBSERVACIONES].Value.ToString();

                //SETEO LOS DEPOSITOS Y SECTORES
                comboBoxDepositoOrigen.SelectedValue = dataGridViewReqInternoCab.Rows[_index].Cells[(int)Col_ReqCab.DEPOSITO_ORIGEN].Value;
                comboBoxSectorOrigen.SelectedValue   = dataGridViewReqInternoCab.Rows[_index].Cells[(int)Col_ReqCab.SECTOR_DEPOSITO_ORIGEN].Value;

                comboBoxDepositoDestino.SelectedValue = dataGridViewReqInternoCab.Rows[_index].Cells[(int)Col_ReqCab.DEPOSITO_DESTINO].Value;
                comboBoxSectorDestino.SelectedValue   = dataGridViewReqInternoCab.Rows[_index].Cells[(int)Col_ReqCab.SECTOR_DEPÒSITO_DESTINO].Value;
                // fin seteo
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #5
0
        private void toolStripButtonSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBoxAnio.Text != string.Empty && textBoxMes.Text != string.Empty)
                {
                    if (Convert.ToInt16(textBoxMes.Text) <= 12)
                    {
                        Cursor = System.Windows.Forms.Cursors.WaitCursor;

                        StaCatalinaEntities _mod = new StaCatalinaEntities();
                        _mod.Database.CommandTimeout = 3800;
                        _mod.OrdenCompra_Indicador_Mensual(Clases.Usuario.EmpresaLogeada.EmpresaIngresada, Convert.ToInt32(textBoxAnio.Text), Convert.ToInt16(textBoxMes.Text), 90);

                        MessageBox.Show("Indicador generado Correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("El número de mes no puede ser mayor a 12", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        textBoxMes.Focus();
                    }
                }

                else
                {
                    MessageBox.Show("Debe ingresar Año y Mes", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    textBoxAnio.Focus();
                }


                Cursor = System.Windows.Forms.Cursors.Default;
            }

            catch (Exception ex)
            {
                Cursor = System.Windows.Forms.Cursors.Default;
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void comboBoxProveed_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (comboBoxProveed.SelectedIndex > 0)
                {
                    StaCatalinaEntities _Mod = new StaCatalinaEntities();
                    var _list = (from M in _Mod.TraeProveedorEmpresa(comboBoxcodEmp.SelectedValue.ToString(), comboBoxProveed.SelectedValue.ToString())

                                 select new
                    {
                        M.Email,
                    }).SingleOrDefault();
                    dataGridViewMails.Rows.Clear();
                    int indice = 0;


                    if (_list.Email != string.Empty && _list.Email != null)
                    {
                        // UN PROVEEDOR PUEDE TENER MAS DE UNA DIRECCION DE MAIL SEPARADO POR ; (punto y coma), APLICO SPLIT
                        Char     _delimiter = ';';
                        String[] substrings = _list.Email.Split(_delimiter);
                        for (int i = 0; i < substrings.Length; i++)
                        {
                            indice = dataGridViewMails.Rows.Add();
                            dataGridViewMails.Rows[indice].Cells[(int)Col_Mail.MAIL].Value = substrings[i].ToString(); // MAIL

                            indice++;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #7
0
        private void textBoxOC_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter && textBoxOC.Text != string.Empty)
            {
                StaCatalinaEntities _Mod = new StaCatalinaEntities();
                var _varObj = (from L in _Mod.ORDENCOMPRA_PENDIENTES_DE_ENTREGA_BUSCADOR(Clases.Usuario.EmpresaLogeada.EmpresaIngresada.ToString().Trim(), Convert.ToInt32(textBoxOC.Text))
                               select L).SingleOrDefault();

                this.dataGridViewOCCab.Rows.Clear();
                int indice = 0;

                if (_varObj == null)
                {
                    MessageBox.Show("Orden de Compra no encontrada, verifique si la misma no está anulada", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                else
                {
                    indice = dataGridViewOCCab.Rows.Add();
                    dataGridViewOCCab.Rows[indice].Cells[(int)Col_OCCab.CODEMP].Value            = _varObj.codEmp;                    //CODIGO DE EMPRESA
                    dataGridViewOCCab.Rows[indice].Cells[(int)Col_OCCab.EMPRESA].Value           = _varObj.codEmp;                    //EMPRESA
                    dataGridViewOCCab.Rows[indice].Cells[(int)Col_OCCab.NRO_OC].Value            = _varObj.ordenCompra_id;            //NRO OC
                    dataGridViewOCCab.Rows[indice].Cells[(int)Col_OCCab.SECTORREQ].Value         = _varObj.sectorRequerimiento_id;    //SECTOR REQUERIMIENTO
                    dataGridViewOCCab.Rows[indice].Cells[(int)Col_OCCab.ESTADO_ID].Value         = _varObj.estado_id;                 //ESTADI ID
                    dataGridViewOCCab.Rows[indice].Cells[(int)Col_OCCab.TIPOOC_ID].Value         = _varObj.tipoOc_id;                 //TIPO DE OC
                    dataGridViewOCCab.Rows[indice].Cells[(int)Col_OCCab.MODIFICACOSTO].Value     = _varObj.modificaCosto;             //MODIFICA COSTO
                    dataGridViewOCCab.Rows[indice].Cells[(int)Col_OCCab.CONDPAGO_ID].Value       = _varObj.condicionPago_id;          //CONDICION PAGO ID
                    dataGridViewOCCab.Rows[indice].Cells[(int)Col_OCCab.USUARIO].Value           = _varObj.usuario;                   //USUARIO
                    dataGridViewOCCab.Rows[indice].Cells[(int)Col_OCCab.USUARIO_AUTORIZA].Value  = _varObj.usuarioAutoriza;           //USUARIO AUTORIZA
                    dataGridViewOCCab.Rows[indice].Cells[(int)Col_OCCab.FECHA].Value             = _varObj.fecha.ToShortDateString(); //FECHA
                    dataGridViewOCCab.Rows[indice].Cells[(int)Col_OCCab.PROVEEDOR].Value         = _varObj.RazonSocial;               //PROVEEDOR
                    dataGridViewOCCab.Rows[indice].Cells[(int)Col_OCCab.OBSERVACIONES].Value     = _varObj.obs;                       //OBSERVACIONES
                    dataGridViewOCCab.Rows[indice].Cells[(int)Col_OCCab.SECTOR_ENTREGA_ID].Value = _varObj.sectorEntrega_id;          //SECTOR DE ENTREGA
                }
            }
        }
예제 #8
0
        private void CargarMotivos()
        {
            StaCatalinaEntities _Mod = new StaCatalinaEntities();


            var _listObj = (from T in _Mod.stkMotivoAjuste
                            orderby T.Descripcion
                            select T).ToList();
            stkMotivoAjuste _itemSeleccion = new stkMotivoAjuste();


            var q = (dynamic)null;

            q = (from item in _listObj
                 select item).ToList <stkMotivoAjuste>();


            //Limpia el combo
            this.comboBoxMotivo.SuspendLayout();
            this.comboBoxMotivo.DataSource = null;
            this.comboBoxMotivo.Items.Clear();


            //Carga el item de Seleccion
            _itemSeleccion.Descripcion = "<Seleccione un Motivo>";
            _itemSeleccion.Id          = 0;

            //_ItemsArtDep = _prod.ItemList();
            q.Insert(0, _itemSeleccion);
            //Carga el combo
            this.comboBoxMotivo.DisplayMember = "Descripcion";
            this.comboBoxMotivo.ValueMember   = "Id";
            this.comboBoxMotivo.DataSource    = q;

            this.comboBoxMotivo.ResumeLayout();
            this.comboBoxMotivo.SelectedIndex = 0;
        }
        private void textBoxNroOC_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (comboBoxcodEmp.SelectedIndex > 0)
                {
                    StaCatalinaEntities _Mod = new StaCatalinaEntities();
                    dataGridViewDetalleOC.Rows.Clear();

                    var _ocDetalle = (from L in _Mod.ordenCompraSinStock_ParaModificar(comboBoxcodEmp.SelectedValue.ToString(), Convert.ToInt32(textBoxNroOC.Text))
                                      select L).ToList();

                    int   indice         = 0;
                    Int16 _tipoProrrateo = 1;

                    foreach (var item in _ocDetalle)
                    {
                        if (item.usuarioAutoriza != string.Empty)
                        {
                            if (item.usuarioAutoriza.Trim() != Clases.Usuario.UsuarioLogeado.usuario_Logeado.Trim())
                            {
                                MessageBox.Show("Ud. no puede modificar esta orden de Compra porque la misma está autorizada. Solo puede modificarla el usuario: " + item.usuarioAutoriza, "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                return;
                            }
                        }
                        indice = dataGridViewDetalleOC.Rows.Add();
                        comboBoxProveed.SelectedValue      = item.proveed_id;
                        comboBoxLugarEntrega.SelectedValue = item.sectorEntrega_id;

                        dataGridViewDetalleOC.Rows[indice].Cells[(int)Col_OCDetalle.DETALLE].Value  = item.detalle;
                        dataGridViewDetalleOC.Rows[indice].Cells[(int)Col_OCDetalle.CANTIDAD].Value = item.cantidad.ToString().Replace(",", ".");
                        dataGridViewDetalleOC.Rows[indice].Cells[(int)Col_OCDetalle.PRECIO].Value   = item.importe.ToString().Replace(",", ".");
                        _tipoProrrateo  = Convert.ToInt16(item.tipoProrrateo);
                        textBoxObs.Text = item.Obs;

                        indice++;
                    }
                    //tipo prorrateo
                    if (_tipoProrrateo == 1)
                    {
                        checkBoxCuotas.Checked  = false;
                        checkBoxEmpresa.Checked = false;
                    }
                    if (_tipoProrrateo == 2)
                    {
                        checkBoxEmpresa.Checked = true;
                        checkBoxCuotas.Checked  = false;
                    }

                    if (_tipoProrrateo == 3)
                    {
                        checkBoxEmpresa.Checked = false;
                        checkBoxCuotas.Checked  = true;
                    }
                    if (_tipoProrrateo == 4)
                    {
                        checkBoxEmpresa.Checked = true;
                        checkBoxCuotas.Checked  = true;
                    }

                    if (_ocDetalle != null)
                    {
                        CalculaImporte();
                        _OrdenCompraModifica = Convert.ToInt32(textBoxNroOC.Text);
                    }
                    else

                    {
                        _OrdenCompraModifica = 0;
                        MessageBox.Show("No existe este Número de orden de compra", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }

                else
                {
                    MessageBox.Show("Debe seleccionar una Empresa", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void toolStripButtonSave_Click(object sender, EventArgs e)
        {
            try
            {
                StaCatalinaEntities _Mod = new StaCatalinaEntities();

                if (comboBoxcodEmp.SelectedIndex > 0 && comboBoxProveed.SelectedIndex > 0)
                {
                    if (dataGridViewMails.Rows.Count > 0)
                    {
                        string  _email  = string.Empty;
                        Boolean _existe = false;
                        for (int i = 0; i < dataGridViewMails.Rows.Count - 1; i++)
                        {
                            //CONCATENO TODOS LOS MAILS CON ;
                            DataGridViewCheckBoxCell cellSelecion = dataGridViewMails.Rows[i].Cells[(int)Col_Mail.INACTIVO] as DataGridViewCheckBoxCell;
                            if (!Convert.ToBoolean(cellSelecion.Value))
                            {
                                if (dataGridViewMails.Rows[i].Cells[(int)Col_Mail.MAIL].Value != string.Empty && dataGridViewMails.Rows[i].Cells[(int)Col_Mail.MAIL].Value != null)
                                {
                                    //ANTES VALIDO EL FORMATO DE MAIL
                                    if (ComprobarFormatoEmail(dataGridViewMails.Rows[i].Cells[(int)Col_Mail.MAIL].Value.ToString()))
                                    {
                                        if (i == 0)
                                        {
                                            _email  = dataGridViewMails.Rows[i].Cells[(int)Col_Mail.MAIL].Value.ToString();
                                            _existe = true;
                                        }
                                        else
                                        {
                                            _email  = _email + ";" + dataGridViewMails.Rows[i].Cells[(int)Col_Mail.MAIL].Value.ToString();
                                            _existe = true;
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show("El Formato de mail no es válido, verifique la dirección ingresada", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                        return;
                                    }
                                }
                            }
                        }

                        if (!_existe)
                        {
                            _email = string.Empty; // ES PORQUE ESTA ELIMINANDO TODOS LOS MAIL DE ESTE PROVEEDOR
                        }

                        _Mod.ActualizaMailProveedor(comboBoxcodEmp.SelectedValue.ToString(), comboBoxProveed.SelectedValue.ToString(), _email);
                        MessageBox.Show("Emails actualizados correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        comboBoxcodEmp.SelectedValue  = Clases.Usuario.EmpresaLogeada.EmpresaIngresada.ToString();
                        comboBoxProveed.SelectedIndex = 0;
                        dataGridViewMails.Rows.Clear();
                    }

                    else
                    {
                        MessageBox.Show("No existen mails para grabar", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }

                else
                {
                    MessageBox.Show("Debe seleccionar una Sede y un Sector", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }


            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void toolStripButtonSave_Click(object sender, EventArgs e)
        {
            try
            {
                int    _cantidaditems  = this.dataGridViewDetalle.Rows.Count;
                int    _cantExcluidos  = 0;
                string _codEmp         = string.Empty;
                Int32  _idReq          = 0;
                Int32  _nroItem        = 0;
                string _motivo         = string.Empty;
                bool   _excluido       = false;
                string _usuarioExcluye = string.Empty;

                StaCatalinaEntities _Mod = new StaCatalinaEntities();

                //VERIFICO SI ESTA ANULANDO ESTE REQUERIMIENTO INTERO
                if (_finaliza)
                {
                    string _codEmpresa = dataGridViewReqCabe.Rows[dataGridViewReqCabe.CurrentRow.Index].Cells[(int)Col_Cabe.CODEMP].Value.ToString();
                    Int32  _reqInt     = Convert.ToInt32(dataGridViewReqCabe.Rows[dataGridViewReqCabe.CurrentRow.Index].Cells[(int)Col_Cabe.REQUERIMIENTO_ID].Value);

                    var _usuarioAutorizo = _Mod.comRequerimientoInterno
                                           .Where(b => b.codEmp == _codEmpresa && b.requerimiento_id == _reqInt)
                                           .FirstOrDefault();

                    if (_usuarioAutorizo.usuarioAutoriza.Trim().ToLower() != Clases.Usuario.UsuarioLogeado.usuario_Logeado.ToString().Trim().ToLower())
                    {
                        MessageBox.Show("Usted no puede finalizar este Requerimiento interno, lo debe hacer el usuario: " + _usuarioAutorizo.usuarioAutoriza, "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else
                    {
                        if (textBoxMotivoFinaliz.Text == string.Empty)
                        {
                            MessageBox.Show("Debe ingresar un motivo de Anulación", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            textBoxMotivoFinaliz.Focus();
                            return;
                        }


                        //finalizo este requerimiento interno

                        string   _motivoAnulacion   = textBoxMotivoFinaliz.Text;
                        string   _usuarioFinaliza   = Clases.Usuario.UsuarioLogeado.usuario_Logeado.ToString();
                        DateTime _fechaFinalizacion = Convert.ToDateTime(DateTime.Now.ToShortDateString());

                        _Mod.FinalizaRequerimientoInterno(_codEmpresa, _reqInt, _motivoAnulacion, _fechaFinalizacion, _usuarioFinaliza);

                        //_Mod.Entry(_reqInterno).State = _reqInterno.codEmp == _codEmpresa && _reqInterno.requerimiento_id == _reqInt ? System.Data.Entity.EntityState.Added : System.Data.Entity.EntityState.Modified;

                        // _Mod.Entry(_reqInterno).State = System.Data.Entity.EntityState.Modified;

                        //_Mod.Entry(_reqInterno).Property(m => m.estado_id).IsModified = true;
                        //_Mod.Entry(_reqInterno).Property(m => m.motivoAnulacion).IsModified = true;
                        //_Mod.Entry(_reqInterno).Property(m => m.usuarioFinaliza).IsModified = true;

                        //_Mod.SaveChanges();
                        MessageBox.Show("Requerimiento Interno finalizado correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        _finaliza                    = false;
                        labelMotivo.Visible          = false;
                        textBoxMotivoFinaliz.Text    = string.Empty;
                        textBoxMotivoFinaliz.Visible = false;

                        TraerRequerimientos(Clases.Usuario.EmpresaLogeada.EmpresaIngresada.ToString(), Convert.ToInt32(comboBoxDepositoDelPedido.SelectedValue), Convert.ToInt32(comboBoxSectorDelPedido.SelectedValue));
                    }



                    return;
                }
                //fin finaliza


                //primero controlo que no esté excluyendo la totalidad de los items
                for (int i = 0; i < this.dataGridViewDetalle.Rows.Count; i++)
                {
                    DataGridViewCheckBoxCell cellSelecion = dataGridViewDetalle.Rows[i].Cells[(int)Col_Detalle.EXCLUIR] as DataGridViewCheckBoxCell;
                    if (Convert.ToBoolean(cellSelecion.Value))
                    {
                        _cantExcluidos++;
                    }
                }

                if (_cantExcluidos == _cantidaditems)
                {
                    MessageBox.Show("No se puede excluir la totalidad de Items de la O.C.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                //FIN CONTROLA CANTIDAD DE ITEMS


                for (int i = 0; i < this.dataGridViewDetalle.Rows.Count; i++)
                {
                    DataGridViewCheckBoxCell cellSelecion = dataGridViewDetalle.Rows[i].Cells[(int)Col_Detalle.EXCLUIR] as DataGridViewCheckBoxCell;


                    _codEmp  = dataGridViewDetalle.Rows[i].Cells[(int)Col_Detalle.CODEMP].Value.ToString();
                    _idReq   = Convert.ToInt32(dataGridViewDetalle.Rows[i].Cells[(int)Col_Detalle.REQUERIMIENTO_ID].Value);
                    _nroItem = Convert.ToInt32(dataGridViewDetalle.Rows[i].Cells[(int)Col_Detalle.NROITEM].Value);

                    if (dataGridViewDetalle.Rows[i].Cells[(int)Col_Detalle.MOTIVO].Value == null)
                    {
                        _motivo = "";
                    }
                    else
                    {
                        _motivo = dataGridViewDetalle.Rows[i].Cells[(int)Col_Detalle.MOTIVO].Value.ToString().ToUpper();
                    }
                    _usuarioExcluye = Clases.Usuario.UsuarioLogeado.usuario_Logeado.ToString();

                    if (Convert.ToBoolean(cellSelecion.Value))
                    {
                        _excluido = true;
                        _cantExcluidos++;
                        _Mod.ExcluyeItemsReqInterno(_codEmp, _idReq, _nroItem, _motivo, _usuarioExcluye, _excluido);
                    }
                    else  //ESTO PORQUE PUEDE VOLVER A TRAS UN ARTICULO EXLUIDO... ES DECIR LO PUEDO INCLUR DE NUEVO
                    {
                        _excluido       = false;
                        _motivo         = "";
                        _usuarioExcluye = "";
                        _Mod.ExcluyeItemsReqInterno(_codEmp, _idReq, _nroItem, _motivo, _usuarioExcluye, _excluido);
                    }
                }


                if (_cantExcluidos > 0)
                {
                    MessageBox.Show("Items excluidos correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    _codEmp         = string.Empty;
                    _idReq          = 0;
                    _nroItem        = 0;
                    _motivo         = string.Empty;
                    _excluido       = false;
                    _usuarioExcluye = string.Empty;
                    this.dataGridViewDetalle.Rows.Clear();
                }

                //vuelvo a traer los requerimientos pendientes
                TraerRequerimientos(Clases.Usuario.EmpresaLogeada.EmpresaIngresada.ToString(), Convert.ToInt32(comboBoxDepositoDelPedido.SelectedValue), Convert.ToInt32(comboBoxSectorDelPedido.SelectedValue));
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #12
0
        private bool EnviarMail(string _empresa, string _path, string Email)
        {
            MailMessage email = new MailMessage();

            //email.To.Add(new MailAddress(Email)); //  ************* MAILS CARGADOS EN BEJERMAN, EN DATOS ADICIONALES DEL PROVEEDOR

            email.To.Add(Email.ToString().Replace(";", ","));
            //ENVIO UNA COPIA A LA PERSONA QUE ESTA AUTORIZANDO, AL USUARIO QUE REALIZÓ LA OC Y AL GRUPO
            StaCatalinaEntities _Mod = new StaCatalinaEntities();
            String _usuOC            = dataGridViewOCCab.Rows[dataGridViewOCCab.CurrentRow.Index].Cells[(int)Col_OCCab.USUARIO].Value.ToString().Trim();

            var _mailUsu = (from U in _Mod.comUsuarioEnviaMail
                            join tbl in _Mod.TBL_Usuarios
                            on U.Id_Usuario equals tbl.Id_Usuario
                            join tbl2 in _Mod.TBL_Usuarios
                            on U.Id_Usuario_EnviaMail equals tbl2.Id_Usuario
                            where tbl.IdentificadorUsuario == _usuOC
                            select new
            {
                MAIL = tbl.Email,               //MAIL DEL USUARIO DE LA OC
                mail_GRUPO = tbl2.Email         //MAIL DEL GRUPO
            }).ToList();

            String _CCMail  = string.Empty;
            bool   _primero = true;

            foreach (var item in _mailUsu)
            {
                //CONCATENO TODOS LOS MAIL A LOS QUE TENGO QUE ENVIAR
                if (_primero)
                {
                    _CCMail  = item.MAIL + "," + item.mail_GRUPO;
                    _primero = false;
                }
                else
                {
                    _CCMail = _CCMail + "," + item.mail_GRUPO;
                }
            }


            if (Clases.Usuario.UsuarioLogeado.Email != string.Empty)
            {
                if (_CCMail != string.Empty)
                {
                    //_CCMail = _CCMail + "," + Clases.Usuario.UsuarioLogeado.Email.ToString();
                    //email.CC.Add(new MailAddress(_CCMail.ToString()));
                    email.CC.Add(_CCMail.ToString());
                }
                else // solo envio mail al que esta autorizando
                {
                    email.CC.Add(new MailAddress(Clases.Usuario.UsuarioLogeado.Email.ToString()));
                }
            }
            email.From       = new MailAddress("*****@*****.**"); // VER SI SE PUEDE UTILIZAR UN GENERICO
            email.Subject    = "Orden de Compra para la Empresa: " + _empresa;
            email.Body       = "******** ORDEN DE COMPRA CLÍNICA SANTA CATALINA ************* ";
            email.IsBodyHtml = true;
            email.Priority   = MailPriority.Normal;
            email.Attachments.Add(new Attachment(_path));
            email.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess;

            SmtpClient smtp = new SmtpClient();

            smtp.Host                  = "smtp.gmail.com";
            smtp.Port                  = 587;
            smtp.EnableSsl             = true;
            smtp.UseDefaultCredentials = false;
            smtp.Credentials           = new NetworkCredential("*****@*****.**", "compras2013");

            string output = null;

            try
            {
                smtp.Send(email);

                email.Dispose();

                //BORRO EL REPORTE... QUE GENERE EN PDF
                File.Delete(_path);

                return(true);
            }
            catch (Exception ex)
            {
                File.Delete(_path);
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            Console.WriteLine(output);
        }