コード例 #1
0
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            String cfecLetra , ctipago;
            cfecLetra = txtFecha.Text;
            int nPrvCod = Convert.ToInt32(hdcodper.Value);
            if (rbtdias.Checked)
                ctipago = "D";
            else
                ctipago = "L";
            int cuotas = int.Parse(txtNumCuotas.Text);
            int icodigo, idetcodigo;
            Double monto_total = Double.Parse(lbpago.Text);
            Double monto_nota = Double.Parse(lbresta.Text);
            String moneda;
            moneda = ddlMoneda_new.SelectedValue;
            try
            {
                clsLetra _Letra = new clsLetra();
                letra obj = new letra();
                icodigo = Convert.ToInt32(_Letra.MaxOpeCod() + 1);
                obj.icodigo = icodigo;
                obj.itotcuota = cuotas;
                obj.nmontocuota = Convert.ToDecimal(monto_total);
                obj.cmoneda = moneda;
                obj.nintpag = Convert.ToDecimal(0.00);
                obj.iestado = "1";
                obj.dfeccreacion = Convert.ToDateTime(cfecLetra);
                obj.dfecmod = DateTime.Today;
                obj.ctippago = ctipago;
                obj.nmntnota = Convert.ToDecimal(monto_nota);
                _Letra.fnletraInsertar(obj);
                clsdetletra _detletra = new clsdetletra();

                foreach (GridViewRow row in dgvcuotas.Rows)
                {
                    det_letra _detobj = new det_letra();
                    _detobj.icodletra = icodigo;
                    _detobj.inumletra = Convert.ToInt32(row.Cells[0].Text);
                    TextBox num_let = row.FindControl("num_let") as TextBox;
                    _detobj.cnumletra = num_let.Text;
                    TextBox ccodletra = row.FindControl("cod_unic") as TextBox;
                    _detobj.ccodletra = ccodletra.Text;
                    TextBox monto = row.FindControl("monto") as TextBox;
                    _detobj.nmonto = Convert.ToDecimal(monto.Text);
                    _detobj.cestado = "1";
                    _detobj.ninteres = Convert.ToDecimal(0.00);
                    TextBox txtFecVen = row.FindControl("txtFecVen") as TextBox;
                    _detobj.dfecvenc = Convert.ToDateTime(txtFecVen.Text);
                    _detobj.dfecmod = DateTime.Today;
                    idetcodigo = Convert.ToInt32(_detletra.Maxdetletra_cod()) + 1;
                    _detobj.idetletra = idetcodigo;
                    _detletra.fndet_letraInsertar(_detobj);
                }
                clsDocumenOperacion _docobj = new clsDocumenOperacion();
                DocumenOperacion _docope = new DocumenOperacion();
                Int64 cod_fact;
                foreach (GridViewRow row in dgvListFact.Rows)
                {

                    CheckBox check = row.FindControl("CheckBox1") as CheckBox;
                    if (check.Checked)
                    {
                        cod_fact = Convert.ToInt64(row.Cells[2].Text);
                        //_docope = _docobj.GetListOperaciones(cod_fact );
                        _docope = _docobj.GetDocumenOperaciona(cod_fact);

                        _docope.icodletra = icodigo;
                        _docobj.fnDocOpeUpdate(_docope);
                    }
                }
                Int32 cod_not;
                clsOpeNotas _formnot = new clsOpeNotas();
                Notas _docopenot = new Notas();
                rel_notfactura _relacion = new rel_notfactura();
                clsrel_notfactura _formrel = new clsrel_notfactura();
                dgvNotas.Columns[3].Visible = true;
                dgvNotas.Columns[5].Visible = true;
                foreach (GridViewRow row in dgvNotas.Rows)
                {

                    CheckBox check = row.FindControl("grdchknota") as CheckBox;
                    if (check.Checked)
                    {
                        cod_not = Convert.ToInt32(row.Cells[5].Text);
                        //clsOpeNotas
                        _docopenot = _formnot.GetNota(cod_not);
                        _docopenot.cestadoNota = "V";
                        _docopenot.nmntutilizado = _docopenot.nmontoNota;
                        _formnot.fnNotaUpdate(_docopenot);

                        _relacion.idtpcod = icodigo;
                        _relacion.inota = cod_not;
                        _relacion.nmonto = _docopenot.nmontoNota;
                        _relacion.dfecmod = DateTime.Today;
                        //_relacion .iusrcrc
                        _relacion.irelnotfac = Convert.ToInt32(_formrel.MaxOpeCod()) + 1;
                        _formrel.fnNotaInsert(_relacion);
                    }
                }
                dgvNotas.Columns[3].Visible = false;
                dgvNotas.Columns[5].Visible = false;
                IniciarCampos();

                obj = _Letra.GetLetra(icodigo);
                obj.iestado = "1";
                _Letra.fnletraupdate(obj);
                pnBusqueda.Visible = true;
                pnNuevo.Visible = false;
                IniciarCampos();
                btnProcesar_Click(sender, e);
            }
            catch (Exception ex)
            {
                MessageBox("Error Interno: " + ex.Message);
            }
        }
