Example #1
0
        private void AbrirFormularioAgregar(DataGridViewCellEventArgs row, DataGridView view)
        {
            try
            {
                if (row.RowIndex >= 0)
                {
                    CEOrden orden = new CEOrden
                    {
                        id                   = Convert.ToInt32(view.Rows[row.RowIndex].Cells[0].Value),
                        numero               = view.Rows[row.RowIndex].Cells[1].Value.ToString(),
                        proveedorDocumento   = view.Rows[row.RowIndex].Cells[2].Value.ToString(),
                        proveedorNombreCorto = view.Rows[row.RowIndex].Cells[3].Value.ToString(),
                        fecha                = view.Rows[row.RowIndex].Cells[4].Value.ToString(),
                        anulado              = Convert.ToBoolean(view.Rows[row.RowIndex].Cells[5].Value),
                        observacion          = view.Rows[row.RowIndex].Cells[6].Value.ToString()
                    };

                    Agregar agregarRecogida = new Agregar(orden);
                    Tag = "C";
                    agregarRecogida.TopLevel = false;
                    agregarRecogida.Dock     = DockStyle.None;
                    Controls.Add(agregarRecogida);
                    agregarRecogida.Location = new Point(50, 50);
                    agregarRecogida.BringToFront();
                    agregarRecogida.FormClosed += new FormClosedEventHandler(A_FormClosed);
                    agregarRecogida.Show();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtFile.Text.Trim().Equals("") || tblRecogida.Rows.Count < 2)
                {
                    Exception exception = new Exception("No se encontro el archivo o no hay ningun equipo registrado");
                    throw exception;
                }


                byte[] File   = null;
                Stream stream = openFileDialog.OpenFile();
                using (MemoryStream ms = new MemoryStream())
                {
                    stream.CopyTo(ms);
                    File = ms.ToArray();
                }

                CEOrden orden = new CEOrden
                {
                    fecha = DateSelect.Text,
                    proveedorDocumento = txtNit.Text,
                    numero             = txtNumero.Text,
                    observacion        = txtObservaciones.Text,
                    anulado            = false,
                    archivo            = File
                };


                if (movimientos.AgregarRecogida(orden) > 0)
                {
                    int id = movimientos.MaximoIdRecogida();
                    foreach (CEEquipo equipo in equipos)
                    {
                        orden = new CEOrden
                        {
                            id                = id,
                            equipoCodigo      = equipo.equipoCodigo,
                            equipoDescripcion = equipo.equipoDescripcion,
                            observacion       = equipo.observacion,
                            modelo            = new CEModelo {
                                id = equipo.modelo.id
                            },
                            fecha = DateSelect.Text
                        };

                        movimientos.AgregarRecogidaDetalle(orden);
                    }
                    Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Se presento el siguiente error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #3
0
        public Agregar(CEOrden orden)
        {
            InitializeComponent();

            this.orden = orden;

            movimientos = new CNMovimientos();

            DateSelect.Text = DateTime.Now.ToString("yyyy-MM-dd");
            CargarRecogidas();
        }
Example #4
0
        public Agregar(CEOrden orden)
        {
            InitializeComponent();

            this.orden = orden;

            equipos     = new CNEquipos();
            movimientos = new CNMovimientos();

            DateSelect.Text = DateTime.Now.ToString("yyyy-MM-dd");

            CargarInstalaciones();
        }
        public int AgregarInstalacion(CEOrden orden)
        {
            Config.openConnection(connection);
            SqlCommand command = new SqlCommand("INV.INSTALACIONES", connection);

            command.CommandType = CommandType.StoredProcedure;

            command.Parameters.AddWithValue("@OPERACION", "OI");
            command.Parameters.AddWithValue("@OI_FECHA", orden.fecha);
            command.Parameters.AddWithValue("@PROV_NIT", orden.proveedorDocumento);
            command.Parameters.AddWithValue("@OI_NUMERO", orden.numero);
            command.Parameters.AddWithValue("@OI_OBSERVACIONES", orden.observacion);
            command.Parameters.AddWithValue("@OI_ANULADO", orden.anulado ? "S" : "N");
            command.Parameters.AddWithValue("@OI_DOCUMENTO", orden.archivo);

            int Resultado = command.ExecuteNonQuery();

            Config.closeConnection(connection);
            return(Resultado);
        }
        public int AgregarRecogidaDetalle(CEOrden orden)
        {
            Config.openConnection(connection);
            SqlCommand command = new SqlCommand("INV.RECOGIDAS", connection);

            command.CommandType = CommandType.StoredProcedure;

            command.Parameters.AddWithValue("@OPERACION", "OR");
            command.Parameters.AddWithValue("@OR_ID", orden.id);
            command.Parameters.AddWithValue("@EQ_CODIGO", orden.equipoCodigo);
            command.Parameters.AddWithValue("@EQ_DESCRIPCION", orden.equipoDescripcion);
            command.Parameters.AddWithValue("@EQ_MODELO", orden.modelo.id);
            command.Parameters.AddWithValue("@EQ_SERIAL", orden.equipoSerial);
            command.Parameters.AddWithValue("@EQ_OBSERVACION", orden.observacion);
            command.Parameters.AddWithValue("@OR_FECHA", orden.fecha);

            int Resultado = command.ExecuteNonQuery();

            Config.closeConnection(connection);
            return(Resultado);
        }
        public int AgregarInstalacionDetalle(CEOrden orden)
        {
            Config.openConnection(connection);
            SqlCommand command = new SqlCommand("INV.INSTALACIONES", connection);

            command.CommandType = CommandType.StoredProcedure;

            command.Parameters.AddWithValue("@OPERACION", "OID");
            command.Parameters.AddWithValue("@OI_ID", orden.id);
            command.Parameters.AddWithValue("@EQ_CODIGO", orden.equipoCodigo);
            command.Parameters.AddWithValue("@EQ_DESCRIPCION", orden.equipoDescripcion);
            command.Parameters.AddWithValue("@EQ_MODELO", orden.modelo.id);
            command.Parameters.AddWithValue("@EQ_SERIAL", orden.equipoSerial);
            command.Parameters.AddWithValue("@EQ_OBSERVACION", orden.observacion);
            command.Parameters.AddWithValue("@OI_FECHA", orden.fecha);
            command.Parameters.AddWithValue("@PROV_NIT", orden.proveedorDocumento);

            int Resultado = command.ExecuteNonQuery();

            Config.closeConnection(connection);
            return(Resultado);
        }
Example #8
0
 public int AgregarRecogidaDetalle(CEOrden orden)
 {
     return(movimientos.AgregarRecogidaDetalle(orden));
 }
Example #9
0
 public int AgregarInstalacionDetalle(CEOrden orden)
 {
     return(movimientos.AgregarInstalacionDetalle(orden));
 }
Example #10
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                Exception exception = null;

                if (tblInstalacion.Rows.Count < 2)
                {
                    exception = new Exception("No se registro ningun equipo.");
                    throw exception;
                }

                if (txtFile.Text.Trim().Equals(""))
                {
                    exception = new Exception("Debe disponser del archvio de soporte.");
                    throw exception;
                }
                foreach (DataGridViewRow row in tblInstalacion.Rows)
                {
                    if (Equals(row.Cells[0].Value, null))
                    {
                        exception = new Exception("Código invalido");
                        throw exception;
                    }

                    if (Equals(row.Cells[1].Value, null))
                    {
                        exception = new Exception("Descripción invalido");
                        throw exception;
                    }
                }

                byte[] File   = null;
                Stream stream = openFileDialog.OpenFile();
                using (MemoryStream ms = new MemoryStream())
                {
                    stream.CopyTo(ms);
                    File = ms.ToArray();
                }

                CEOrden instalacion = new CEOrden
                {
                    fecha = DateSelect.Text.ToString(),
                    proveedorDocumento = txtNit.Text,
                    numero             = txtNumero.Text,
                    observacion        = txtObservaciones.Text,
                    anulado            = false,
                    archivo            = File,
                };


                if (movimientos.AgregarInstalacion(instalacion) > 0)
                {
                    instalacion.id = movimientos.MaximoIdInstalacion();

                    foreach (DataGridViewRow row in tblInstalacion.Rows)
                    {
                        instalacion.equipoCodigo      = row.Cells[0].Value.ToString();
                        instalacion.equipoDescripcion = row.Cells[1].Value.ToString();
                        instalacion.observacion       = Equals(row.Cells[5].Value, null) ? "" : row.Cells[5].Value.ToString();
                        instalacion.modelo            = new CEModelo
                        {
                            id = Equals(row.Cells[3].Value, null) ? 0 : Convert.ToInt32(row.Cells[3].Value)
                        };
                        instalacion.equipoSerial = Equals(row.Cells[4].Value, null) ? "" : row.Cells[4].Value.ToString();

                        movimientos.AgregarInstalacionDetalle(instalacion);
                    }

                    Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Se presento el siguiente error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }