protected override void btnGuardar_Click(object sender, EventArgs e)
        {
            int cont = 0;

            foreach (DataGridViewRow row in this.dgvDatos.Rows)
            {
                if (Convert.ToBoolean(row.Cells["X"].Value).Equals(true))
                {
                    cont++;
                }
            }

            if (cont == 0)
            {
                Util.MensajeAdvertencia("Debe seleccionar un registro.", GlobalClass.NombreApp);
                return;
            }

            if (cont > 1)
            {
                Util.MensajeAdvertencia("Debe seleccionar un solo registro.", GlobalClass.NombreApp);
                return;
            }

            this.Sel = new Dictionary <string, object>();
            foreach (DataGridViewRow row in this.dgvDatos.Rows)
            {
                if (Convert.ToBoolean(row.Cells["X"].Value).Equals(true))
                {
                    var detalle = new PartesView()
                    {
                        ParteID       = Util.Entero(row.Cells["ParteID"].Value),
                        NumeroDeParte = row.Cells["NumeroDeParte"].Value.ToString(),
                        Descripcion   = row.Cells["Descripcion"].Value.ToString(),
                        LineaID       = Util.Entero(row.Cells["LineaID"].Value)
                    };

                    Sel.Add("PartesView", detalle);
                    this.Seleccionado = true;
                }
            }

            if (Seleccionado)
            {
                this.Close();
            }
        }
Esempio n. 2
0
        private void btnNinguno_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                foreach (DataGridViewRow row in this.dgvDatos.Rows)
                {
                    DataGridViewCheckBoxCell cb = (DataGridViewCheckBoxCell)row.Cells["X"];
                    if (cb.Value == null)
                    {
                        if (Util.Decimal(row.Cells["Existencia"].Value) > 0)
                        {
                            cb.Value = true;
                            //
                            int parteId = Util.Entero(row.Cells["ParteID"].Value);
                            string numeroParte = Util.Cadena(row.Cells["NumeroParte"].Value);
                            string descripcion = Util.Cadena(row.Cells["NombreParte"].Value);

                            var existencia = Util.Decimal(row.Cells["Existencia"].Value);
                            var sugerencia = Util.Decimal(row.Cells["Sugerencia"].Value);

                            if (sugerencia > existencia)
                                sugerencia = existencia;

                            if (this.validaExistencia(parteId, 1))
                            {
                                var rowIndex = UtilLocal.findRowIndex(this.dgvTraspasos, "ParteID", parteId.ToString());
                                if (rowIndex >= 0) return;

                                var parte = new PartesView()
                                {
                                    ParteID = parteId,
                                    NumeroDeParte = numeroParte,
                                    Descripcion = descripcion,
                                    Marca = "",
                                    Linea = "",
                                    ParteEstatusID = 1,
                                    LineaID = 0,
                                    Busqueda = sugerencia.ToString()
                                };

                                this.agregarDetalleTraspasos(parte);
                            }
                            //
                        }
                        else
                        {
                            cb.Value = false;
                        }
                    }
                }
                this.Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                this.Cursor = Cursors.Default;
                Util.MensajeError(ex.Message, GlobalClass.NombreApp);
            }
        }
Esempio n. 3
0
        private void agregarDetalleTraspasos(PartesView parte)
        {
            DataRow row;
            try
            {
                if (parte != null)
                {
                    // Se valida si ya existe un traspaso de la misma parte, para mostrar la advertencia
                    if (Datos.Exists<MovimientoInventarioDetalleView>(c => c.TipoOperacionID == Cat.TiposDeOperacionMovimientos.Traspaso && c.ParteID == parte.ParteID
                        && !c.FechaRecepcion.HasValue && c.SucursalDestinoID == GlobalClass.SucursalID))
                    {
                        if (UtilLocal.MensajePregunta("Ya existe un Traspaso en curso para esta Parte. ¿Aún así deseas continuar?") != DialogResult.Yes)
                            return;
                    }

                    var proveedorid = Datos.GetEntity<Parte>(p => p.ParteID == parte.ParteID);
                    var proveedor = Datos.GetEntity<Proveedor>(pr=>pr.ProveedorID==proveedorid.ProveedorID);
                    row = dtDetalleTraspasos.NewRow();
                    row["ParteID"] = parte.ParteID;
                    row["Numero Parte"] = parte.NumeroDeParte;
                    row["Descripcion"] = parte.Descripcion;
                    row["Cantidad"] = parte.Busqueda;
                    row["Proveedor"] = proveedor.NombreProveedor;
                    dtDetalleTraspasos.Rows.Add(row);
                }
            }
            catch (Exception ex)
            {
                Util.MensajeError(ex.Message, GlobalClass.NombreApp);
            }
        }
