示例#1
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         string rpta = "";
         if (this.txtIdProveedor.Text == string.Empty || this.txtFactura.Text == string.Empty || this.txtIva.Text == string.Empty || this.txtCorrelativo.Text == string.Empty)
         {
             MensajeError("Falta el Nombre");
             errorProvider1.SetError(txtIdProveedor, "Ingrese el Nombre");
         }
         else
         {
             if (this.IsNuevo)
             {
                 rpta = NCompra.Insertar(Id_Trabajador, Convert.ToInt32(this.txtIdProveedor.Text), this.dateTimePicker2.Value, Convert.ToInt32(this.txtFactura.Text), Convert.ToDecimal(this.txtIva.Text), Convert.ToInt32(this.txtCorrelativo.Text), "EMITIDO", dtDetalles);
             }
             else
             {
                 MensajeError("No es nuevo");
             }
             if (rpta.Equals("Ok"))
             {
                 if (this.IsNuevo)
                 {
                     MensajeOK("Guardado Correctamente");
                 }
             }
             else
             {
                 MensajeError(rpta);
             }
             this.IsNuevo = false;
             this.Mostrar();
             this.Botones();
             this.Limpiar();
             this.LimpiarDetalles();
             this.Habilitar(false);
         }
     }
     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
                {
                    string  rpta = "";
                    string  igv = "";
                    string  formaPago = "";
                    string  estado = "";
                    decimal adelanto = 00.00m, dcto = 00.00m, saldo = 00.00m;

                    if (this.txtIdProveedor.Text == string.Empty)
                    {
                        MensajeError("Seleccione un proveedor");
                        errorIcono.SetError(txtProveedor, "Seleccione un valor");
                    }
                    else if (this.txtCorrelativo.Text.Trim() == string.Empty)
                    {
                        MensajeError("Ingrese el número documento");
                        errorIcono.SetError(txtCorrelativo, "Ingrese un valor");
                    }

                    else if (this.txtIgv.Text.Trim() == string.Empty && this.cbTipoComprobante.SelectedItem.ToString().Equals("FACTURA"))
                    {
                        MensajeError("Ingrese el IGV");
                        errorIcono.SetError(txtIgv, "Ingrese un valor");
                    }

                    else
                    {
                        if (this.isNuevo)
                        {
                            if (this.cbTipoComprobante.SelectedItem.ToString().Equals("FACTURA"))
                            {
                                igv = this.txtIgv.Text.Trim();
                            }
                            else if (!this.cbTipoComprobante.SelectedItem.ToString().Equals("FACTURA"))
                            {
                                igv = "00.00";
                            }
                            if (cbFormaPago.SelectedIndex == 0)
                            {
                                formaPago = "CREDITO";
                                estado    = "CREDITO-PENDIENTE";
                            }
                            else if (cbFormaPago.SelectedIndex == 1)
                            {
                                formaPago = "EFECTIVO";
                                estado    = "CANCELADO";
                            }

                            if (txtAdelanto.Text.Trim().Length == 0)
                            {
                                adelanto = 00.00m;
                            }
                            else
                            {
                                adelanto = Convert.ToDecimal(txtAdelanto.Text.Trim());
                            }

                            if (txtDcto.Text.Trim().Length == 0)
                            {
                                dcto = 00.00m;
                            }
                            else
                            {
                                dcto = Convert.ToDecimal(txtDcto.Text.Trim());
                            }
                            saldo = Convert.ToDecimal(txtTotalPagado.Text) - dcto - adelanto;
                            rpta  = NCompra.Insertar(Convert.ToInt32(this.lblIdUsuario.Text), Convert.ToInt32(this.txtIdProveedor.Text), dtFecha.Value, cbTipoComprobante.Text, "", this.txtCorrelativo.Text,
                                                     Convert.ToDecimal(igv), formaPago, "SOLES", estado,
                                                     Convert.ToDecimal(this.txtTotalPagado.Text), dtDetalle, adelanto, dcto, 00.00m, 00.00m, 00.00m, 00.00m, saldo, 00.00m);
                        }
                        if (rpta.Equals("OK"))
                        {
                            if (this.isNuevo)
                            {
                                if (txtAdelanto.Text.Trim().Length == 0)
                                {
                                    adelanto = 00.00m;
                                }
                                else
                                {
                                    adelanto = Convert.ToDecimal(txtAdelanto.Text.Trim());
                                }

                                if (cbCaja.Checked == true && formaPago == "EFECTIVO")
                                {
                                    rpta = NCaja.Insertar(Convert.ToInt32(this.lblIdUsuario.Text), "1", "EGRESO", Convert.ToDecimal(this.txtTotalPagado.Text), "COMPRA", "EFECTIVO");
                                }
                                else if (cbCaja.Checked == true && formaPago == "CREDITO" && txtAdelanto.Text.Trim().Length > 0)
                                {
                                    rpta = NCaja.Insertar(Convert.ToInt32(this.lblIdUsuario.Text), "1", "EGRESO", adelanto, "COMPRA", "EFECTIVO");
                                }
                                else if (cbCaja.Checked == true && formaPago == "CREDITO" && txtAdelanto.Text.Trim().Length == 0)
                                {
                                }
                                this.MensajeOK("Se insertó correctamente");
                            }
                        }
                        else
                        {
                            this.MensajeError(rpta);
                        }

                        this.isNuevo = false;
                        this.Botones();
                        this.Limpiar();
                        this.limpiarDetalle();
                        this.txtCantidad.ReadOnly = true;
                        subTotal    = 0;
                        totalPagado = 0;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + ex.StackTrace);
                }
            }
        }
