コード例 #1
0
        public override bool PaidInFull(iBillingVehicle v)
        {
            using (SqlConnection conn = new SqlConnection(ConnectionString))
            {
                string q = string.Empty;

                q = @"
                    UPDATE [dbo].[billingvehicles]
                       SET [paypalid] = @ppId,
                           [ppstate] = @ppState,
                           [create_time] = @PaymentDate
                     WHERE id = @pBillId";

                SqlCommand cmd = new SqlCommand(q, conn);
                cmd.CommandText = q;
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add("@ppId", SqlDbType.VarChar).Value         = v.PayPalId;
                cmd.Parameters.Add("@ppState", SqlDbType.VarChar).Value      = v.PayPalState;
                cmd.Parameters.Add("@PaymentDate", SqlDbType.DateTime).Value = v.CreateTime;
                cmd.Parameters.Add("@pBillId", SqlDbType.Int).Value          = v.Id;
                try
                {
                    conn.Open();
                    int rc = ExecuteNonQuery(cmd);
                    return(rc == 1);
                }
                catch (SqlException ex)
                {
                    ErrorHandler.writeSQLExceptionToLogFile(ex);
                    return(false);
                }
            }
        }
コード例 #2
0
        public override bool UpdateRemaining(iBillingVehicle bv)
        {
            using (SqlConnection conn = new SqlConnection(ConnectionString))
            {
                string q = string.Empty;

                q = @"
                    UPDATE [dbo].[billingvehicles]
                       SET [adsremaining] = @pRemaining
                     WHERE id = @pBillId";

                SqlCommand cmd = new SqlCommand(q, conn);
                cmd.CommandText = q;
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add("@pBillId", SqlDbType.Int).Value    = bv.Id;
                cmd.Parameters.Add("@pRemaining", SqlDbType.Int).Value = bv.AdsRemaining;
                try
                {
                    conn.Open();
                    int rc = ExecuteNonQuery(cmd);
                    return(rc == 1);
                }
                catch (SqlException ex)
                {
                    ErrorHandler.writeSQLExceptionToLogFile(ex);
                    return(false);
                }
            }
        }
コード例 #3
0
        public override int Insert(iBillingVehicle bv)
        {
            using (SqlConnection conn = new SqlConnection(ConnectionString))
            {
                string     q   = string.Empty;
                SqlCommand cmd = new SqlCommand(q, conn);

                q = @"
                    INSERT INTO [dbo].[billingvehicles]
                                ([customerid]
                                ,[adsbought]
                                ,[adsremaining]
                                ,[payment]
                                ,[promocode])
                            VALUES
                                (@pCustomerid
                                ,@pBought
                                ,@pRemaining
                                ,@pCost
                                ,@Promo);
                                SELECT SCOPE_IDENTITY()";

                cmd.CommandText = q;
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add("@pCustomerid", SqlDbType.Int).Value = bv.CustomerId;
                cmd.Parameters.Add("@pBought", SqlDbType.Int).Value     = bv.AdsBought;
                cmd.Parameters.Add("@pRemaining", SqlDbType.Int).Value  = bv.AdsRemaining;
                cmd.Parameters.Add("@pCost", SqlDbType.Money).Value     = bv.Payment;
                cmd.Parameters.Add("@Promo", SqlDbType.VarChar).Value   = bv.PromoCode;

                try
                {
                    conn.Open();
                    int rc = Convert.ToInt32(ExecuteScalar(cmd));
                    return(rc);
                }
                catch (SqlException ex)
                {
                    ErrorHandler.writeSQLExceptionToLogFile(ex);
                    return(0);
                }
            }
        }
コード例 #4
0
        protected virtual iBillingVehicle GetVehicleBillingFromReader(IDataReader reader, bool singleRecord)
        {
            if (singleRecord)
            {
                reader.Read();
            }
            iBillingVehicle billing = new iBillingVehicle(
                Convert.ToInt32(reader["id"]),
                Convert.ToInt32(reader["customerid"]),
                Convert.ToInt16(reader["adsbought"]),
                Convert.ToInt16(reader["adsremaining"]),
                Convert.ToDouble(reader["payment"]),
                Helpers.ConvertNullToBlank(reader["promocode"]),
                Helpers.ConvertNullToBlank(reader["paypalid"]),
                Helpers.ConvertNullToBlank(reader["ppstate"]),
                Helpers.CheckNullableDate(reader["create_time"])
                );

            return(billing);
        }
コード例 #5
0
 public abstract bool PaidInFull(iBillingVehicle v);
コード例 #6
0
 public abstract bool UpdateRemaining(iBillingVehicle c);
コード例 #7
0
 public abstract int Insert(iBillingVehicle c);