コード例 #2
0
 protected void btnImprimir_Click(object sender, EventArgs e)
 {
     clsDocumenOperacion lstDocumenOpe = new clsDocumenOperacion();
     int nDopCod = 0;
     try
     {
         nDopCod = int.Parse(lbldopCod.Value);
         lstDocumenOpe.ActualizarImpresion(nDopCod);
     }
     catch (Exception ex)
     {
         MessageBox(ex.Message);
     }
 }
コード例 #3
0
        protected void btnNuevo_Click(object sender, EventArgs e)
        {
            int nMainTipo = 0;
            try
            {
                clsDocumenOperacion lstDocumentos = new clsDocumenOperacion();

                if (((Button)sender).ToolTip == btnNuevo.ToolTip)
                {
                    HabilitarCampos(true);
                    CargarCombos();
                    CargarTransportistas();
                    CargarVendedores();
                    nMainTipo = 2;
                    lblProceso.Value = "NEW";
                    ddlTipoDocu.Enabled = true;
                }
                else
                {
                    txtNroDocu.Enabled = true;
                    txtNroSerie.Enabled = true;
                    nMainTipo = 3;
                    lblProceso.Value = "NEWDOC";
                    ddlTipoDocu.Enabled = true;
                }

                if (ddlTipoDocu.Items.Count > 1)
                {
                    if (ddlTipoDocu.Items.Count > nMainTipo - 1)
                        ddlTipoDocu.SelectedIndex = nMainTipo;
                    else
                        ddlTipoDocu.SelectedIndex = 0;

                    txtNroSerie.Text = lstDocumentos.MaxDopNroSerie(Convert.ToInt32(ddlTipoDocu.SelectedValue));
                    txtNroDocu.Focus();
                    HabilitarBtn(btnAgregar, true);
                    ModalPopupNuevoDocumento.Show();
                }
                else
                    MessageBox("No hay ningun Tipo de Documento registrado. Por favor registrar alguno antes de Comenzar.");

            }
            catch (Exception ex)
            {
                MessageBox("Error Interno: " + ex.Message);
            }
        }
コード例 #4
0
        private void SetPanelDocumento(int nOpeCod)
        {
            clsDocumenOperacion lstDocumenOpe = new clsDocumenOperacion();
            dgvDocumentos.DataSource = lstDocumenOpe.GetListDocumenOperacion(nOpeCod);
            dgvDocumentos.DataBind();

            HabilitarBtn(btnNuevoDocumento, dgvDocumentos.Rows.Count < 6);
        }
