コード例 #1
0
        public frmPedidoPendienteDetalles(Pedidos owner)
        {
            _owner = owner;
            String fecha_requerido = "";

            InitializeComponent();

            if (String.IsNullOrWhiteSpace(_owner.ObtenerSeleccionPedidos().Cells["REQUERIDO"].Value.ToString()))
            {
                fecha_requerido = null;
            }
            else
            {
                fecha_requerido = Convert.ToDateTime(_owner.ObtenerSeleccionPedidos().Cells["REQUERIDO"].Value).ToString("dd/MM/yyyy");
            }

            this.labelNumeroPedido.Text           = _owner.ObtenerSeleccionPedidos().Cells["CÓDIGO"].Value.ToString();
            this.textBoxCliente.Text              = _owner.ObtenerSeleccionPedidos().Cells["CLIENTE"].Value.ToString();
            this.textBoxTransporte.Text           = _owner.ObtenerSeleccionPedidos().Cells["TRANSPORTE"].Value.ToString();
            this.textBoxEmpleado.Text             = _owner.ObtenerSeleccionPedidos().Cells["RESPONSABLE"].Value.ToString();
            this.textBoxFechaOrdenado.Text        = Convert.ToDateTime(_owner.ObtenerSeleccionPedidos().Cells["ORDENADO"].Value).ToString("dd/MM/yyyy");
            this.textBoxFechaRequerido.Text       = fecha_requerido;
            this.textBoxCostoEnvio.Text           = Convert.ToDecimal(_owner.ObtenerSeleccionPedidos().Cells["COSTO DE ENVÍO"].Value).ToString("0.00#");
            this.dataGridViewProductos.DataSource = NPedidoDetalles.MostrarPedidoDetalles(Convert.ToInt32(_owner.ObtenerSeleccionPedidos().Cells[1].Value));
            this.dataGridViewProductos.Columns[4].DefaultCellStyle.Format    = "0.00# '$'";
            this.dataGridViewProductos.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            this.dataGridViewProductos.Columns[5].DefaultCellStyle.Format    = "0.00# '%'";
            this.dataGridViewProductos.Columns[5].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
        }
        public FrmEditarPedidoEntregado(Pedidos owner)
        {
            InitializeComponent();
            this._owner = owner;

            CargarClientes();
            CargarTransportistas();
            CargarEmpleados();
            CargarProductos();

            this.labelNumeroPedido.Text            = Convert.ToString(_owner.ObtenerSeleccionPedidos().Cells["CÓDIGO"].Value);
            this.comboBoxClientes.Text             = Convert.ToString(_owner.ObtenerSeleccionPedidos().Cells["CLIENTE"].Value);
            this.comboBoxTransportes.Text          = Convert.ToString(_owner.ObtenerSeleccionPedidos().Cells["TRANSPORTE"].Value);
            this.comboBoxEmpleados.Text            = Convert.ToString(_owner.ObtenerSeleccionPedidos().Cells["RESPONSABLE"].Value);
            this.dateTimePickerFechaOrdenado.Text  = Convert.ToDateTime(_owner.ObtenerSeleccionPedidos().Cells["ORDENADO"].Value).ToString("dd/MM/yyyy");
            this.dateTimePickerFechaEntregado.Text = Convert.ToDateTime(_owner.ObtenerSeleccionPedidos().Cells["ENTREGADO"].Value).ToString("dd/MM/yyyy");
            this.textBoxCostoEnvio.Text            = Convert.ToDecimal(_owner.ObtenerSeleccionPedidos().Cells["COSTO DE ENVÍO"].Value).ToString("0.00#");
            //Creamos otra grilla porque no podemos agregar filas a una grilla binded por un data source
            this.dataGridViewOrigen.Hide();
            this.dataGridViewOrigen.DataSource = NPedidoDetalles.MostrarPedidoDetalles(Convert.ToInt32(_owner.ObtenerSeleccionPedidos().Cells[1].Value));

            for (int fila = 0; fila < (this.dataGridViewOrigen.Rows.Count - 1); fila++)
            {
                this.dataGridViewProductos.Rows.Add("", Convert.ToString(this.dataGridViewOrigen.Rows[fila].Cells["PRODUCTO"].Value),
                                                    Convert.ToInt32(this.dataGridViewOrigen.Rows[fila].Cells["CANT."].Value),
                                                    Convert.ToDecimal(this.dataGridViewOrigen.Rows[fila].Cells["PRECIO"].Value),
                                                    Convert.ToDecimal(this.dataGridViewOrigen.Rows[fila].Cells["DESC."].Value));
            }

            this.dataGridViewProductos.Columns[3].DefaultCellStyle.Format    = "0.00# '$'";
            this.dataGridViewProductos.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            this.dataGridViewProductos.Columns[4].DefaultCellStyle.Format    = "0.00# '%'";
            this.dataGridViewProductos.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
        }
        private void buttonGuardar_Click(object sender, EventArgs e)
        {
            String mensaje = "";

            try
            {
                if (this.textBoxCostoEnvio.Text == String.Empty)
                {
                    this.textBoxCostoEnvio.Text = "0";
                }

                if (this.dataGridViewProductos.Rows.Count > 0)
                {
                    mensaje = NPedidos.Editar(Convert.ToInt32(_owner.ObtenerSeleccionPedidos().Cells[1].Value), this.comboBoxClientes.Text, this.comboBoxTransportes.Text,
                                              this.comboBoxEmpleados.Text, this.dateTimePickerFechaOrdenado.Text, null,
                                              this.dateTimePickerFechaEntregado.Text, Convert.ToDecimal(this.textBoxCostoEnvio.Text));

                    if (mensaje == "Y")
                    {
                        for (int fila = 0; fila < dataGridViewProductos.Rows.Count; fila++)
                        {
                            mensaje = NPedidoDetalles.Editar(Convert.ToInt32(_owner.ObtenerSeleccionPedidos().Cells[1].Value),
                                                             dataGridViewProductos.Rows[fila].Cells["producto"].Value.ToString(),
                                                             Convert.ToInt32(dataGridViewProductos.Rows[fila].Cells["cantidad"].Value.ToString()),
                                                             Convert.ToDecimal(dataGridViewProductos.Rows[fila].Cells["precio"].Value.ToString().Replace("$", "")),
                                                             Convert.ToDecimal(dataGridViewProductos.Rows[fila].Cells["descuento"].Value.ToString().Replace("%", "")));
                        }

                        if (mensaje == "Y")
                        {
                            this._owner.Mensaje(String.Format("El Pedido {0} para {1} ha sido EDITADO",
                                                              this._owner.ObtenerSeleccionPedidos().Cells["CÓDIGO"].Value,
                                                              this.comboBoxClientes.Text));
                            this._owner.Refrescar();
                            this.Close();
                        }
                        else
                        {
                            MensajeError(mensaje);
                        }
                    }

                    else
                    {
                        MensajeError(mensaje);
                    }
                }
                else
                {
                    MensajeError("Debes añadir algún producto al pedido");
                }
            }
            catch (Exception ex)
            {
                MensajeError(mensaje + ex.Message);
            }
        }
