public override bool Update(iBillingAds ba)
        {
            using (SqlConnection conn = new SqlConnection(ConnectionString))
            {
                string q = string.Empty;

                q = @"
                    UPDATE [dbo].[billing_ads]
                       SET [customerid] = @pCustomerid
                          ,[adid] = @pAdId
                          ,[payment] = @pCost
                     WHERE id = @pid";

                SqlCommand cmd = new SqlCommand(q, conn);
                cmd.CommandText = q;
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add("@pid", SqlDbType.Int).Value         = ba.Id;
                cmd.Parameters.Add("@pCustomerid", SqlDbType.Int).Value = ba.CustomerId;
                cmd.Parameters.Add("@pAdId", SqlDbType.Int).Value       = ba.AdId;
                cmd.Parameters.Add("@pCost", SqlDbType.Money).Value     = ba.Payment;
                try
                {
                    conn.Open();
                    int rc = ExecuteNonQuery(cmd);
                    return(rc == 1);
                }
                catch (SqlException ex)
                {
                    ErrorHandler.writeSQLExceptionToLogFile(ex);
                    return(false);
                }
            }
        }
        public override bool Insert(iBillingAds ba)
        {
            using (SqlConnection conn = new SqlConnection(ConnectionString))
            {
                string     q   = string.Empty;
                SqlCommand cmd = new SqlCommand(q, conn);

                q = @"
                    INSERT INTO [dbo].[billing_ads]
                                ([customerid]
                                ,[adid]
                                ,[payment]
                                ,[paypalid]
                                ,[ppstate]
                                ,[create_time])
                            VALUES
                                (@pCustomerid
                                ,@pAdId
                                ,@pCost
                                ,@pPayPalId
                                ,@pState
                                ,@pTime)";

                cmd.CommandText = q;
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add("@pCustomerid", SqlDbType.Int).Value   = ba.CustomerId;
                cmd.Parameters.Add("@pAdId", SqlDbType.Int).Value         = ba.AdId;
                cmd.Parameters.Add("@pCost", SqlDbType.Money).Value       = ba.Payment;
                cmd.Parameters.Add("@pPayPalId", SqlDbType.VarChar).Value = ba.PayPalId;
                cmd.Parameters.Add("@pState", SqlDbType.VarChar).Value    = ba.PayPalState;
                cmd.Parameters.Add("@pTime", SqlDbType.DateTime).Value    = ba.CreateTime;

                try
                {
                    conn.Open();
                    int rc = ExecuteNonQuery(cmd);
                    return(rc == 1);
                }
                catch (SqlException ex)
                {
                    ErrorHandler.writeSQLExceptionToLogFile(ex);
                    return(false);
                }
            }
        }
        protected virtual iBillingAds GetAdBillingFromReader(IDataReader reader, bool singleRecord)
        {
            if (singleRecord)
            {
                reader.Read();
            }
            iBillingAds billing = new iBillingAds(
                Convert.ToInt32(reader["id"]),
                Convert.ToInt32(reader["customerid"]),
                Convert.ToInt32(reader["adid"]),
                Convert.ToDouble(reader["payment"]),
                reader["paypalid"].ToString(),
                reader["ppstate"].ToString(),
                Helpers.CheckNullableDate(reader["create_time"])
                );

            return(billing);
        }
 public abstract bool Update(iBillingAds c);
 public abstract bool Insert(iBillingAds c);