コード例 #5
0
        protected void btnAceptarNuevoDoc_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtNroDocu.Text != "")
                {
                    lblTipoDoc.Value = ddlTipoDocu.SelectedValue;
                    lblDescriDocumento.Text = ddlTipoDocu.SelectedItem.Text;
                    lblNroDocumento.Text = txtNroSerie.Text + " - " + txtNroDocu.Text;

                    if (lblProceso.Value == "NEW")
                    {
                        HabilitarCampos(true);
                        g_dtDetOperacion.Rows.Clear();
                        RellenarGrilla(ref dgvDetalleVenta, g_dtDetOperacion, this.nNroDetPed);
                        CargarCombos();
                        CargarClientes();

                        txtDireccion.Enabled = false;
                        txtDocCli.Enabled = false;
                        txtTelefono.Enabled = false;

                        txtSubTotal.Text = "0.00";
                        txtDescuento.Text = "0.00";
                        txtFlete.Text = "0.00";
                        txtIgv.Text = "0.00";
                        txtTotal.Text = "0.00";

                        txtFecha.Text = DateTime.Today.ToString("yyyy-MM-dd");
                        SetBotones(lblProceso.Value);

                    }
                    else if (lblProceso.Value == "NEWDOC")
                    {
                        clsDocumenOperacion lstDocumenOpe = new clsDocumenOperacion();

                        long ndopCod = 0;
                        int OpeCod = int.Parse(lblNroPedido.Text);

                        lstDocumenOpe.Guardar(this, ref ndopCod);
                        lbldopCod.Value = ndopCod.ToString();

                        SetPanelDocumento(OpeCod);
                        lblProceso.Value = "EDIT";
                    }

                }
                else
                {
                    MessageBox("Debe poner un Numero de Documento");
                }
            }
            catch (Exception ex)
            {
                MessageBox("Error Interno: " + ex.Message);
            }
        }
コード例 #6
0
        protected void GuardarDtCabeceraDocumento()
        {
            DocumenOperacion DocumenOpe = new DocumenOperacion();
            clsDocumenOperacion lstDocumenOpe = new clsDocumenOperacion();
            DataTable dtCabeceraOperacion = CreatDTCabeceraVenta();

            int OpeCod = int.Parse(lblNroPedido.Text);
            string NroGuia = "";
            string NroPedido = "";

            DocumenOpe = lstDocumenOpe.GetDocumenOperacion(OpeCod, 2);
            if (DocumenOpe != null)
            {
                NroGuia = DocumenOpe.dopNroSerie.ToString() + " - " + DocumenOpe.dopNumero.ToString();
            }
            DocumenOpe = lstDocumenOpe.GetDocumenOperacion(OpeCod, 4);
            if (DocumenOpe != null)
            {
                NroPedido = DocumenOpe.dopNroSerie.ToString() + " - " + DocumenOpe.dopNumero.ToString();
            }

            DataRow newRow = dtCabeceraOperacion.NewRow();
            newRow["cRazonSocial"] = ddlClientes.SelectedItem.Text;
            newRow["cDireccion"] = txtDireccion.Text;
            newRow["cTelefono"] = txtTelefono.Text;
            newRow["cNroGuia"] = NroGuia;
            newRow["cNroPedido"] = NroPedido;
            newRow["cRuc"] = txtDocCli.Text;
            newRow["cFormaPago"] = ddlTipoVenta.SelectedItem.Text;
            newRow["cAnio"] = DateTime.Parse(txtFecha.Text).Year.ToString();
            newRow["cMes"] = DateTime.Parse(txtFecha.Text).Month.ToString();
            newRow["cDia"] = DateTime.Parse(txtFecha.Text).Day.ToString();
            newRow["cValorVenta"] = SetFormatNum(GetNumero(txtValorVenta.Text) -GetNumero(txtDescuento.Text));
            newRow["cFlete"] = txtFlete.Text;
            newRow["cIGV"] = txtIgv.Text;
            newRow["cTotal"] = txtTotal.Text;
            newRow["cTotalSinFlete"] = SetFormatNum(GetNumero(newRow["cValorVenta"].ToString()) * (nTasIGV+1));
            newRow["cTotalLetras"] = ConvertiraLetras(decimal.Parse((txtTotal.Text.Replace("S/.", "").Trim()).Replace("$", "").Trim()));
            newRow["Destinatario"] = "";
            newRow["PLlegada"] = "";
            newRow["NroFactura"] = "";
            newRow["Unidad"] = "";

            dtCabeceraOperacion.Rows.Add(newRow);
            AgregarVariableSession("dtCabeceraOperacion", dtCabeceraOperacion);
        }