示例#3
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (this.dataListadoDetalle.Rows.Count == 0)
            {
                MensajeError("No hay productos en la lista");
            }
            else
            {
                try
                {
                    string rpta = "";
                    string igv  = "";

                    if (this.txtIdProveedor.Text == string.Empty)
                    {
                        MensajeError("Seleccione un proveedor");
                        errorIcono.SetError(txtProveedor, "Seleccione un valor");
                    }

                    else if (this.txtSerie.Text.Trim() == string.Empty)
                    {
                        MensajeError("Ingrese el número de serie");
                        errorIcono.SetError(txtSerie, "Ingrese un valor");
                    }
                    else if (this.txtCorrelativo.Text.Trim() == string.Empty)
                    {
                        MensajeError("Ingrese el número documento");
                        errorIcono.SetError(txtCorrelativo, "Ingrese un valor");
                    }

                    else if (this.txtIgv.Text.Trim() == string.Empty && this.cbTipoComprobante.SelectedItem.ToString().Equals("FACTURA"))
                    {
                        MensajeError("Ingrese el IGV");
                        errorIcono.SetError(txtIgv, "Ingrese un valor");
                    }

                    else
                    {
                        if (this.isNuevo)
                        {
                            if (this.cbTipoComprobante.SelectedItem.ToString().Equals("FACTURA"))
                            {
                                igv = this.txtIgv.Text.Trim();
                            }
                            else if (!this.cbTipoComprobante.SelectedItem.ToString().Equals("FACTURA"))
                            {
                                igv = "00.00";
                            }

                            rpta = NCompra.Insertar(Convert.ToInt32(this.lblIdUsuario.Text), Convert.ToInt32(this.txtIdProveedor.Text), dtFecha.Value, cbTipoComprobante.Text, this.txtSerie.Text, this.txtCorrelativo.Text,
                                                    Convert.ToDecimal(igv), this.cbFormaPago.SelectedItem.ToString(), this.cbMoneda.SelectedItem.ToString(), "EMITIDO",
                                                    Convert.ToDecimal(this.txtTotalPagado.Text), dtDetalle);
                        }
                        if (rpta.Equals("OK"))
                        {
                            if (this.isNuevo)
                            {
                                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");
                            }
                        }
                        else
                        {
                            this.MensajeError(rpta);
                        }

                        this.isNuevo = false;
                        this.Botones();
                        this.Limpiar();
                        this.limpiarDetalle();
                        this.txtCantidad.ReadOnly = true;
                        subTotal    = 0;
                        totalPagado = 0;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + ex.StackTrace);
                }
            }
        }