Пример #1
0
        public void RegistrarDatoFactura(DtoDatoFactura objfactura)
        {
            bool           correcto    = true;
            DtoDatoFactura objfactura2 = new DtoDatoFactura();

            objfactura2.FK_VU_DNI = objfactura.FK_VU_DNI;
            objfactura2.IDF_RUC   = objfactura.IDF_RUC;
            correcto = !factura.selectRUC(objfactura2);
            if (!correcto)
            {
                objfactura.error = 2;
                return;
            }
            correcto = 10 < objfactura.IDF_RUC.Length && objfactura.IDF_RUC.Length < 12;
            if (!correcto)
            {
                objfactura.error = 3; return;
            }
            for (int i = 0; i < objfactura.IDF_RUC.Length; i++)
            {
                correcto = char.IsDigit(objfactura.IDF_RUC.Trim()[i]);
            }
            if (!correcto)
            {
                objfactura.error = 4; return;
            }
            objfactura.error = 77;
            factura.InsertarDatoFactura(objfactura);
        }
Пример #2
0
        public void DeleteDatoFatcura(DtoDatoFactura objDtoDatoFactura)
        {
            string     insert  = "DELETE T_DATO_FACTURA WHERE VDF_Ruc='" + objDtoDatoFactura.VDF_Ruc + "'" + "and FK_VU_Dni='" + objDtoDatoFactura.FK_VU_Dni + "'";
            SqlCommand command = new SqlCommand(insert, conexion);

            conexion.Open();
            command.ExecuteNonQuery();
            conexion.Close();
        }
Пример #3
0
        public void InsertDatoFatcura(DtoDatoFactura objDtoDatoFactura)
        {
            string     insert  = "INSERT INTO T_DATO_FACTURA VALUES('" + objDtoDatoFactura.VDF_Ruc + "','" + objDtoDatoFactura.FK_VU_Dni + "')";
            SqlCommand command = new SqlCommand(insert, conexion);

            conexion.Open();
            command.ExecuteNonQuery();
            conexion.Close();
        }
Пример #4
0
        public void InsertarDatoFactura(DtoDatoFactura factura)
        {
            SqlCommand command = new SqlCommand("SP_InsertarDatoFactura", conexion);

            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.AddWithValue("@id", factura.PK_IDF_Cod);
            command.Parameters.AddWithValue("@ruc", factura.IDF_RUC);
            command.Parameters.AddWithValue("@dni", factura.FK_VU_DNI);
            conexion.Open();
            command.ExecuteNonQuery();
            conexion.Close();
        }
Пример #5
0
        public DataSet SelectRUCxDNI(DtoDatoFactura objDtoDatoFactura)
        {
            string     select  = "SELECT VDF_Ruc from T_DATO_FACTURA where FK_VU_Dni ='" + objDtoDatoFactura.FK_VU_Dni + "'";
            SqlCommand command = new SqlCommand(select, conexion);

            conexion.Open();
            SqlDataAdapter daAdapter = new SqlDataAdapter(command);
            DataSet        DS        = new DataSet();

            daAdapter.Fill(DS);
            return(DS);
        }
Пример #6
0
        public bool selectRUC(DtoDatoFactura objfactura)
        {
            string     Select    = "SELECT * from T_DatoFactura where FK_VU_Dni ='" + objfactura.FK_VU_DNI + "' and VDF_Ruc='" + objfactura.IDF_RUC + "'";
            SqlCommand unComando = new SqlCommand(Select, conexion);

            conexion.Open();
            SqlDataReader reader       = unComando.ExecuteReader();
            bool          hayRegistros = reader.Read();

            if (hayRegistros)
            {
                objfactura.IDF_RUC = (string)reader[1];
            }
            conexion.Close();
            return(hayRegistros);
        }
Пример #7
0
        public bool SelectDatoFacturaxRUC_Dni(DtoDatoFactura objDtoDatoFactura)
        {
            string     Select    = "SELECT * from T_DATO_FACTURA where FK_VU_Dni ='" + objDtoDatoFactura.FK_VU_Dni + "' and VDF_Ruc='" + objDtoDatoFactura.VDF_Ruc + "'";
            SqlCommand unComando = new SqlCommand(Select, conexion);

            conexion.Open();
            SqlDataReader reader       = unComando.ExecuteReader();
            bool          hayRegistros = reader.Read();

            if (hayRegistros)
            {
                objDtoDatoFactura.VDF_Ruc = (string)reader[1];
            }
            conexion.Close();
            return(hayRegistros);
        }