コード例 #7
0
        private void CargarCamposDocumento(int _dopCod, string cDopDescri)
        {
            clsDocumenOperacion lstDocumenOpe = new clsDocumenOperacion();
            DocumenOperacion DocumenOpe = new DocumenOperacion();

            try
            {
                DocumenOpe = lstDocumenOpe.GetDocumenOperacion(_dopCod);

                lblTipoDoc.Value = ddlTipoDocu.SelectedValue;
                lblDescriDocumento.Text = cDopDescri;

                lblTipoDoc.Value = DocumenOpe.tdoCod.ToString();
                lbldopCod.Value = DocumenOpe.dopCod.ToString();
                lblNroDocumento.Text = DocumenOpe.dopNroSerie.ToString() + " - " + DocumenOpe.dopNumero.ToString();
                txtFecha.Text = ((DateTime)DocumenOpe.dopFecEmision).ToString("yyyy-MM-dd");

                switch (lblTipoDoc.Value)
                {
                    case "2":
                        btnImprimir.OnClientClick = "AbrirVentanaGuia()";
                        break;
                    case "4":
                        btnImprimir.OnClientClick = "AbrirVentanaNota()";
                        break;
                    case "5":
                        btnImprimir.OnClientClick = "AbrirVentanaBoleta()";
                        break;
                    default:
                        btnImprimir.OnClientClick = "AbrirVentanaFactura()";
                        break;
                }
            }
            catch (Exception ex)
            {
                MessageBox("Error Interno: " + ex.Message);
            }
        }
コード例 #8
0
        protected void btnNuevo_Click(object sender, EventArgs e)
        {
            int nMainTipo = 0;
            try
            {
                clsDocumenOperacion lstDocumentos = new clsDocumenOperacion();

                if (((Button)sender).ToolTip == btnNuevo.ToolTip)
                {
                    HabilitarCampos(true);
                    CargarCombos();
                    nMainTipo = 2;
                    lblProceso.Value = "NEW";
                    ddlTipoDocu.Enabled = true;
                    txtProveedor.Text = "";
                }
                else
                {
                   DataRow[] Filas = g_dtDetOperacion.Select("dtpSubTotal = 0");
                   if (Filas.Count() > 0)
                   {
                       MessageBox("Tiene " + Filas.Count().ToString() + " Detalles con Precio 0, No se puede Canjear la Factura.");
                       return;
                   }
                   else {
                       txtNroDocu.Enabled = true;
                       txtNroSerie.Enabled = true;
                       nMainTipo = 3;
                       lblProceso.Value = "NEWDOC";
                       ddlTipoDocu.Enabled = false;
                   }
                }

                if (ddlTipoDocu.Items.Count > 1)
                {
                    if (ddlTipoDocu.Items.Count > nMainTipo - 1)
                        ddlTipoDocu.SelectedIndex = nMainTipo;
                    else
                        ddlTipoDocu.SelectedIndex = 0;

                    txtNroSerie.Text = lstDocumentos.MaxDopNroSerie(Convert.ToInt32(ddlTipoDocu.SelectedValue));
                    txtNroDocu.Focus();
                    HabilitarBtn(btnAgregar, true);
                    ModalPopupNuevoDocumento.Show();
                }
                else
                    MessageBox("No hay ningun Tipo de Documento registrado. Por favor registrar alguno antes de Comenzar.");

            }
            catch (Exception ex)
            {
                MessageBox("Error Interno: " + ex.Message);
            }
        }
