コード例 #1
0
ファイル: DAOPayment.cs プロジェクト: luiisperez/ARACADEMY
        public List <AraPayment> ReadAllPayments()
        {
            conn = DAO.getConnection();
            AraPayment        readPayment = new AraPayment();
            List <AraPayment> payments    = new List <AraPayment>();
            int      id;
            DateTime paymentDate;
            DateTime expirationDate;
            String   paypalTransactionId;
            Double   amount;
            Section  section;
            Student  student;

            try
            {
                conn = DAO.getConnection();
                NpgsqlTransaction tran    = conn.BeginTransaction();
                NpgsqlCommand     command = new NpgsqlCommand(DAOPaymentResource.ReadAllPaymentsSP, conn);
                command.CommandType = CommandType.StoredProcedure;

                NpgsqlDataReader dr = command.ExecuteReader();
                try
                {
                    while (dr.Read())
                    {
                        id                  = dr.GetInt32(0);
                        paymentDate         = dr.GetDateTime(1);
                        expirationDate      = dr.GetDateTime(2);
                        paypalTransactionId = dr.GetString(3);
                        amount              = dr.GetDouble(4);
                        int    remainingClasses = dr.GetInt32(5);
                        int    sectionId        = dr.GetInt32(6);
                        String studentId        = dr.GetString(7);
                        section       = new Section();
                        student       = new Student();
                        section.Id    = sectionId;
                        student.Email = studentId;
                        readPayment   = new AraPayment(id, paymentDate, expirationDate, paypalTransactionId, amount, remainingClasses, section, student);
                        payments.Add(readPayment);
                    }
                    dr.Close();
                    tran.Commit();
                    return(payments);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            catch (NpgsqlException ex2)
            {
                throw ex2;
            }
            finally
            {
                conn.Close();
            }
        }
コード例 #2
0
ファイル: DAOPayment.cs プロジェクト: luiisperez/ARACADEMY
        public int UpdateClasses(AraPayment payment)
        {
            conn = DAO.getConnection();
            NpgsqlCommand     command     = new NpgsqlCommand(DAOPaymentResource.UpdateClassesSP, conn);
            NpgsqlTransaction transaction = conn.BeginTransaction();

            NpgsqlParameter id = new NpgsqlParameter();
            NpgsqlParameter remainingClasses = new NpgsqlParameter();

            id.ParameterName = DAOPaymentResource.Id;
            remainingClasses.ParameterName = DAOPaymentResource.RemainingClasses;

            id.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Integer;
            remainingClasses.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Integer;

            id.Direction = ParameterDirection.Input;
            remainingClasses.Direction = ParameterDirection.Input;

            id.Value = payment.Id;
            remainingClasses.Value = payment.RemainingClasses;

            command.Parameters.Add(id);
            command.Parameters.Add(remainingClasses);

            command.CommandType = CommandType.StoredProcedure;

            int response = 500;

            NpgsqlDataReader dr = command.ExecuteReader();


            try
            {
                while (dr.Read())
                {
                    response = dr.GetInt32(0);
                }

                dr.Close();
                transaction.Commit();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
            return(response);
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            APIContext apiContext    = PaypalConfiguration.GetAPIContext();
            String     transactionId = "";

            try
            {
                var guid            = Request.Params["guid"];
                var payerId         = Request.Params["payerId"];
                var executedPayment = PaypalPayment.ExecutePayment(apiContext, payerId, Session[guid] as String);
                if (!executedPayment.state.ToLower().Equals("approved"))
                {
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "random", "alertmeErr()", true);
                    //Response.Redirect("~/site/failedPaypal.aspx");
                }
                transactionId = executedPayment.transactions[0].related_resources[0].sale.id;
            }
            catch (Exception ex)
            {
                String g = ex.Message;
                Response.Redirect("~/site/failedPaypal.aspx");
            }
            List <Section> cartList = (List <Section>)Session["cartList"];

            foreach (Section item in cartList)
            {
                string     username         = Session["Username"].ToString();
                DateTime   today            = DateTime.Now;
                DateTime   expirationDate   = today.AddYears(1);         //MOMENTANEAMENTE SE COLOCO QUE VENCE EN UN AÑO
                Double     amount           = item.Amount + (item.Amount * 0.21);
                Student    student          = new Student(username, ""); //OBTENER EL OBJETO DEL ESTUDIANTE QUE INICIO SESION
                int        remainingClasses = 10;
                AraPayment payment          = new AraPayment(today, expirationDate, transactionId, amount, remainingClasses, item, student);
                CreateAraPaymentCommand cmd = new CreateAraPaymentCommand(payment);
                cmd.Execute();
                Session["ScItms"] = null;
                /*DESCOMENTAR CUANDO FUNCIONE TODO EL BACK Y SE PASE CORRECTAMENTE EL ESTUDIANTE Y LOS MODULOS*/
            }
            ClientScript.RegisterClientScriptBlock(this.GetType(), "random", "alertme()", true);
            //Response.Redirect("/site/student/successPaypal.aspx");
        }
コード例 #4
0
 public CreateAraPaymentCommand(AraPayment payment)
 {
     this.payment = payment;
 }
コード例 #5
0
ファイル: DAOReport.cs プロジェクト: luiisperez/ARACADEMY
        public List <AraPayment> ReadAllPaymentsBetweenDates(DateTime initDate, DateTime endDate)
        {
            conn = DAO.getConnection();
            AraPayment        readPayment = new AraPayment();
            List <AraPayment> payments    = new List <AraPayment>();
            int      id;
            DateTime paymentDate;
            DateTime expirationDate;
            String   paypalTransactionId;
            Double   amount;
            Section  section;
            Student  student;

            try
            {
                conn = DAO.getConnection();
                NpgsqlTransaction tran        = conn.BeginTransaction();
                NpgsqlCommand     command     = new NpgsqlCommand(DAOReportResource.PaymentListSP, conn);
                NpgsqlParameter   parameter   = new NpgsqlParameter();
                NpgsqlParameter   parameter_2 = new NpgsqlParameter();

                parameter.ParameterName = DAOReportResource.IniDate;
                parameter.NpgsqlDbType  = NpgsqlTypes.NpgsqlDbType.Date;
                parameter.Direction     = ParameterDirection.Input;
                parameter.Value         = initDate;
                command.Parameters.Add(parameter);


                parameter_2.ParameterName = DAOReportResource.EndDate;
                parameter_2.NpgsqlDbType  = NpgsqlTypes.NpgsqlDbType.Date;
                parameter_2.Direction     = ParameterDirection.Input;
                parameter_2.Value         = endDate;
                command.Parameters.Add(parameter_2);

                command.CommandType = CommandType.StoredProcedure;

                NpgsqlDataReader dr = command.ExecuteReader();
                try
                {
                    while (dr.Read())
                    {
                        id                  = dr.GetInt32(0);
                        paymentDate         = dr.GetDateTime(1);
                        expirationDate      = dr.GetDateTime(2);
                        paypalTransactionId = dr.GetString(3);
                        amount              = dr.GetDouble(4);
                        int    remaingClasses = dr.GetInt32(5);
                        int    sectionId      = dr.GetInt32(6);
                        String studentId      = dr.GetString(7);
                        section       = new Section();
                        section.Id    = sectionId;
                        student       = new Student();
                        student.Email = studentId;
                        readPayment   = new AraPayment(id, paymentDate, expirationDate, paypalTransactionId, amount, remaingClasses, section, student);
                        payments.Add(readPayment);
                    }
                    dr.Close();
                    tran.Commit();
                    return(payments);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            catch (NpgsqlException ex2)
            {
                throw ex2;
            }
            finally
            {
                conn.Close();
            }
        }
コード例 #6
0
ファイル: DAOPayment.cs プロジェクト: luiisperez/ARACADEMY
        public int UpdatePayment(AraPayment payment)
        {
            conn = DAO.getConnection();
            NpgsqlCommand     command     = new NpgsqlCommand(DAOPaymentResource.UpdatePaymentSP, conn);
            NpgsqlTransaction transaction = conn.BeginTransaction();

            NpgsqlParameter id                  = new NpgsqlParameter();
            NpgsqlParameter paymentDate         = new NpgsqlParameter();
            NpgsqlParameter expirationDate      = new NpgsqlParameter();
            NpgsqlParameter paypalTransactionId = new NpgsqlParameter();
            NpgsqlParameter amount              = new NpgsqlParameter();
            NpgsqlParameter section             = new NpgsqlParameter();
            NpgsqlParameter student             = new NpgsqlParameter();

            id.ParameterName                  = DAOPaymentResource.Id;
            paymentDate.ParameterName         = DAOPaymentResource.PaymentDate;
            expirationDate.ParameterName      = DAOPaymentResource.ExpirationDate;
            paypalTransactionId.ParameterName = DAOPaymentResource.PaypalTransactionID;
            amount.ParameterName              = DAOPaymentResource.Amount;
            section.ParameterName             = DAOPaymentResource.SectionID;
            student.ParameterName             = DAOPaymentResource.StudentID;

            id.NpgsqlDbType                  = NpgsqlTypes.NpgsqlDbType.Integer;
            paymentDate.NpgsqlDbType         = NpgsqlTypes.NpgsqlDbType.Date;
            expirationDate.NpgsqlDbType      = NpgsqlTypes.NpgsqlDbType.Date;
            paypalTransactionId.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar;
            amount.NpgsqlDbType              = NpgsqlTypes.NpgsqlDbType.Numeric;
            section.NpgsqlDbType             = NpgsqlTypes.NpgsqlDbType.Integer;
            student.NpgsqlDbType             = NpgsqlTypes.NpgsqlDbType.Varchar;

            id.Direction                  = ParameterDirection.Input;
            paymentDate.Direction         = ParameterDirection.Input;
            expirationDate.Direction      = ParameterDirection.Input;
            paypalTransactionId.Direction = ParameterDirection.Input;
            amount.Direction              = ParameterDirection.Input;
            section.Direction             = ParameterDirection.Input;
            student.Direction             = ParameterDirection.Input;

            id.Value                  = payment.Id;
            paymentDate.Value         = payment.PaymentDate;
            expirationDate.Value      = payment.ExpirationDate;
            paypalTransactionId.Value = payment.PaypalTransactionId;
            amount.Value              = payment.Amount;
            section.Value             = payment.Section.Id;
            student.Value             = payment.Student.Email;

            command.Parameters.Add(id);
            command.Parameters.Add(paymentDate);
            command.Parameters.Add(expirationDate);
            command.Parameters.Add(paypalTransactionId);
            command.Parameters.Add(amount);
            command.Parameters.Add(section);
            command.Parameters.Add(student);

            command.CommandType = CommandType.StoredProcedure;

            int response = 500;

            NpgsqlDataReader dr = command.ExecuteReader();


            try
            {
                while (dr.Read())
                {
                    response = dr.GetInt32(0);
                }

                dr.Close();
                transaction.Commit();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
            return(response);
        }
コード例 #7
0
 public DeletePaymentCommand(AraPayment payment)
 {
     this.payment = payment;
 }
コード例 #8
0
        // private String oldId;

        public UpdatePaymentCommand(AraPayment payment)
        {
            this.payment = payment;
        }
コード例 #9
0
        // private String oldId;

        public UpdateRemainingClassesCommand(AraPayment payment)
        {
            this.payment = payment;
        }
コード例 #10
0
 public ReadPaymentCommand(AraPayment payment)
 {
     this.payment = payment;
 }