Esempio n. 4
0
        private void dgvDatos_CurrentCellDirtyStateChanged(object sender, EventArgs e)
        {
            if (null == this.dgvDatos.CurrentRow)
                return;
            try
            {
                if (this.dgvDatos.IsCurrentCellDirty)
                {
                    this.dgvDatos.CommitEdit(DataGridViewDataErrorContexts.Commit);
                    dgvDatos.EndEdit();
                    return;
                }

                var cb = (DataGridViewCheckBoxCell)dgvDatos.CurrentRow.Cells["X"];
                if (cb.Value != null)
                {
                    if (Util.Logico(cb.Value))
                    {
                        int parteId = Util.Entero(this.dgvDatos.CurrentRow.Cells["ParteID"].Value);
                        string numeroParte = Util.Cadena(this.dgvDatos.CurrentRow.Cells["NumeroParte"].Value);
                        string descripcion = Util.Cadena(this.dgvDatos.CurrentRow.Cells["NombreParte"].Value);

                        var existencia = Util.Decimal(this.dgvDatos.CurrentRow.Cells["Existencia"].Value);
                        var sugerencia = Util.Decimal(this.dgvDatos.CurrentRow.Cells["Sugerencia"].Value);

                        if (sugerencia > existencia)
                            sugerencia = existencia;

                        if (this.validaExistencia(parteId, 1))
                        {
                            var rowIndex = UtilLocal.findRowIndex(this.dgvTraspasos, "ParteID", parteId.ToString());
                            if (rowIndex >= 0) return;

                            var parte = new PartesView()
                            {
                                ParteID = parteId,
                                NumeroDeParte = numeroParte,
                                Descripcion = descripcion,
                                Marca = "",
                                Linea = "",
                                ParteEstatusID = 1,
                                LineaID = 0,
                                Busqueda = sugerencia.ToString()
                            };

                            // Se verifica si ya hay un traspaso para la parte indicada
                            int iSucDestID = Util.Entero(this.cboUbicacionDestino.SelectedValue);
                            if (Datos.Exists<MovimientoInventarioDetalleView>(c => c.TipoOperacionID == Cat.TiposDeOperacionMovimientos.Traspaso && c.SucursalDestinoID == iSucDestID
                                && !c.FechaRecepcion.HasValue && c.ParteID == parteId))
                            {
                                if (UtilLocal.MensajePregunta("El artículo seleccionado ya tiene un traspaso pendiente. ¿Aún así deseas continuar?") != DialogResult.Yes)
                                    return;
                            }

                            this.agregarDetalleTraspasos(parte);
                        }
                        else
                        {
                            Util.MensajeError("No hay existencia suficiente para realizar la operación", GlobalClass.NombreApp);
                            cb.Value = cb.FalseValue;
                        }
                    }
                }
                //dgvDatos.EndEdit();
            }
            catch (Exception ex)
            {
                Util.MensajeError(ex.Message, GlobalClass.NombreApp);
            }
        }
        protected override void btnGuardar_Click(object sender, EventArgs e)
        {
            int cont = 0;
            foreach (DataGridViewRow row in this.dgvDatos.Rows)
            if (Convert.ToBoolean(row.Cells["X"].Value).Equals(true))
                    cont++;

            if (cont == 0)
            {
                Util.MensajeAdvertencia("Debe seleccionar un registro.", GlobalClass.NombreApp);
                return;
            }

            if (cont > 1)
            {
                Util.MensajeAdvertencia("Debe seleccionar un solo registro.", GlobalClass.NombreApp);
                return;
            }

            this.Sel = new Dictionary<string, object>();
            foreach (DataGridViewRow row in this.dgvDatos.Rows)
            {
                if (Convert.ToBoolean(row.Cells["X"].Value).Equals(true))
                {
                    var detalle = new PartesView()
                    {
                        ParteID = Util.Entero(row.Cells["ParteID"].Value),
                        NumeroDeParte = row.Cells["NumeroDeParte"].Value.ToString(),
                        Descripcion = row.Cells["Descripcion"].Value.ToString(),
                        LineaID = Util.Entero(row.Cells["LineaID"].Value)
                    };

                    Sel.Add("PartesView", detalle);
                    this.Seleccionado = true;
                }
            }

            if (Seleccionado)
                this.Close();
        }