コード例 #9
0
        protected void dgvDocumentos_SelectedIndexChanged(object sender, EventArgs e)
        {
            long ndopCod = 0;
            if (lblOpeEstado.Value.Trim() == "R")
            {
                clsDocumenOperacion lstDocumenOpe = new clsDocumenOperacion();
                lstDocumenOpe.Guardar(this, ref ndopCod);
                lbldopCod.Value = ndopCod.ToString();
            }

            int nDopCod = int.Parse(dgvDocumentos.Rows[dgvDocumentos.SelectedIndex].Cells[1].Text);
            string cDopDescri = dgvDocumentos.Rows[dgvDocumentos.SelectedIndex].Cells[2].Text;

            CargarCamposDocumento(nDopCod, cDopDescri);
        }
コード例 #10
0
        private void SetPanelDocumento(int nOpeCod)
        {
            clsDocumenOperacion lstDocumenOpe = new clsDocumenOperacion();

            dgvDocumentos.DataSource = lstDocumenOpe.GetListDocumenOperacion(nOpeCod);
            dgvDocumentos.DataBind();

            switch(lblTipoDoc.Value){
                case "2":
                    btnNuevoDocumento.Text = "Canjear Factura";
                    HabilitarBtn(btnNuevoDocumento,true);
                    break;
                case "3":
                    btnNuevoDocumento.Text = "Canjear Guia";
                    HabilitarBtn(btnNuevoDocumento, true);
                    break;
                default:
                    btnNuevoDocumento.Text = "Canjear Factura";
                    HabilitarBtn(btnNuevoDocumento, false);
                    break;
            }
            HabilitarBtn(btnNuevoDocumento, dgvDocumentos.Rows.Count<2);
            lstDocumenOpe = null;
        }
