コード例 #1
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (this.dataListadoDetalle.Rows.Count == 0)
            {
                MensajeError("No hay productos en la lista");
            }
            else
            {
                try
                {
                    if (cbAlmacen.SelectedIndex == -1)
                    {
                        MensajeError("Seleccione el almacén de salida");
                    }
                    else if (cbTipoIngreso.SelectedIndex == -1)
                    {
                        MensajeError("Seleccioe el tipo de salida");
                    }
                    else if (this.txtEntregado.Text.Trim() == string.Empty)
                    {
                        MensajeError("Ingrese el nombre al que entregerá los productos");
                    }
                    else
                    {
                        string rpta = "";
                        if (this.isNuevo)
                        {
                            rpta = NMovimientoAlmacen.Insertar(Convert.ToInt32(this.cbAlmacen.SelectedValue.ToString()), Convert.ToInt32(this.cbTipoIngreso.SelectedValue.ToString()), Convert.ToInt32(this.lblIdUsuario.Text), txtEntregado.Text.Trim().ToUpper(), dtFecha.Value, "REGISTRADO", "SALIDA", dtDetalle);
                        }
                        if (rpta.Equals("OK"))
                        {
                            if (this.isNuevo)
                            {
                                this.MensajeOK("Se insertó correctamente");
                            }
                        }
                        else
                        {
                            this.MensajeError(rpta);
                        }

                        this.isNuevo = false;
                        this.Botones();
                        this.Limpiar();
                        this.limpiarDetalle();
                        this.txtCantidad.ReadOnly = true;
                    }
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + ex.StackTrace);
                }
            }
        }
コード例 #2
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (this.dataListadoDetalle.Rows.Count == 0)
            {
                MensajeError("No hay productos en la lista");
            }
            else
            {
                try
                {
                    if (cbAlmacen.SelectedIndex == -1)
                    {
                        MensajeError("Seleccione el almacén de salida");
                    }
                    else if (cbTipoIngreso.SelectedIndex == -1)
                    {
                        MensajeError("Seleccioe el tipo de salida");
                    }
                    else
                    {
                        string rpta = "";
                        if (this.isNuevo)
                        {
                            rpta = NMovimientoAlmacen.Insertar(Convert.ToInt32(this.cbAlmacen.SelectedValue.ToString()), Convert.ToInt32(this.cbTipoIngreso.SelectedValue.ToString()), Convert.ToInt32(this.lblIdUsuario.Text), "", dtFecha.Value, "REGISTRADO", "INGRESO", dtDetalle);
                        }
                        if (rpta.Equals("OK"))
                        {
                            if (this.isNuevo)
                            {
                                for (int i = 0; i < dataListadoDetalle.Rows.Count; i++)
                                {
                                    decimal precioUnitario = Convert.ToDecimal(dataListadoDetalle.Rows[i].Cells["PrecioUnitario"].Value.ToString());
                                    if (precioUnitario > 0)
                                    {
                                        rpta = NProducto.EditarCostoInsumo(Convert.ToInt32(dataListadoDetalle.Rows[i].Cells[0].Value.ToString()), precioUnitario);
                                    }
                                }
                                if (cbCaja.Checked == true)
                                {
                                    rpta = NCaja.Insertar(Convert.ToInt32(this.lblIdUsuario.Text), "1", "EGRESO", Convert.ToDecimal(this.txtTotalPagado.Text), "COMPRA", "EFECTIVO");
                                }
                                this.MensajeOK("Se insertó correctamente");
                                txtTotalPagado.Text = string.Empty;
                            }
                        }
                        else
                        {
                            this.MensajeError(rpta);
                        }

                        this.isNuevo = false;
                        this.Botones();
                        this.Limpiar();
                        this.limpiarDetalle();
                        this.txtCantidad.ReadOnly = true;
                        this.txtMonto.ReadOnly    = true;
                        cbCaja.Enabled            = false;
                    }
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + ex.StackTrace);
                }
            }
        }