Пример #8
0
    public void mostrarmsjFACTURA(DtoDatoFactura d)
    {
        switch (d.error)
        {
        case 2:
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "swal({type: 'error',title: 'ERROR!',text: 'RUC DUPLICADA!!!'});", true);
            break;

        case 3:
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "swal({type: 'error',title: 'ERROR!',text: 'No tiene el tamaño CORRECTO!!!'});", true);
            break;

        case 4:
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "swal({type: 'error',title: 'ERROR!',text: 'El RUC no admite LETRAS!!!'});", true);
            break;
        }
    }
Пример #9
0
        public bool formatoRUC(DtoDatoFactura objDtoDatoFactura)
        {
            string letras   = "";
            bool   correcto = true;
            string ruc      = objDtoDatoFactura.VDF_Ruc;

            for (int i = 0; i < ruc.Trim().Length; i++)
            {
                correcto = char.IsDigit(ruc.Trim()[i]);
                if (!correcto)
                {
                    letras += ruc.Trim()[i];
                }
            }
            if (letras.Length > 0)
            {
                return(false);
            }
            else
            {
                return(correcto);
            }
        }
Пример #10
0
 public void EliminarRUC(DtoDatoFactura objDtoDatoFactura)
 {
     objDaoDatoFactura.DeleteDatoFatcura(objDtoDatoFactura);
 }
Пример #11
0
 public DataSet ListarRucs(DtoDatoFactura objDtoDatoFactura)
 {
     return(objDaoDatoFactura.SelectRUCxDNI(objDtoDatoFactura));
 }
Пример #12
0
 public bool RUC_Duplicado(DtoDatoFactura objDtoDatoFactura)
 {
     return(objDaoDatoFactura.SelectDatoFacturaxRUC_Dni(objDtoDatoFactura));
 }
Пример #13
0
 public void RegistrarDatoFatcura(DtoDatoFactura objDtoDatoFactura)
 {
     objDaoDatoFactura.InsertDatoFatcura(objDtoDatoFactura);
 }