コード例 #11
0
        protected void btnProcesar_Click(object sender, EventArgs e)
        {
            string cMensaje = "";
            clsOperaciones lstOperaciones = new clsOperaciones();

            long ndopCod = 0;
            int ntcmCod = 0;
            try
            {
                if (ValidarDatos("OPE", ref cMensaje,"PROC"))
                {
                    if (lblProceso.Value == "NEW")
                    {
                        txtFleteTra.Text = Math.Round(GetNumero(txtSubTotal.Text) / 100, 2).ToString();
                        txtFlete.Text = SetFormatNum(Math.Round(GetNumero(txtSubTotal.Text) / 100, 2));
                        long nOpeCod = lstOperaciones.MaxOpeCod() + 1;
                        lblNroPedido.Text = nOpeCod.ToString().PadLeft(10, '0');
                        txtDesEspec.Text = "0.0";
                    }

                    lstOperaciones.Procesar(this, gcOpeTipo, ref ndopCod, ref ntcmCod);
                    lbldopCod.Value = ndopCod.ToString();
                    lbltcmCod.Value = ntcmCod.ToString();
                    lblOpeEstado.Value = "P";
                    bDetallesChanged = 0;

                    GuardarDtCabeceraDocumento();
                    MessageBox("La Operacion fue Procesada con Exito, Ahora puede imprimir.");
                    //NUEVO:  asigna funcion a botón IMPRIMIR
                    AsignarFuncionBotonImprimir();

                    lblProceso.Value = "EDIT";
                    SetBotones(lblProceso.Value);

                    ConfigurarDocumento();
                     /*generacion automatica de  la letra*/
                    string valor = lblTipoDoc.Value;
                    if (valor == "3" && ddlTipCiclo.SelectedValue == "D" && chkletra.Checked == true)
                    {
                        int cuotas = 1;
                        int icodigo, idetcodigo;
                        Double monto_total = Double.Parse(txtTotal.Text.ToString().Substring(3));
                        Double monto_nota = 0.00;
                        String moneda;
                        try
                        {
                            clsLetra _Letra = new clsLetra();
                            letra obj = new letra();

                            icodigo = Convert.ToInt32(_Letra.MaxOpeCod() + 1);
                            obj.icodigo = icodigo;
                            moneda = ddlMoneda.SelectedValue;
                            obj.icodigo = icodigo;
                            obj.itotcuota = cuotas;
                            obj.nmontocuota = Convert.ToDecimal(monto_total);
                            obj.cmoneda = moneda;
                            obj.nintpag = Convert.ToDecimal(0.00);
                            obj.iestado = "1";
                            obj.dfeccreacion = DateTime.Today;
                            obj.dfecmod = DateTime.Today;
                            obj.ctippago = "D";
                            obj.nmntnota = Convert.ToDecimal(monto_nota);
                            _Letra.fnletraInsertar(obj);
                            clsdetletra _detletra = new clsdetletra();
                            det_letra _detobj = new det_letra();
                            _detobj.icodletra = icodigo;
                            _detobj.inumletra = 1;
                            _detobj.cnumletra = "-";
                            _detobj.ccodletra = "-";
                            _detobj.nmonto = Convert.ToDecimal(monto_total);
                            _detobj.cestado = "1";
                            _detobj.ninteres = Convert.ToDecimal(0.00);
                            _detobj.dfecvenc = Convert.ToDateTime(txtFecha.Text).AddDays(Convert.ToInt16(this.txtCiclo.Text));
                            _detobj.dfecmod = DateTime.Today;
                            idetcodigo = Convert.ToInt32(_detletra.Maxdetletra_cod()) + 1;
                            _detobj.idetletra = idetcodigo;
                            _detletra.fndet_letraInsertar(_detobj);

                            clsDocumenOperacion _docobj = new clsDocumenOperacion();
                            DocumenOperacion _docope = new DocumenOperacion();
                            _docope = _docobj.GetDocumenOperaciona(dopcod_letra);
                            _docope.icodletra = icodigo;
                            _docobj.fnDocOpeUpdate(_docope);

                        }
                        catch (Exception ex)
                        {
                            MessageBox("Error Interno: " + ex.Message);
                        }

                    }
                }
                else
                {
                    MessageBox(cMensaje);
                }
            }
            catch (Exception ex)
            {
                MessageBox("Error Interno: " + ex.Message + ex.InnerException.Message);
            }
        }
コード例 #12
0
        protected void btnAceptarNuevoDoc_Click(object sender, EventArgs e)
        {
            try
            {
                clsDocumenOperacion colDocumenOpe = new clsDocumenOperacion();

                if (colDocumenOpe.ValidarDocumento(txtNroSerie.Text, txtNroDocu.Text))
                {
                    MessageBox("Este Nro de Documento Ya se Registro");
                    ModalPopupNuevoDocumento.Show();
                    return;
                }

                if (txtNroDocu.Text != "")
                {
                    lblTipoDoc.Value = ddlTipoDocu.SelectedValue;

                    //GUARDA EL TIPO DE DOC EN VARIABLE SESSION
                    this.AgregarVariableSession("lblTipoDoc", lblTipoDoc.Value );

                    lblDescriDocumento.Text = ddlTipoDocu.SelectedItem.Text;
                    lblNroDocumento.Text = txtNroSerie.Text + " - " + txtNroDocu.Text;

                    if (lblProceso.Value == "NEW")
                    {
                        HabilitarCampos(true);
                        g_dtDetOperacion.Rows.Clear();
                        RellenarGrilla(ref dgvDetalleVenta, g_dtDetOperacion, this.nNroDetPed);
                        CargarCombos();
                        CargarClientes();

                        txtDireccion.Enabled = false;
                        txtDocCli.Enabled = false;
                        txtTelefono.Enabled = false;

                        txtSubTotal.Text = "0.00";
                        txtDescuento.Text = "0.00";
                        txtFlete.Text = "0.00";
                        txtIgv.Text = "0.00";
                        txtTotal.Text = "0.00";
                        bDetallesChanged = 0;
                        txtFecha.Text = DateTime.Today.ToString("yyyy-MM-dd");
                        SetBotones(lblProceso.Value);
                        ConfigurarDocumento();

                    }
                    else if (lblProceso.Value == "NEWDOC")
                    {
                        long ndopCod = 0;
                        int OpeCod = int.Parse(lblNroPedido.Text);

                        colDocumenOpe.Guardar(this, ref ndopCod);
                        lbldopCod.Value = ndopCod.ToString();

                        SetPanelDocumento(OpeCod);
                        lblProceso.Value = "EDIT";
                        dgvDocumentos_SelectedIndexChanged(sender, e);
                    }

                }
                else
                {
                    MessageBox("Debe poner un Numero de Documento");
                }
            }
            catch (Exception ex)
            {
                MessageBox("Error Interno: " + ex.Message);
            }
        }