コード例 #4
0
        public FrmEditarPedidoPendiente(Pedidos owner)
        {
            InitializeComponent();

            try
            {
                this._owner = owner;

                CargarClientes();
                CargarTransportistas();
                CargarEmpleados();
                CargarProductos();

                this.labelNumeroPedido.Text            = Convert.ToString(_owner.ObtenerSeleccionPedidos().Cells["CÓDIGO"].Value);
                this.comboBoxClientes.Text             = Convert.ToString(_owner.ObtenerSeleccionPedidos().Cells["CLIENTE"].Value);
                this.comboBoxTransportes.Text          = Convert.ToString(_owner.ObtenerSeleccionPedidos().Cells["TRANSPORTE"].Value);
                this.comboBoxEmpleados.Text            = Convert.ToString(_owner.ObtenerSeleccionPedidos().Cells["RESPONSABLE"].Value);
                this.dateTimePickerFechaOrdenado.Value = Convert.ToDateTime(_owner.ObtenerSeleccionPedidos().Cells["ORDENADO"].Value);
                this.textBoxCostoEnvio.Text            = Convert.ToDecimal(_owner.ObtenerSeleccionPedidos().Cells["COSTO DE ENVÍO"].Value).ToString("0.00#");

                if (String.IsNullOrWhiteSpace(_owner.ObtenerSeleccionPedidos().Cells["REQUERIDO"].Value.ToString()))
                {
                    this.checkBoxSinFecha.Checked = true;
                }

                else
                {
                    this.checkBoxSinFecha.Checked           = false;
                    this.dateTimePickerFechaRequerido.Value = Convert.ToDateTime(_owner.ObtenerSeleccionPedidos().Cells["REQUERIDO"].Value);
                }

                //Creamos otra grilla porque no podemos agregar filas a una grilla binded por un data source
                this.dataGridViewOrigen.Hide();
                this.dataGridViewOrigen.DataSource = NPedidoDetalles.MostrarPedidoDetalles(Convert.ToInt32(_owner.ObtenerSeleccionPedidos().Cells[1].Value));

                for (int fila = 0; fila < (this.dataGridViewOrigen.Rows.Count - 1); fila++)
                {
                    this.dataGridViewProductos.Rows.Add("", Convert.ToString(this.dataGridViewOrigen.Rows[fila].Cells["PRODUCTO"].Value),
                                                        Convert.ToInt32(this.dataGridViewOrigen.Rows[fila].Cells["CANT."].Value),
                                                        Convert.ToDecimal(this.dataGridViewOrigen.Rows[fila].Cells["PRECIO"].Value),
                                                        Convert.ToDecimal(this.dataGridViewOrigen.Rows[fila].Cells["DESC."].Value));
                }

                this.dataGridViewProductos.Columns[3].DefaultCellStyle.Format    = "0.00# '$'";
                this.dataGridViewProductos.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                this.dataGridViewProductos.Columns[4].DefaultCellStyle.Format    = "0.00# '%'";
                this.dataGridViewProductos.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            }

            catch (Exception ex)
            {
                MensajeError("Datos incompletos. " + ex.Message);
                this._owner.Refrescar();
            }
        }
        public FrmPedidoEntregadoDetalles(Pedidos owner)
        {
            _owner = owner;

            InitializeComponent();

            this.labelNumeroPedido.Text           = _owner.ObtenerSeleccionPedidos().Cells["CÓDIGO"].Value.ToString();
            this.textBoxCliente.Text              = _owner.ObtenerSeleccionPedidos().Cells["CLIENTE"].Value.ToString();
            this.textBoxTransporte.Text           = _owner.ObtenerSeleccionPedidos().Cells["TRANSPORTE"].Value.ToString();
            this.textBoxEmpleado.Text             = _owner.ObtenerSeleccionPedidos().Cells["RESPONSABLE"].Value.ToString();
            this.textBoxFechaOrdenado.Text        = Convert.ToDateTime(_owner.ObtenerSeleccionPedidos().Cells["ORDENADO"].Value).ToString("dd/MM/yyyy");
            this.textBoxFechaEntregado.Text       = Convert.ToDateTime(_owner.ObtenerSeleccionPedidos().Cells["ENTREGADO"].Value).ToString("dd/MM/yyyy");;
            this.textBoxCostoEnvio.Text           = Convert.ToDecimal(_owner.ObtenerSeleccionPedidos().Cells["COSTO DE ENVÍO"].Value).ToString("0.00#");
            this.dataGridViewProductos.DataSource = NPedidoDetalles.MostrarPedidoDetalles(Convert.ToInt32(_owner.ObtenerSeleccionPedidos().Cells[1].Value));
            this.dataGridViewProductos.Columns[4].DefaultCellStyle.Format    = "0.00# '$'";
            this.dataGridViewProductos.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            this.dataGridViewProductos.Columns[5].DefaultCellStyle.Format    = "0.00# '%'";
            this.dataGridViewProductos.Columns[5].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
        }