Пример #14
0
    protected void btnEnviar_Click(object sender, EventArgs e)
    {
        Log _Log = new Log();

        try
        {
            objfacturaneg = new CtrDatoFactura();
            objfactura    = new DtoDatoFactura();
            objpago       = new DtoPago();
            objpagoneg    = new CtrPago();
            objsol        = new DtoSolicitud();
            objsolneg     = new Ctr_Solicitud();
            objvou        = new DtoVoucher();
            objvouneg     = new CtrVoucher();
            int ultimo = objfacturaneg.ultimo();

            if (valorObtenidoRBTN.Value != "1" && valorObtenidoRBTN.Value != "2")
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "swal({icon: 'error',title: 'ERROR!',text: 'Seleccione BOLETA o FACTURA!!'});", true);
                return;
            }
            if (txtImporte.Text == "" | txtNumOp.Text == "")
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "swal({icon: 'error',title: 'ERROR!',text: 'Complete espacios en BLANCO!!'});", true);
                return;
            }
            if (txtnewRUC.Text == "" && valorCheck.Value == "3" && valorObtenidoRBTN.Value == "2")
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "swal({icon: 'error',title: 'ERROR!',text: 'Complete espacios en BLANCO!!'});", true);
                return;
            }
            if (ddlRUC.Text == "" && valorObtenidoRBTN.Value == "2" && valorCheck.Value != "3")
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "swal({icon: 'error',title: 'ERROR!',text: 'Complete espacios en BLANCO!!'});", true);
                return;
            }

            objsol.PK_IS_Cod           = Convert.ToInt32(Session["idSolicitudPago"].ToString());
            objfactura.PK_IDF_Cod      = ultimo + 1;
            objfactura.VDF_RazonSocial = "";
            objfactura.FK_VU_DNI       = Session["DNIUsuario"].ToString();
            if (valorObtenidoRBTN.Value == "2" && valorCheck.Value == "3")
            {
                objpago.IP_TipoCertificado = 2;
                objpago.VP_RUC             = txtnewRUC.Text;
                objfactura.IDF_RUC         = txtnewRUC.Text;
            }
            if (valorObtenidoRBTN.Value == "2" && valorCheck.Value != "3")
            {
                objpago.VP_RUC             = ddlRUC.Text;
                objpago.IP_TipoCertificado = 2;
            }
            if (valorObtenidoRBTN.Value == "1")
            {
                objpago.VP_RUC             = "";
                objpago.IP_TipoCertificado = 1;
            }
            objpago.FK_IS_Cod        = Convert.ToInt32(Session["idSolicitudPago"].ToString());
            objpago.DP_ImportePagado = Convert.ToDouble(txtImporte.Text);
            double costo = objpagoneg.Costo(objpago);

            objpago.DP_ImporteRestante = costo - Convert.ToDouble(txtImporte.Text);

            if (Convert.ToDouble(txtImporte.Text) == (costo / 2))
            {
                objpago.IP_TipoPago = 1;
            }
            if (Convert.ToDouble(txtImporte.Text) > (costo / 2) | Convert.ToDouble(txtImporte.Text) == costo)
            {
                objpago.IP_TipoPago = 2;
            }
            objvou.PK_VV_NumVoucher     = txtNumOp.Text;
            objvou.DV_ImporteDepositado = Convert.ToDouble(txtImporte.Text);
            objvou.VV_Comentario        = "";

            if (hftxtimg.Value == "vacio")
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "mensaje", "swal({icon: 'error',title: 'ERROR!',text: 'suba la IMAGEN!!'});", true);
                return;
            }
            else
            {
                _Log.CustomWriteOnLog("ImagenGuardada", "EL CAMPO ESTA LLENO");
            }
            objpagoneg.RegistrarPago(objpago);
            mostrarmsjPAGO(objpago);
            if (objpago.error == 77 && valorCheck.Value == "3" && valorObtenidoRBTN.Value == "2")
            {
                objfacturaneg.RegistrarDatoFactura(objfactura);
                mostrarmsjFACTURA(objfactura);
                _Log.CustomWriteOnLog("RealizarCompra.cs", "Ruc registrado");
                objvouneg.RegistrarVoucher(objvou);
                _Log.CustomWriteOnLog("RealizarCompra.cs", "2");
                Utils.AddScriptClientUpdatePanel(UpdatePanel1, "uploadFileImagenVoucher('" + objvou.PK_VV_NumVoucher + "');");
                _Log.CustomWriteOnLog("RealizarCompra.cs", "3");
                objsolneg.ActualizarEstado(objsol);
            }
            if (objpago.error == 77 && valorObtenidoRBTN.Value == "2" && valorCheck.Value != "3")
            {
                _Log.CustomWriteOnLog("RealizarCompra.cs", "Ruc registrado");
                objvouneg.RegistrarVoucher(objvou);
                _Log.CustomWriteOnLog("RealizarCompra.cs", "2");
                Utils.AddScriptClientUpdatePanel(UpdatePanel1, "uploadFileImagenVoucher('" + objvou.PK_VV_NumVoucher + "');");
                _Log.CustomWriteOnLog("RealizarCompra.cs", "3");
                objsolneg.ActualizarEstado(objsol);
            }
            if (objpago.error == 77)
            {
                _Log.CustomWriteOnLog("RealizarCompra.cs", "1");
                objvouneg.RegistrarVoucher(objvou);
                _Log.CustomWriteOnLog("RealizarCompra.cs", "2");
                Utils.AddScriptClientUpdatePanel(UpdatePanel1, "uploadFileImagenVoucher('" + objvou.PK_VV_NumVoucher + "');");
                _Log.CustomWriteOnLog("RealizarCompra.cs", "3");
                objsolneg.ActualizarEstado(objsol);
            }
        }
        catch (Exception ex)
        {
            _Log.CustomWriteOnLog("RealizarCompra.cs", "error   " + ex.Message);
        }
    }