コード例 #13
0
        private void CargarCamposDocumento(int _dopCod, string cDopDescri)
        {
            clsDocumenOperacion lstDocumenOpe = new clsDocumenOperacion();
            DocumenOperacion DocumenOpe = new DocumenOperacion();

            try
            {
                DocumenOpe = lstDocumenOpe.GetDocumenOperacion(_dopCod);

                lblTipoDoc.Value = ddlTipoDocu.SelectedValue;
                lblDescriDocumento.Text = cDopDescri;

                lblTipoDoc.Value = DocumenOpe.tdoCod.ToString();
                lbldopCod.Value = DocumenOpe.dopCod.ToString();
                lblNroDocumento.Text = DocumenOpe.dopNroSerie.ToString() + " - " + DocumenOpe.dopNumero.ToString();
                txtFecha.Text = ((DateTime)DocumenOpe.dopFecEmision).ToString("yyyy-MM-dd");

                if (DocumenOpe.dopFecTraslado != null)
                    txtFecTraslado.Text = ((DateTime)DocumenOpe.dopFecTraslado).ToString("yyyy-MM-dd");
                else
                    txtFecTraslado.Text = ((DateTime)DocumenOpe.dopFecEmision).ToString("yyyy-MM-dd");

                if (DocumenOpe.dopPunPartida != null)
                    txtPuntoPartida.Text = DocumenOpe.dopPunPartida;
                else
                    txtPuntoPartida.Text = "";

                ConfigurarDocumento();
                GuardarDtCabeceraDocumento();
            }
            catch (Exception ex)
            {
                MessageBox("Error Interno: " + ex.Message);
            }
        }