コード例 #6
0
        private void buttonGuardar_Click(object sender, EventArgs e)
        {
            String mensaje         = "";
            String fecha_requerido = "";

            try
            {
                if (this.textBoxCostoEnvio.Text == String.Empty)
                {
                    this.textBoxCostoEnvio.Text = "0";
                }

                if (this.checkBoxSinFecha.Checked)
                {
                    fecha_requerido = null;
                }
                else
                {
                    fecha_requerido = this.dateTimePickerFechaRequerido.Value.ToString("dd/MM/yyyy");
                }

                if (this.dataGridViewProductos.Rows.Count > 0)
                {
                    mensaje = NPedidos.Insertar(this.comboBoxClientes.Text, this.comboBoxTransportes.Text,
                                                this.comboBoxEmpleados.Text, this.dateTimePickerFechaOrdenado.Value.ToString("dd/MM/yyyy"),
                                                fecha_requerido, Convert.ToDecimal(this.textBoxCostoEnvio.Text));

                    if (mensaje == "Y")
                    {
                        for (int fila = 0; fila < dataGridViewProductos.Rows.Count; fila++)
                        {
                            mensaje = NPedidoDetalles.Insertar(dataGridViewProductos.Rows[fila].Cells["producto"].Value.ToString(),
                                                               Convert.ToInt32(dataGridViewProductos.Rows[fila].Cells["cantidad"].Value.ToString()),
                                                               Convert.ToDecimal(dataGridViewProductos.Rows[fila].Cells["precio"].Value.ToString().Replace("$", "")),
                                                               Convert.ToDecimal(dataGridViewProductos.Rows[fila].Cells["descuento"].Value.ToString().Replace("%", "")));
                        }
                        if (mensaje == "Y")
                        {
                            this._owner.Mensaje(String.Format("El Pedido para {0} ha sido AGREGADO",
                                                              this.comboBoxClientes.Text));
                            this._owner.Refrescar();
                            this.Close();
                        }
                        else
                        {
                            MensajeError(String.Format("El Pedido para {0} ha sido agregado pero ocurrió un problema al agregar los productos. " + mensaje,
                                                       this.comboBoxClientes.Text));
                        }
                    }
                    else
                    {
                        MensajeError(mensaje);
                    }
                }
                else
                {
                    MensajeError("Debes añadir algún producto al pedido");
                }
            }
            catch (Exception ex)
            {
                MensajeError(ex.Message);
            }
        }