コード例 #14
0
        protected void GuardarDtCabeceraDocumento()
        {
            DocumenOperacion DocumenOpe = new DocumenOperacion();
            clsDocumenOperacion lstDocumenOpe = new clsDocumenOperacion();
            DataTable dtCabeceraOperacion = CreatDTCabeceraVenta();

            int OpeCod = int.Parse(lblNroPedido.Text);

            string NroGuia = "", NroFactura = "", moneda = "", NroPedido = "", cPuntoPartida = "", cFecTraslado = "", cFormaPago = "";

            DocumenOpe = lstDocumenOpe.GetDocumenOperacion(OpeCod, 3);
            if (DocumenOpe != null)
            {

                NroFactura = DocumenOpe.dopNroSerie.ToString() + " - " + DocumenOpe.dopNumero.ToString();
                //////////////////////cmbios silvia///////////////////////////
                dopcod_letra = Convert.ToInt32(DocumenOpe.dopCod);
                /////////////////////////////////////////////////////////////
            }
            DocumenOpe = lstDocumenOpe.GetDocumenOperacion(OpeCod, 2);
            if (DocumenOpe != null)
            {
                NroGuia = DocumenOpe.dopNroSerie.ToString() + " - " + DocumenOpe.dopNumero.ToString();
                if (DocumenOpe.dopPunPartida != null)
                    cPuntoPartida = DocumenOpe.dopPunPartida;
                if (DocumenOpe.dopFecTraslado != null)
                    cFecTraslado = ((DateTime)DocumenOpe.dopFecTraslado).ToString("yyyy-MM-dd");
                else
                    cFecTraslado = ((DateTime)DocumenOpe.dopFecEmision).ToString("yyyy-MM-dd");

            }

            if (txtOpeOrdCompra.Text != "")
                NroPedido = txtOpeOrdCompra.Text;
            else
            {
                DocumenOpe = lstDocumenOpe.GetDocumenOperacion(OpeCod, 4);
                if (DocumenOpe != null)
                {
                    NroPedido = DocumenOpe.dopNroSerie.ToString() + " - " + DocumenOpe.dopNumero.ToString();

                }
            }

            if (ddlMoneda.SelectedValue == "PEN")
                moneda = " Nuevos Soles";
            else
                moneda = " Dolares";

            if (ddlTipoVenta.SelectedValue == "CR")
                cFormaPago = txtCiclo.Text + " " +  ddlTipCiclo.SelectedItem.Text;
            else
                cFormaPago = ddlTipoVenta.SelectedItem.Text;

            DataRow newRow = dtCabeceraOperacion.NewRow();
            newRow["cRazonSocial"] = ddlClientes.SelectedItem.Text;
            newRow["cDireccion"] = txtDireccion.Text;
            newRow["cTelefono"] = txtTelefono.Text;
            newRow["cNroGuia"] = NroGuia;
            newRow["cNroPedido"] = NroPedido;
            newRow["cRuc"] = txtDocCli.Text;
            newRow["cFormaPago"] = cFormaPago;
            newRow["cSimboloMon"] = ddlMoneda.SelectedValue == "PEN" ? "S/." : "$";
            newRow["cAnio"] = DateTime.Parse(txtFecha.Text).Year.ToString();
            newRow["cMes"] = DateTime.Parse(txtFecha.Text).Month.ToString();
            newRow["cDia"] = DateTime.Parse(txtFecha.Text).Day.ToString();
            newRow["cValorVenta"] = (GetNumero(txtValorVenta.Text, false) - GetNumero(txtDescuento.Text, false)).ToString("F2");
            newRow["cFlete"] = GetNumero(txtFlete.Text, false).ToString("F2");
            newRow["cIGV"] = GetNumero(txtIgv.Text, false).ToString("F2");
            newRow["cTotal"] = GetNumero(txtTotal.Text, false).ToString("F2");
            newRow["cTotalSinFlete"] = SetFormatNum(GetNumero(newRow["cValorVenta"].ToString()) * (nTasIGV + 1));
            newRow["cTotalLetras"] = ConvertiraLetras(decimal.Parse((txtTotal.Text.Replace("S/.", "").Trim()).Replace("$", "").Trim())).ToUpper() + moneda.ToUpper();
            newRow["Destinatario"] = ddlClientes.SelectedItem.Text;
            newRow["PLlegada"] = txtDireccion.Text;
            newRow["NroFactura"] = NroFactura;
            newRow["Unidad"] = "";
            newRow["PPartida"] = cPuntoPartida;
            newRow["dFecTraslado"] = cFecTraslado;
            if (ddlTipoVenta.SelectedValue == "CR")
            {
                newRow["dOpeTipCiclo"] = ddlTipCiclo.SelectedItem.Text;
                newRow["dOpeCiclo"] = txtCiclo.Text;
            }
            else
            {
                newRow["dOpeTipCiclo"] = "";
                newRow["dOpeCiclo"] = "";
            }

            dtCabeceraOperacion.Rows.Add(newRow);
            AgregarVariableSession("dtCabeceraOperacion", dtCabeceraOperacion);
        }